lang: first test and stuff

This commit is contained in:
Schrottkatze 2024-04-24 21:09:55 +02:00
parent ba0da33509
commit 4df0118aa4
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
5 changed files with 69 additions and 5 deletions

View file

@ -1,6 +1,13 @@
use std::fmt::Debug;
use crate::parser::syntax_kind::SyntaxKind::*;
use super::Parser;
use super::{
input::Input,
output::Output,
syntax_kind::{self, lex},
Parser,
};
mod expression;
@ -12,3 +19,16 @@ pub fn source_file(p: &mut Parser) {
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);
}