print and more

This commit is contained in:
nora 2021-12-29 20:12:45 +01:00
parent ebbc675ffd
commit 9e643b8acd
9 changed files with 150 additions and 54 deletions

View file

@ -292,6 +292,28 @@ mod r#if {
}
}
mod print {
use super::prelude::*;
fn parse_print(tokens: Vec<Token>) -> Stmt {
let mut parser = parser(tokens);
parser.print_stmt().unwrap()
}
#[test]
fn print_true() {
let tokens = [Print, True].map(token).into();
let ast = parse_print(tokens);
assert_eq!(
Stmt::Print(
Expr::Literal(Literal::Boolean(true, Span::dummy())),
Span::dummy()
),
ast
);
}
}
mod r#while {
use super::prelude::*;