diff --git a/grammar.js b/grammar.js index 2b8234d..f4230f2 100644 --- a/grammar.js +++ b/grammar.js @@ -274,7 +274,7 @@ module.exports = grammar({ }, - lambda_expr: $ => prec.right(1, seq( + lambda_expr: $ => prec.right('lambda', seq( choice( $.identifier, // TODO: can lambdas args have type annotations? @@ -384,10 +384,11 @@ module.exports = grammar({ 'braced_any', 'local_def', 'if_else', // TODO: docs don't specify precedence + 'lambda', ], [ - 'tuple', 'parens', + 'tuple', ], [ 'function_type', diff --git a/test/corpus/expressions.txt b/test/corpus/expressions.txt index b17d5e4..2648bd9 100644 --- a/test/corpus/expressions.txt +++ b/test/corpus/expressions.txt @@ -284,6 +284,17 @@ action _ = all { (qualified_identifier (identifier)))))))))) +========================================= +UFCS Application - Multi Line +========================================= + +def _ = list + .filter(f) + .map(g) + +--- + + ========================================= List Access via Index ========================================= @@ -454,9 +465,9 @@ action _ = { (qualified_identifier (identifier)))))))))) -========================== -Local Variable Definition -========================== +============================ +Local Variable Definition 1 +============================ def _ = and { val coins = GetAllBalances(addr) @@ -502,6 +513,16 @@ def _ = and { (expr (int_literal))))))))))))))) +============================ +Local Variable Definition 2 +============================ + +def _ = val test = foo.bar() 42 +def _ = val test = foo.bar () + +--- + + =========================== Map Constructor =========================== @@ -626,32 +647,39 @@ Tuple Constructor ============================ val _ = () -val _ = (e_1) +val _ = (e_1) // <-- not a tuple val _ = (e_1, e_2, e_3) --- (source_file (operator_definition - (qualified_identifier (identifier)) + (qualified_identifier + (identifier)) (expr (tuple_literal))) (operator_definition - (qualified_identifier (identifier)) + (qualified_identifier + (identifier)) (expr - (tuple_literal - (expr - (qualified_identifier (identifier)))))) + (expr + (qualified_identifier + (identifier)))) + (comment)) (operator_definition - (qualified_identifier (identifier)) + (qualified_identifier + (identifier)) (expr (tuple_literal (expr - (qualified_identifier (identifier))) + (qualified_identifier + (identifier))) (expr - (qualified_identifier (identifier))) + (qualified_identifier + (identifier))) (expr - (qualified_identifier (identifier))))))) + (qualified_identifier + (identifier))))))) ============================ Match Expression diff --git a/test/corpus/module-level-constructs.txt b/test/corpus/module-level-constructs.txt index c7d2ade..6026dd1 100644 --- a/test/corpus/module-level-constructs.txt +++ b/test/corpus/module-level-constructs.txt @@ -21,6 +21,7 @@ const N: int const Proc: Set[str] --- + (source_file (constant_declaration (qualified_identifier (identifier))