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