From 94db2ea17fd0d9586b59ddffae7520e639b4d07e Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sat, 20 Nov 2021 19:42:50 -0800 Subject: [PATCH] Add toknl thing --- schala-lang/src/parsing/combinator.rs | 8 +++++++- schala-lang/src/parsing/test.rs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/schala-lang/src/parsing/combinator.rs b/schala-lang/src/parsing/combinator.rs index 48ea43d..6d48e67 100644 --- a/schala-lang/src/parsing/combinator.rs +++ b/schala-lang/src/parsing/combinator.rs @@ -70,7 +70,13 @@ fn fresh_id(span: &Span) -> Id { fn tok<'a, O>( input_parser: impl Parser, O, VerboseError>>, ) -> impl FnMut(Span<'a>) -> IResult, O, VerboseError>> { - context("tok", preceded(ws0, input_parser)) + context("token", preceded(ws0, input_parser)) +} + +fn toknl<'a, O>( + input_parser: impl Parser, O, VerboseError>>, +) -> impl FnMut(Span<'a>) -> IResult, O, VerboseError>> { + context("token/newline", preceded(ws0, input_parser)) } fn kw<'a>(keyword_str: &'static str) -> impl FnMut(Span<'a>) -> ParseResult<()> { diff --git a/schala-lang/src/parsing/test.rs b/schala-lang/src/parsing/test.rs index 66c1f73..02cd750 100644 --- a/schala-lang/src/parsing/test.rs +++ b/schala-lang/src/parsing/test.rs @@ -534,7 +534,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"; + let err = "0: at line 1, in Verify:\nmodule::item::call()\n^\n\n1: at line 1, in token:\nmodule::item::call()\n^\n\n2: at line 1, in token:\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!("module::item::call()", err); assert_expr!("modulek::item", expr(ExpressionKind::Value(qn!(modulek, item)))); @@ -801,7 +801,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"; + 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 token:\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!("a(b,,c)", err_msg); assert_ast!(