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