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