Skip to main content

oak_d/parser/
mod.rs

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