Skip to main content

oak_msil/parser/
mod.rs

1use crate::{language::MsilLanguage, lexer::MsilLexer};
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, MsilLanguage, S>;
11
12pub struct MsilParser<'config> {
13    pub(crate) _config: &'config MsilLanguage,
14}
15
16impl<'config> MsilParser<'config> {
17    pub fn new(config: &'config MsilLanguage) -> Self {
18        Self { _config: config }
19    }
20}
21
22impl<'config> Parser<MsilLanguage> for MsilParser<'config> {
23    fn parse<'a, S: Source + ?Sized>(&self, text: &'a S, edits: &[TextEdit], cache: &'a mut impl ParseCache<MsilLanguage>) -> oak_core::ParseOutput<'a, MsilLanguage> {
24        let lexer = MsilLexer::new(self._config);
25        oak_core::parser::parse_with_lexer(&lexer, text, edits, cache, |state| self.parse_root_internal(state))
26    }
27}