1pub mod element_type;
2
3use crate::{language::LeanLanguage, lexer::LeanLexer};
4use element_type::LeanElementType;
5use oak_core::{
6 parser::{ParseCache, ParseOutput, Parser, ParserState, parse_with_lexer},
7 source::{Source, TextEdit},
8};
9
10mod parse_top_level;
11
12pub(crate) type State<'a, S> = ParserState<'a, LeanLanguage, S>;
13
14pub struct LeanParser<'config> {
15 pub(crate) config: &'config LeanLanguage,
16}
17
18impl<'config> LeanParser<'config> {
19 pub fn new(config: &'config LeanLanguage) -> Self {
20 Self { config }
21 }
22}
23
24impl<'config> Parser<LeanLanguage> for LeanParser<'config> {
25 fn parse<'a, S: Source + ?Sized>(&self, text: &'a S, edits: &[TextEdit], cache: &'a mut impl ParseCache<LeanLanguage>) -> ParseOutput<'a, LeanLanguage> {
26 let lexer = LeanLexer::new(&self.config);
27 parse_with_lexer(&lexer, text, edits, cache, |state| self.parse_root_internal(state))
28 }
29}