1pub mod lexer;
7pub mod parser;
8pub use ariadne::{Report, Source};
9use chumsky::input::Stream;
10pub use chumsky::input::ValueInput;
11use chumsky::prelude::*;
12use lexer::*;
13pub use lexer::{lex, report_lex_errors};
14pub use parser::parse as parse_from_lex;
15pub use parser::report_parse_errors;
16use parser::*;
17
18pub fn parse<'a>(src: &'a str) -> ParseResult<SourceText<'a>, Rich<'a, Token<'a>>> {
19 let lexed_src = lex(src);
20 let mapped_lexed_src = lexed_src.into_iter().map(|(tok, span)| match tok {
21 Ok(tok) => (
22 tok,
23 <std::ops::Range<usize> as Into<SimpleSpan>>::into(span),
24 ),
25 Err(_) => (
26 Token::Error,
27 <std::ops::Range<usize> as Into<SimpleSpan>>::into(span),
28 ),
29 });
30 let stream_lexed_src = Stream::from_iter(mapped_lexed_src).map((0..src.len()).into(), |x| x);
31 parse_from_lex(stream_lexed_src)
32}