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