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