@@ -55,8 +55,8 @@ module.exports = grammar({
55
55
$ . _pattern ,
56
56
$ . _semicolon ,
57
57
$ . _definition ,
58
- $ . _type_identifier ,
59
58
$ . _param_type ,
59
+ $ . _identifier ,
60
60
$ . literal ,
61
61
] ,
62
62
@@ -278,7 +278,7 @@ module.exports = grammar({
278
278
) ,
279
279
280
280
_type_parameter : $ => seq (
281
- field ( 'name' , choice ( $ . wildcard , $ . identifier ) ) ,
281
+ field ( 'name' , choice ( $ . wildcard , $ . _identifier ) ) ,
282
282
field ( 'type_parameters' , optional ( $ . type_parameters ) ) ,
283
283
field ( 'bound' , optional ( $ . upper_bound ) ) ,
284
284
field ( 'bound' , optional ( $ . lower_bound ) ) ,
@@ -445,7 +445,7 @@ module.exports = grammar({
445
445
446
446
// Created for memory-usage optimization during codegen.
447
447
_function_constructor : $ => prec . left ( PREC . control , seq (
448
- field ( 'name' , choice ( $ . identifier , $ . operator_identifier ) ) ,
448
+ field ( 'name' , $ . _identifier ) ,
449
449
field ( 'type_parameters' , optional ( $ . type_parameters ) ) ,
450
450
field ( 'parameters' , repeat ( $ . parameters ) ) ,
451
451
optional ( seq ( ':' , field ( 'return_type' , $ . _type ) ) ) ,
@@ -556,6 +556,7 @@ module.exports = grammar({
556
556
optional ( choice ( 'val' , 'var' ) ) ,
557
557
field ( 'name' , $ . identifier ) ,
558
558
optional ( seq ( ':' , field ( 'type' , $ . _type ) ) ) ,
559
+ optional ( '*' ) ,
559
560
optional ( seq ( '=' , field ( 'default_value' , $ . expression ) ) )
560
561
) ,
561
562
@@ -634,7 +635,7 @@ module.exports = grammar({
634
635
635
636
infix_type : $ => prec . left ( PREC . infix , seq (
636
637
field ( 'left' , choice ( $ . compound_type , $ . infix_type , $ . _annotated_type ) ) ,
637
- field ( 'operator' , choice ( $ . identifier , $ . operator_identifier ) ) ,
638
+ field ( 'operator' , $ . _identifier ) ,
638
639
field ( 'right' , choice ( $ . compound_type , $ . infix_type , $ . _annotated_type ) )
639
640
) ) ,
640
641
@@ -698,13 +699,13 @@ module.exports = grammar({
698
699
'*' ,
699
700
) ,
700
701
701
- _type_identifier : $ => alias ( $ . identifier , $ . type_identifier ) ,
702
+ _type_identifier : $ => alias ( $ . _identifier , $ . type_identifier ) ,
702
703
703
704
// ---------------------------------------------------------------
704
705
// Patterns
705
706
706
707
_pattern : $ => choice (
707
- $ . identifier ,
708
+ $ . _identifier ,
708
709
$ . stable_identifier ,
709
710
$ . capture_pattern ,
710
711
$ . tuple_pattern ,
@@ -726,7 +727,7 @@ module.exports = grammar({
726
727
727
728
infix_pattern : $ => prec . left ( PREC . infix , seq (
728
729
field ( 'left' , $ . _pattern ) ,
729
- field ( 'operator' , choice ( $ . identifier , $ . operator_identifier ) ) ,
730
+ field ( 'operator' , $ . _identifier ) ,
730
731
field ( 'right' , $ . _pattern ) ,
731
732
) ) ,
732
733
@@ -938,7 +939,7 @@ module.exports = grammar({
938
939
$ . prefix_expression ,
939
940
$ . _simple_expression ,
940
941
) ) ,
941
- field ( 'operator' , choice ( $ . identifier , $ . operator_identifier ) ) ,
942
+ field ( 'operator' , $ . _identifier ) ,
942
943
field ( 'right' , choice (
943
944
$ . prefix_expression ,
944
945
$ . _simple_expression ,
@@ -954,7 +955,7 @@ module.exports = grammar({
954
955
$ . prefix_expression ,
955
956
$ . _simple_expression ,
956
957
) ,
957
- choice ( $ . identifier , $ . operator_identifier ) ,
958
+ $ . _identifier ,
958
959
) ) ,
959
960
960
961
/**
@@ -1030,9 +1031,11 @@ module.exports = grammar({
1030
1031
1031
1032
symbol_literal : $ => '__no_longer_used' ,
1032
1033
1033
- // TODO: Include operators.
1034
1034
_plainid : $ => / [ a - z A - Z _ \\ $ ] [ \w \\ $ ] * / ,
1035
1035
_backquoted_id : $ => / ` [ ^ \n ` ] + ` / ,
1036
+
1037
+ _identifier : $ => choice ( $ . identifier , $ . operator_identifier ) ,
1038
+
1036
1039
identifier : $ => choice (
1037
1040
$ . _plainid ,
1038
1041
$ . _backquoted_id ,
@@ -1045,7 +1048,7 @@ module.exports = grammar({
1045
1048
1046
1049
wildcard : $ => '_' ,
1047
1050
1048
- operator_identifier : $ => / [ ^ \s \w \( \) \[ \] \{ \} ' " ` \. ; , ] + / ,
1051
+ operator_identifier : $ => / [ ! # % & * + - \/ : < = > ? @ ' ^ \| ‘ ~ ] + / ,
1049
1052
1050
1053
_non_null_literal : $ =>
1051
1054
choice (
0 commit comments