diff --git a/schala-lang/src/parsing/combinator.rs b/schala-lang/src/parsing/combinator.rs index 1d1643b..f7475b6 100644 --- a/schala-lang/src/parsing/combinator.rs +++ b/schala-lang/src/parsing/combinator.rs @@ -503,11 +503,14 @@ fn extended_expr_part(input: Span) -> ParseResult { fn call_part(input: Span) -> ParseResult> { context( "call-part", - //TODO generalize this `not` - delimited( - tok(char('(')), - separated_list0(tok(char(',')), preceded(not(tok(char(')'))), invocation_argument)), - tok(char(')')), + verify( + //TODO generalize this `not` + delimited( + tok(char('(')), + separated_list0(tok(char(',')), preceded(not(tok(char(')'))), invocation_argument)), + tok(char(')')), + ), + |output: &Vec<_>| output.len() <= 255, ), )(input) } diff --git a/schala-lang/src/parsing/test.rs b/schala-lang/src/parsing/test.rs index 14d8d88..f7c5b91 100644 --- a/schala-lang/src/parsing/test.rs +++ b/schala-lang/src/parsing/test.rs @@ -113,6 +113,7 @@ macro_rules! assert_ast { }; } +/* macro_rules! assert_fail { ($input:expr, $failure:expr) => { let mut parser = Parser::new(); @@ -120,8 +121,13 @@ macro_rules! assert_fail { assert_eq!(err.msg, $failure); }; } +*/ -macro_rules! assert_fail_comb { +macro_rules! assert_fail { + ($input:expr) => { + let mut parser = Parser::new(); + let err = parser.parse_comb($input).unwrap_err(); + }; ($input:expr, $failure:expr) => { let mut parser = Parser::new(); let err = parser.parse_comb($input).unwrap_err(); @@ -557,7 +563,7 @@ fn complex_lambdas() { #[test] fn reserved_words() { let err = "0: at line 1, in Verify:\nmodule::item::call()\n^\n\n1: at line 1, in tok:\nmodule::item::call()\n^\n\n2: at line 1, in tok:\nmodule::item::call()\n^\n\n3: at line 1, in primary-expr-no-struct:\nmodule::item::call()\n^\n\n4: at line 1, in primary-expr:\nmodule::item::call()\n^\n\n5: at line 1, in extended-expr:\nmodule::item::call()\n^\n\n6: at line 1, in prefix-expr:\nmodule::item::call()\n^\n\n7: at line 1, in expression-kind:\nmodule::item::call()\n^\n\n8: at line 1, in Parsing-statement:\nmodule::item::call()\n^\n\n9: at line 1, in AST:\nmodule::item::call()\n^\n\n"; - assert_fail_comb!("module::item::call()", err); + assert_fail!("module::item::call()", err); assert_expr!("modulek::item", expr(ExpressionKind::Value(qn!(modulek, item)))); } @@ -824,7 +830,7 @@ fn functions() { }) ); let err_msg = "0: at line 1, in Alpha:\na(b,,c)\n ^\n\n1: at line 1, in Alt:\na(b,,c)\n ^\n\n2: at line 1, in tok:\na(b,,c)\n ^\n\n3: at line 1, in identifier-expr:\na(b,,c)\n ^\n\n4: at line 1, in Alt:\na(b,,c)\n ^\n\n5: at line 1, in primary-expr:\na(b,,c)\n ^\n\n6: at line 1, in extended-expr:\na(b,,c)\n ^\n\n7: at line 1, in prefix-expr:\na(b,,c)\n ^\n\n8: at line 1, in expression-kind:\na(b,,c)\n ^\n\n9: at line 1, in Alt:\na(b,,c)\n ^\n\n10: at line 1, in invocation-argument:\na(b,,c)\n ^\n\n11: at line 1, in call-part:\na(b,,c)\n ^\n\n12: at line 1, in extended-expr:\na(b,,c)\n^\n\n13: at line 1, in prefix-expr:\na(b,,c)\n^\n\n14: at line 1, in expression-kind:\na(b,,c)\n^\n\n15: at line 1, in Parsing-statement:\na(b,,c)\n^\n\n16: at line 1, in AST:\na(b,,c)\n^\n\n"; - assert_fail_comb!("a(b,,c)", err_msg); + assert_fail!("a(b,,c)", err_msg); assert_ast!( "fn a(b, c: Int): Int", @@ -868,8 +874,8 @@ fn max_function_params() { } write!(buf, ") {{ return 20 }}").unwrap(); //assert_fail!(&buf, "A function cannot have more than 255 arguments"); - //TODO better errors again - assert_fail!(&buf, "error at 1:1439: expected ['a' ..= 'z' | 'A' ..= 'Z' | '_']"); + //TODO need to create a good, custom error message for this case + assert_fail!(&buf); } #[test]