Skip to main content

oak_pascal/parser/
mod.rs

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