block moved to scoped_expression

This commit is contained in:
ProgramSnail 2023-07-18 14:37:16 +03:00
parent 7f53a21f20
commit f525fce6d7
2 changed files with 8 additions and 7 deletions

View file

@ -26,7 +26,7 @@ function_definition: (definietion_info)? (ANNOTATION_INFO)* (constraint ';')*
(('%' | 'let') | ('$' | 'var'))? SIMPLE_NAME_IDENTIFIER (('%' | 'let') | ('$' | 'var'))? SIMPLE_NAME_IDENTIFIER
((ANNOTATION_IDENTIFIER)? ARGUMENT_NAME_IDENTIFIER ('?')?)* ((ANNOTATION_IDENTIFIER)? ARGUMENT_NAME_IDENTIFIER ('?')?)*
(':' ((ANNOTATION_IDENTIFIER)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)? (':' ((ANNOTATION_IDENTIFIER)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)?
(('=' ((super_expression ';') | block)) | ';') (('=' ( /*prec 2*/ block | (super_expression ';'))) | ';')
; ;
typeclass_definition: (DEFINITION_INFO)? (ANNOTATION_INFO)* typeclass_definition: (DEFINITION_INFO)? (ANNOTATION_INFO)*
@ -102,7 +102,6 @@ expression: name_expression
| return | return
| lambda | lambda
| constructor | constructor
| block
| not_name_scoped_expression | not_name_scoped_expression
; ;
@ -110,15 +109,17 @@ scoped_expression: name_identifier
| not_name_scoped_expression | not_name_scoped_expression
; ;
not_name_scoped_expression: PLACEHOLDER not_name_scoped_expression: block
| array
| PLACEHOLDER
| name_definition | name_definition
| access | access
| tuple_access | tuple_access
| loop_control | loop_control
| array | reference
| suffix_expression
| literal | literal
| '(' super_expression ')' | '(' super_expression ')'
| reference
; ;
variant_type: ('|')? tuple_type ('|' tuple_type)+ ; variant_type: ('|')? tuple_type ('|' tuple_type)+ ;

View file

@ -64,7 +64,7 @@ module.exports = grammar({
optional(choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'))), optional(choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'))),
$.type, $.type,
)))), )))),
choice(seq('=', choice(seq($._super_expression, ';'), $.block)), ';'), choice(seq('=', choice(prec(2, $.block), seq($._super_expression, ';'))), ';'),
), ),
typeclass_definition: $ => seq( typeclass_definition: $ => seq(
@ -185,7 +185,6 @@ module.exports = grammar({
_expression: $ => choice( _expression: $ => choice(
$.operator_expression, $.operator_expression,
$.block,
$.return, $.return,
$.name_expression, $.name_expression,
$.constructor, $.constructor,
@ -199,6 +198,7 @@ module.exports = grammar({
), ),
_not_name_scoped_expression: $ => choice( _not_name_scoped_expression: $ => choice(
$.block,
$.array, $.array,
$.placeholder, $.placeholder,
$.name_definition, $.name_definition,