parser now bubbles errors instead of unit type
llvm added to dependencies
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| use lrlex::lrlex_mod; | ||||
| use lrpar::lrpar_mod; | ||||
|  | ||||
| use crate::ast::errors::ParsingError; | ||||
| use crate::ast::{Expression, Literal, Program}; | ||||
|  | ||||
| lrlex_mod!("lexers/fudge.l"); | ||||
| @@ -21,19 +22,14 @@ macro_rules! test_literal_list { | ||||
|     }; | ||||
| } | ||||
|  | ||||
| fn parse_expr(input: &str) -> Result<Expression, ()> { | ||||
| fn parse_expr(input: &str) -> Result<Expression, ParsingError> { | ||||
|     let lexerdef = expr_only_l::lexerdef(); | ||||
|     let lexer = lexerdef.lexer(&input); | ||||
|     let (res, errs) = expr_only_y::parse(&lexer); | ||||
|     if let Some(parsed_res) = res { | ||||
|         parsed_res | ||||
|     } else { | ||||
|         Err(()) | ||||
|     } | ||||
|     res.expect("REASON") | ||||
| } | ||||
| #[test] | ||||
| fn test_int_literal() { | ||||
|  | ||||
|     let matches_parsed_int = |s: &str| match parse_expr(s) { | ||||
|         Ok(i) => matches!(i, Expression::Lit(Literal::Int(_))), | ||||
|         Err(_) => false, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user