1use crate::language::PerlLanguage;
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, PerlLanguage, S>;
10
11pub struct PerlParser<'config> {
12 pub(crate) config: &'config PerlLanguage,
13}
14
15impl<'config> PerlParser<'config> {
16 pub fn new(config: &'config PerlLanguage) -> Self {
17 Self { config }
18 }
19}
20
21impl<'config> Parser<PerlLanguage> for PerlParser<'config> {
22 fn parse<'a, S: Source + ?Sized>(&self, text: &'a S, edits: &[TextEdit], cache: &'a mut impl ParseCache<PerlLanguage>) -> ParseOutput<'a, PerlLanguage> {
23 let lexer = crate::lexer::PerlLexer::new(&self.config);
24 parse_with_lexer(&lexer, text, edits, cache, |state| self.parse_root_internal(state))
25 }
26}