error tokens instead of result

This commit is contained in:
nora 2021-12-30 16:21:18 +01:00
parent 5ae747d513
commit 11b735d728
3 changed files with 49 additions and 36 deletions

View file

@ -18,7 +18,13 @@ pub fn run_program(program: &str) {
let ast_alloc = Bump::new();
let lexer = lex::Lexer::new(program);
let ast = parse::parse(lexer, &ast_alloc);
let ast = parse::parse(
lexer.map(|token| match &token.kind {
TokenType::Error(err) => Err(err.clone()),
_ => Ok(token),
}),
&ast_alloc,
);
match ast {
Ok(ast) => process_ast(program, ast),