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