lang: add pipelines and rename parser to lst_parser
This commit is contained in:
parent
db2643359c
commit
30f17773a8
18 changed files with 108 additions and 47 deletions
34
crates/lang/src/lst_parser/grammar.rs
Normal file
34
crates/lang/src/lst_parser/grammar.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
use crate::lst_parser::syntax_kind::SyntaxKind::*;
|
||||
|
||||
use super::{
|
||||
input::Input,
|
||||
output::Output,
|
||||
syntax_kind::{self, lex},
|
||||
Parser,
|
||||
};
|
||||
|
||||
mod expression;
|
||||
|
||||
pub fn source_file(p: &mut Parser) {
|
||||
let root = p.start("root");
|
||||
|
||||
expression::expression(p, false);
|
||||
p.eat_succeeding_ws();
|
||||
|
||||
root.complete(p, ROOT);
|
||||
}
|
||||
|
||||
fn check_parser(input: &str, parser_fn: fn(&mut Parser), output: &str) {
|
||||
let toks = lex(input);
|
||||
let mut parser = Parser::new(Input::new(&toks));
|
||||
|
||||
parser_fn(&mut parser);
|
||||
|
||||
let p_out = dbg!(parser.finish());
|
||||
let o = Output::from_parser_output(toks, p_out);
|
||||
|
||||
let s = format!("{o:?}");
|
||||
assert_eq!(&s, output);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue