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