diff --git a/grammar.g4 b/grammar.g4 index 58092d6..915f12b 100644 --- a/grammar.g4 +++ b/grammar.g4 @@ -26,7 +26,7 @@ function_definition: (definietion_info)? (ANNOTATION_INFO)* (constraint ';')* (('%' | 'let') | ('$' | 'var'))? SIMPLE_NAME_IDENTIFIER ((ANNOTATION_IDENTIFIER)? ARGUMENT_NAME_IDENTIFIER ('?')?)* (':' ((ANNOTATION_IDENTIFIER)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)? - (('=' ((super_expression ';') | block)) | ';') + (('=' ( /*prec 2*/ block | (super_expression ';'))) | ';') ; typeclass_definition: (DEFINITION_INFO)? (ANNOTATION_INFO)* @@ -102,7 +102,6 @@ expression: name_expression | return | lambda | constructor - | block | not_name_scoped_expression ; @@ -110,15 +109,17 @@ scoped_expression: name_identifier | not_name_scoped_expression ; -not_name_scoped_expression: PLACEHOLDER +not_name_scoped_expression: block + | array + | PLACEHOLDER | name_definition | access | tuple_access | loop_control - | array + | reference + | suffix_expression | literal | '(' super_expression ')' - | reference ; variant_type: ('|')? tuple_type ('|' tuple_type)+ ; diff --git a/grammar.js b/grammar.js index e1e973a..2c2b567 100644 --- a/grammar.js +++ b/grammar.js @@ -64,7 +64,7 @@ module.exports = grammar({ optional(choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'))), $.type, )))), - choice(seq('=', choice(seq($._super_expression, ';'), $.block)), ';'), + choice(seq('=', choice(prec(2, $.block), seq($._super_expression, ';'))), ';'), ), typeclass_definition: $ => seq( @@ -185,7 +185,6 @@ module.exports = grammar({ _expression: $ => choice( $.operator_expression, - $.block, $.return, $.name_expression, $.constructor, @@ -199,6 +198,7 @@ module.exports = grammar({ ), _not_name_scoped_expression: $ => choice( + $.block, $.array, $.placeholder, $.name_definition,