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