1use crate::{language::CobolLanguage, lexer::CobolLexer};
2use oak_core::{
3 parser::{ParseCache, ParseOutput, Parser, parse_with_lexer},
4 source::{Source, TextEdit},
5};
6
7pub mod element_type;
13
14pub use element_type::CobolElementType;
15
16pub struct CobolParser;
18
19impl CobolParser {
20 pub fn new() -> Self {
22 Self
23 }
24}
25
26impl Parser<CobolLanguage> for CobolParser {
27 fn parse<'a, S: Source + ?Sized>(&self, text: &'a S, edits: &[TextEdit], cache: &'a mut impl ParseCache<CobolLanguage>) -> ParseOutput<'a, CobolLanguage> {
28 let lexer = CobolLexer::new();
29 parse_with_lexer(&lexer, text, edits, cache, |state| {
30 let cp = state.checkpoint();
31 while state.not_at_end() {
32 state.bump();
33 }
34 Ok(state.finish_at(cp, CobolElementType::Root))
35 })
36 }
37}