@@ -16,6 +16,7 @@ const PREC = {
16
16
XOR_OP : 140 ,
17
17
TERNARY_OP : 150 ,
18
18
CONCAT_OPS : 160 ,
19
+ RANGE_OP : 160 ,
19
20
ADD_OPS : 170 ,
20
21
MULT_OPS : 180 ,
21
22
POWER_OP : 190 ,
@@ -33,13 +34,13 @@ const COMP_OPS = ["==", "!=", "=~", "===", "!=="];
33
34
const REL_OPS = [ "<" , ">" , "<=" , ">=" ] ;
34
35
const ARROW_OPS = [ "|>" , "<<<" , ">>>" , "<<~" , "~>>" , "<~" , "~>" , "<~>" , "<|>" ] ;
35
36
const IN_OPS = [ "in" , "not in" ] ;
36
- const CONCAT_OPS = [ "++" , "--" , "+++" , "---" , ".." , " <>"] ;
37
+ const CONCAT_OPS = [ "++" , "--" , "+++" , "---" , "<>" ] ;
37
38
const ADD_OPS = [ "+" , "-" ] ;
38
39
const MULT_OPS = [ "*" , "/" ] ;
39
40
const UNARY_OPS = [ "+" , "-" , "!" , "^" , "~~~" , "not" ] ;
40
41
41
42
const ALL_OPS = [
42
- [ "->" , "when" , "::" , "|" , "=>" , "&" , "=" , "^^^" , "//" , "**" , "." , "@" ] ,
43
+ [ "->" , "when" , "::" , "|" , "=>" , "&" , "=" , "^^^" , "//" , ".." , " **", "." , "@" ] ,
43
44
IN_MATCH_OPS ,
44
45
OR_OPS ,
45
46
AND_OPS ,
@@ -213,6 +214,7 @@ module.exports = grammar({
213
214
$ . tuple ,
214
215
$ . bitstring ,
215
216
$ . map ,
217
+ $ . _nullary_operator ,
216
218
$ . unary_operator ,
217
219
$ . binary_operator ,
218
220
$ . dot ,
@@ -426,6 +428,11 @@ module.exports = grammar({
426
428
)
427
429
) ,
428
430
431
+ _nullary_operator : ( $ ) =>
432
+ // Nullary operators don't have any child nodes, so we reuse the
433
+ // operator_identifier node
434
+ alias ( prec ( PREC . RANGE_OP , ".." ) , $ . operator_identifier ) ,
435
+
429
436
unary_operator : ( $ ) =>
430
437
choice (
431
438
unaryOp ( $ , prec , PREC . CAPTURE_OP , "&" , $ . _capture_expression ) ,
@@ -480,6 +487,7 @@ module.exports = grammar({
480
487
binaryOp ( $ , prec . left , PREC . XOR_OP , "^^^" ) ,
481
488
binaryOp ( $ , prec . right , PREC . TERNARY_OP , "//" ) ,
482
489
binaryOp ( $ , prec . right , PREC . CONCAT_OPS , choice ( ...CONCAT_OPS ) ) ,
490
+ binaryOp ( $ , prec . right , PREC . RANGE_OP , ".." ) ,
483
491
binaryOp ( $ , prec . left , PREC . ADD_OPS , choice ( ...ADD_OPS ) ) ,
484
492
binaryOp ( $ , prec . left , PREC . MULT_OPS , choice ( ...MULT_OPS ) ) ,
485
493
binaryOp ( $ , prec . left , PREC . POWER_OP , "**" ) ,
@@ -524,6 +532,10 @@ module.exports = grammar({
524
532
alias ( $ . _not_in , "not in" ) ,
525
533
"^^" ,
526
534
...CONCAT_OPS ,
535
+ // The range operator has both a binary and a nullary version.
536
+ // The nullary version is already parsed as operator_identifier,
537
+ // so it covers this case
538
+ // ".."
527
539
...MULT_OPS ,
528
540
"**" ,
529
541
"->" ,
0 commit comments