plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
47e9b71
— Peter John
2023-05-03T20:01:24+05:30
Fix pipes
Generated files not shown: src/parser.c
- grammar.js +20 -4
- src/grammar.json +4 -25
- src/node-types.json +52 -508
- test/corpus/expressions.txt +128 -9
- test/corpus/statements.txt +5 -3
grammar.js
CHANGED
|
@@ -99,8 +99,8 @@ module.exports = grammar({
|
|
|
99
99
|
"=",
|
|
100
100
|
field("value", $._const_expression)
|
|
101
101
|
),
|
|
102
|
-
_const_expression: ($) => choice($._const_expression_unit, $.
|
|
102
|
+
_const_expression: ($) => choice($._const_expression_unit, $.const_binary_expression),
|
|
103
|
-
|
|
103
|
+
const_binary_expression: ($) => arithmeticExpression($._const_expression),
|
|
104
104
|
_const_expression_unit: ($) =>
|
|
105
105
|
choice(
|
|
106
106
|
$.string,
|
|
@@ -134,7 +134,23 @@ module.exports = grammar({
|
|
|
134
134
|
_statement_seq: ($) => repeat1($._statement),
|
|
135
135
|
_statement: ($) => choice($._expression, $.let),
|
|
136
136
|
_expression: ($) => choice($._expression_unit, $.binary_expression),
|
|
137
|
+
binary_expression: ($) => choice(
|
|
138
|
+
binaryExpr(prec.left, 1, "||", $._expression),
|
|
137
|
-
|
|
139
|
+
binaryExpr(prec.left, 2, "&&", $._expression),
|
|
140
|
+
binaryExpr(prec.left, 3, "==", $._expression),
|
|
141
|
+
binaryExpr(prec.left, 3, "!=", $._expression),
|
|
142
|
+
binaryExpr(prec.left, 4, "<", $._expression),
|
|
143
|
+
binaryExpr(prec.left, 4, "<=", $._expression),
|
|
144
|
+
binaryExpr(prec.left, 4, ">", $._expression),
|
|
145
|
+
binaryExpr(prec.left, 4, ">=", $._expression),
|
|
146
|
+
binaryExpr(prec.left, 5, "|>", $._expression),
|
|
147
|
+
binaryExpr(prec.left, 6, "+", $._expression),
|
|
148
|
+
binaryExpr(prec.left, 6, "-", $._expression),
|
|
149
|
+
binaryExpr(prec.left, 7, "*", $._expression),
|
|
150
|
+
binaryExpr(prec.left, 7, "/", $._expression),
|
|
151
|
+
binaryExpr(prec.left, 7, "%", $._expression),
|
|
152
|
+
binaryExpr(prec.left, 7, "<>", $._expression)
|
|
153
|
+
),
|
|
138
154
|
_expression_unit: ($) =>
|
|
139
155
|
choice(
|
|
140
156
|
$.string,
|
|
@@ -223,7 +239,7 @@ module.exports = grammar({
|
|
|
223
239
|
|
|
224
240
|
when_entry: $ => seq(
|
|
225
241
|
choice(
|
|
226
|
-
|
|
242
|
+
$._expression,
|
|
227
243
|
"_"
|
|
228
244
|
),
|
|
229
245
|
"->",
|
src/grammar.json
CHANGED
|
@@ -746,11 +746,11 @@
|
|
|
746
746
|
},
|
|
747
747
|
{
|
|
748
748
|
"type": "SYMBOL",
|
|
749
|
-
"name": "
|
|
749
|
+
"name": "const_binary_expression"
|
|
750
750
|
}
|
|
751
751
|
]
|
|
752
752
|
},
|
|
753
|
-
"
|
|
753
|
+
"const_binary_expression": {
|
|
754
754
|
"type": "CHOICE",
|
|
755
755
|
"members": [
|
|
756
756
|
{
|
|
@@ -2419,29 +2419,8 @@
|
|
|
2419
2419
|
"type": "CHOICE",
|
|
2420
2420
|
"members": [
|
|
2421
2421
|
{
|
|
2422
|
-
"type": "SEQ",
|
|
2423
|
-
"members": [
|
|
2424
|
-
{
|
|
2425
|
-
|
|
2422
|
+
"type": "SYMBOL",
|
|
2426
|
-
|
|
2423
|
+
"name": "_expression"
|
|
2427
|
-
},
|
|
2428
|
-
{
|
|
2429
|
-
"type": "REPEAT",
|
|
2430
|
-
"content": {
|
|
2431
|
-
"type": "SEQ",
|
|
2432
|
-
"members": [
|
|
2433
|
-
{
|
|
2434
|
-
"type": "STRING",
|
|
2435
|
-
"value": ","
|
|
2436
|
-
},
|
|
2437
|
-
{
|
|
2438
|
-
"type": "SYMBOL",
|
|
2439
|
-
"name": "_expression"
|
|
2440
|
-
}
|
|
2441
|
-
]
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
]
|
|
2445
2424
|
},
|
|
2446
2425
|
{
|
|
2447
2426
|
"type": "STRING",
|
src/node-types.json
CHANGED
|
@@ -340,299 +340,13 @@
|
|
|
340
340
|
"type": "const",
|
|
341
341
|
"named": true,
|
|
342
342
|
"fields": {
|
|
343
|
-
"left": {
|
|
344
|
-
"multiple": true,
|
|
345
|
-
"required": false,
|
|
346
|
-
"types": [
|
|
347
|
-
{
|
|
348
|
-
"type": "!=",
|
|
349
|
-
"named": false
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
"type": "%",
|
|
353
|
-
"named": false
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
"type": "&&",
|
|
357
|
-
"named": false
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
"type": "*",
|
|
361
|
-
"named": false
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
"type": "+",
|
|
365
|
-
"named": false
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
"type": "-",
|
|
369
|
-
"named": false
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
"type": "/",
|
|
373
|
-
"named": false
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
"type": "<",
|
|
377
|
-
"named": false
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
"type": "<=",
|
|
381
|
-
"named": false
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
"type": "<>",
|
|
385
|
-
"named": false
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
"type": "==",
|
|
389
|
-
"named": false
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
"type": ">",
|
|
393
|
-
"named": false
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
"type": ">=",
|
|
397
|
-
"named": false
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
"type": "const_function_call",
|
|
401
|
-
"named": true
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
"type": "const_record",
|
|
405
|
-
"named": true
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
"type": "float",
|
|
409
|
-
"named": true
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
"type": "integer",
|
|
413
|
-
"named": true
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
"type": "string",
|
|
417
|
-
"named": true
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
"type": "|>",
|
|
421
|
-
"named": false
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
"type": "||",
|
|
425
|
-
"named": false
|
|
426
|
-
}
|
|
427
|
-
]
|
|
428
|
-
},
|
|
429
|
-
"operator": {
|
|
430
|
-
"multiple": true,
|
|
431
|
-
"required": false,
|
|
432
|
-
"types": [
|
|
433
|
-
{
|
|
434
|
-
"type": "!=",
|
|
435
|
-
"named": false
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
"type": "%",
|
|
439
|
-
"named": false
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
"type": "&&",
|
|
443
|
-
"named": false
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
"type": "*",
|
|
447
|
-
"named": false
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
"type": "+",
|
|
451
|
-
"named": false
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
"type": "-",
|
|
455
|
-
"named": false
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
"type": "/",
|
|
459
|
-
"named": false
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
"type": "<",
|
|
463
|
-
"named": false
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
"type": "<=",
|
|
467
|
-
"named": false
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
"type": "<>",
|
|
471
|
-
"named": false
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
"type": "==",
|
|
475
|
-
"named": false
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
"type": ">",
|
|
479
|
-
"named": false
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
"type": ">=",
|
|
483
|
-
"named": false
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
"type": "|>",
|
|
487
|
-
"named": false
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
"type": "||",
|
|
491
|
-
"named": false
|
|
492
|
-
}
|
|
493
|
-
]
|
|
494
|
-
},
|
|
495
|
-
"right": {
|
|
496
|
-
"multiple": true,
|
|
497
|
-
"required": false,
|
|
498
|
-
"types": [
|
|
499
|
-
{
|
|
500
|
-
"type": "!=",
|
|
501
|
-
"named": false
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
"type": "%",
|
|
505
|
-
"named": false
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
"type": "&&",
|
|
509
|
-
"named": false
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
"type": "*",
|
|
513
|
-
"named": false
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
"type": "+",
|
|
517
|
-
"named": false
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
"type": "-",
|
|
521
|
-
"named": false
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
"type": "/",
|
|
525
|
-
"named": false
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
"type": "<",
|
|
529
|
-
"named": false
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
"type": "<=",
|
|
533
|
-
"named": false
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
"type": "<>",
|
|
537
|
-
"named": false
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
"type": "==",
|
|
541
|
-
"named": false
|
|
542
|
-
},
|
|
543
|
-
{
|
|
544
|
-
"type": ">",
|
|
545
|
-
"named": false
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
"type": ">=",
|
|
549
|
-
"named": false
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
"type": "const_function_call",
|
|
553
|
-
"named": true
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
"type": "const_record",
|
|
557
|
-
"named": true
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
"type": "float",
|
|
561
|
-
"named": true
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
"type": "integer",
|
|
565
|
-
"named": true
|
|
566
|
-
},
|
|
567
|
-
{
|
|
568
|
-
"type": "string",
|
|
569
|
-
"named": true
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
"type": "|>",
|
|
573
|
-
"named": false
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
"type": "||",
|
|
577
|
-
"named": false
|
|
578
|
-
}
|
|
579
|
-
]
|
|
580
|
-
},
|
|
581
343
|
"value": {
|
|
582
|
-
"multiple":
|
|
344
|
+
"multiple": false,
|
|
583
345
|
"required": true,
|
|
584
346
|
"types": [
|
|
585
347
|
{
|
|
586
|
-
"type": "
|
|
348
|
+
"type": "const_binary_expression",
|
|
587
|
-
"named":
|
|
349
|
+
"named": true
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
"type": "%",
|
|
591
|
-
"named": false
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
"type": "&&",
|
|
595
|
-
"named": false
|
|
596
|
-
},
|
|
597
|
-
{
|
|
598
|
-
"type": "*",
|
|
599
|
-
"named": false
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
"type": "+",
|
|
603
|
-
"named": false
|
|
604
|
-
},
|
|
605
|
-
{
|
|
606
|
-
"type": "-",
|
|
607
|
-
"named": false
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
"type": "/",
|
|
611
|
-
"named": false
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
"type": "<",
|
|
615
|
-
"named": false
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
"type": "<=",
|
|
619
|
-
"named": false
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
"type": "<>",
|
|
623
|
-
"named": false
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
"type": "==",
|
|
627
|
-
"named": false
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
"type": ">",
|
|
631
|
-
"named": false
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
"type": ">=",
|
|
635
|
-
"named": false
|
|
636
350
|
},
|
|
637
351
|
{
|
|
638
352
|
"type": "const_function_call",
|
|
@@ -653,14 +367,6 @@
|
|
|
653
367
|
{
|
|
654
368
|
"type": "string",
|
|
655
369
|
"named": true
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
"type": "|>",
|
|
659
|
-
"named": false
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
"type": "||",
|
|
663
|
-
"named": false
|
|
664
370
|
}
|
|
665
371
|
]
|
|
666
372
|
}
|
|
@@ -690,61 +396,13 @@
|
|
|
690
396
|
}
|
|
691
397
|
]
|
|
692
398
|
},
|
|
693
|
-
"
|
|
399
|
+
"value": {
|
|
694
|
-
"multiple":
|
|
400
|
+
"multiple": false,
|
|
695
|
-
"required":
|
|
401
|
+
"required": true,
|
|
696
402
|
"types": [
|
|
697
403
|
{
|
|
698
|
-
"type": "
|
|
404
|
+
"type": "const_binary_expression",
|
|
699
|
-
"named":
|
|
405
|
+
"named": true
|
|
700
|
-
},
|
|
701
|
-
{
|
|
702
|
-
"type": "%",
|
|
703
|
-
"named": false
|
|
704
|
-
},
|
|
705
|
-
{
|
|
706
|
-
"type": "&&",
|
|
707
|
-
"named": false
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
"type": "*",
|
|
711
|
-
"named": false
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
"type": "+",
|
|
715
|
-
"named": false
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
"type": "-",
|
|
719
|
-
"named": false
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
"type": "/",
|
|
723
|
-
"named": false
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
"type": "<",
|
|
727
|
-
"named": false
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
"type": "<=",
|
|
731
|
-
"named": false
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
"type": "<>",
|
|
735
|
-
"named": false
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
"type": "==",
|
|
739
|
-
"named": false
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
"type": ">",
|
|
743
|
-
"named": false
|
|
744
|
-
},
|
|
745
|
-
{
|
|
746
|
-
"type": ">=",
|
|
747
|
-
"named": false
|
|
748
406
|
},
|
|
749
407
|
{
|
|
750
408
|
"type": "const_function_call",
|
|
@@ -765,86 +423,63 @@
|
|
|
765
423
|
{
|
|
766
424
|
"type": "string",
|
|
767
425
|
"named": true
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
"type": "|>",
|
|
771
|
-
"named": false
|
|
772
|
-
},
|
|
773
|
-
{
|
|
774
|
-
"type": "||",
|
|
775
|
-
"named": false
|
|
776
426
|
}
|
|
777
427
|
]
|
|
428
|
+
}
|
|
429
|
+
}
|
|
778
|
-
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"type": "const_arguments",
|
|
433
|
+
"named": true,
|
|
434
|
+
"fields": {},
|
|
779
|
-
|
|
435
|
+
"children": {
|
|
780
|
-
|
|
436
|
+
"multiple": true,
|
|
781
|
-
|
|
437
|
+
"required": false,
|
|
438
|
+
"types": [
|
|
439
|
+
{
|
|
440
|
+
"type": "const_argument",
|
|
441
|
+
"named": true
|
|
442
|
+
}
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"type": "const_binary_expression",
|
|
448
|
+
"named": true,
|
|
449
|
+
"fields": {
|
|
450
|
+
"left": {
|
|
451
|
+
"multiple": false,
|
|
452
|
+
"required": true,
|
|
782
453
|
"types": [
|
|
783
454
|
{
|
|
784
|
-
"type": "
|
|
455
|
+
"type": "const_binary_expression",
|
|
785
|
-
"named":
|
|
456
|
+
"named": true
|
|
786
|
-
},
|
|
787
|
-
{
|
|
788
|
-
"type": "%",
|
|
789
|
-
"named": false
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
"type": "&&",
|
|
793
|
-
"named": false
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
"type": "*",
|
|
797
|
-
"named": false
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
"type": "+",
|
|
801
|
-
"named": false
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
"type": "-",
|
|
805
|
-
"named": false
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
"type": "/",
|
|
809
|
-
"named": false
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
"type": "<",
|
|
813
|
-
"named": false
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
"type": "<=",
|
|
817
|
-
"named": false
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
"type": "<>",
|
|
821
|
-
"named": false
|
|
822
457
|
},
|
|
823
458
|
{
|
|
824
|
-
"type": "
|
|
459
|
+
"type": "const_function_call",
|
|
825
|
-
"named":
|
|
460
|
+
"named": true
|
|
826
461
|
},
|
|
827
462
|
{
|
|
828
|
-
"type": "
|
|
463
|
+
"type": "const_record",
|
|
829
|
-
"named":
|
|
464
|
+
"named": true
|
|
830
465
|
},
|
|
831
466
|
{
|
|
832
|
-
"type": "
|
|
467
|
+
"type": "float",
|
|
833
|
-
"named":
|
|
468
|
+
"named": true
|
|
834
469
|
},
|
|
835
470
|
{
|
|
836
|
-
"type": "
|
|
471
|
+
"type": "integer",
|
|
837
|
-
"named":
|
|
472
|
+
"named": true
|
|
838
473
|
},
|
|
839
474
|
{
|
|
840
|
-
"type": "
|
|
475
|
+
"type": "string",
|
|
841
|
-
"named":
|
|
476
|
+
"named": true
|
|
842
477
|
}
|
|
843
478
|
]
|
|
844
479
|
},
|
|
845
|
-
"
|
|
480
|
+
"operator": {
|
|
846
|
-
"multiple":
|
|
481
|
+
"multiple": false,
|
|
847
|
-
"required":
|
|
482
|
+
"required": true,
|
|
848
483
|
"types": [
|
|
849
484
|
{
|
|
850
485
|
"type": "!=",
|
|
@@ -898,26 +533,6 @@
|
|
|
898
533
|
"type": ">=",
|
|
899
534
|
"named": false
|
|
900
535
|
},
|
|
901
|
-
{
|
|
902
|
-
"type": "const_function_call",
|
|
903
|
-
"named": true
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
"type": "const_record",
|
|
907
|
-
"named": true
|
|
908
|
-
},
|
|
909
|
-
{
|
|
910
|
-
"type": "float",
|
|
911
|
-
"named": true
|
|
912
|
-
},
|
|
913
|
-
{
|
|
914
|
-
"type": "integer",
|
|
915
|
-
"named": true
|
|
916
|
-
},
|
|
917
|
-
{
|
|
918
|
-
"type": "string",
|
|
919
|
-
"named": true
|
|
920
|
-
},
|
|
921
536
|
{
|
|
922
537
|
"type": "|>",
|
|
923
538
|
"named": false
|
|
@@ -928,61 +543,13 @@
|
|
|
928
543
|
}
|
|
929
544
|
]
|
|
930
545
|
},
|
|
931
|
-
"
|
|
546
|
+
"right": {
|
|
932
|
-
"multiple":
|
|
547
|
+
"multiple": false,
|
|
933
548
|
"required": true,
|
|
934
549
|
"types": [
|
|
935
550
|
{
|
|
936
|
-
"type": "
|
|
551
|
+
"type": "const_binary_expression",
|
|
937
|
-
"named":
|
|
552
|
+
"named": true
|
|
938
|
-
},
|
|
939
|
-
{
|
|
940
|
-
"type": "%",
|
|
941
|
-
"named": false
|
|
942
|
-
},
|
|
943
|
-
{
|
|
944
|
-
"type": "&&",
|
|
945
|
-
"named": false
|
|
946
|
-
},
|
|
947
|
-
{
|
|
948
|
-
"type": "*",
|
|
949
|
-
"named": false
|
|
950
|
-
},
|
|
951
|
-
{
|
|
952
|
-
"type": "+",
|
|
953
|
-
"named": false
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
"type": "-",
|
|
957
|
-
"named": false
|
|
958
|
-
},
|
|
959
|
-
{
|
|
960
|
-
"type": "/",
|
|
961
|
-
"named": false
|
|
962
|
-
},
|
|
963
|
-
{
|
|
964
|
-
"type": "<",
|
|
965
|
-
"named": false
|
|
966
|
-
},
|
|
967
|
-
{
|
|
968
|
-
"type": "<=",
|
|
969
|
-
"named": false
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
"type": "<>",
|
|
973
|
-
"named": false
|
|
974
|
-
},
|
|
975
|
-
{
|
|
976
|
-
"type": "==",
|
|
977
|
-
"named": false
|
|
978
|
-
},
|
|
979
|
-
{
|
|
980
|
-
"type": ">",
|
|
981
|
-
"named": false
|
|
982
|
-
},
|
|
983
|
-
{
|
|
984
|
-
"type": ">=",
|
|
985
|
-
"named": false
|
|
986
553
|
},
|
|
987
554
|
{
|
|
988
555
|
"type": "const_function_call",
|
|
@@ -1003,34 +570,11 @@
|
|
|
1003
570
|
{
|
|
1004
571
|
"type": "string",
|
|
1005
572
|
"named": true
|
|
1006
|
-
},
|
|
1007
|
-
{
|
|
1008
|
-
"type": "|>",
|
|
1009
|
-
"named": false
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
"type": "||",
|
|
1013
|
-
"named": false
|
|
1014
573
|
}
|
|
1015
574
|
]
|
|
1016
575
|
}
|
|
1017
576
|
}
|
|
1018
577
|
},
|
|
1019
|
-
{
|
|
1020
|
-
"type": "const_arguments",
|
|
1021
|
-
"named": true,
|
|
1022
|
-
"fields": {},
|
|
1023
|
-
"children": {
|
|
1024
|
-
"multiple": true,
|
|
1025
|
-
"required": false,
|
|
1026
|
-
"types": [
|
|
1027
|
-
{
|
|
1028
|
-
"type": "const_argument",
|
|
1029
|
-
"named": true
|
|
1030
|
-
}
|
|
1031
|
-
]
|
|
1032
|
-
}
|
|
1033
|
-
},
|
|
1034
578
|
{
|
|
1035
579
|
"type": "const_function_call",
|
|
1036
580
|
"named": true,
|
test/corpus/expressions.txt
CHANGED
|
@@ -4,18 +4,137 @@ Pipes
|
|
|
4
4
|
|
|
5
5
|
module palm
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
fn add() {
|
|
8
|
+
"hello"
|
|
8
|
-
|> iodata.new
|
|
9
|
+
|> iodata.new
|
|
9
|
-
|> iodata.reverse
|
|
10
|
+
|> iodata.reverse
|
|
11
|
+
}
|
|
10
12
|
|
|
11
13
|
--------------------------------------------------------------------------------
|
|
12
14
|
|
|
13
15
|
(source_file
|
|
14
16
|
(module
|
|
15
17
|
(module_name))
|
|
18
|
+
(function
|
|
19
|
+
(identifier)
|
|
20
|
+
(binary_expression
|
|
21
|
+
(binary_expression
|
|
16
|
-
|
|
22
|
+
(string
|
|
17
|
-
|
|
23
|
+
(quoted_content))
|
|
24
|
+
(field_access
|
|
25
|
+
(identifier)
|
|
26
|
+
(label)))
|
|
27
|
+
(field_access
|
|
28
|
+
(identifier)
|
|
29
|
+
(label)))))
|
|
30
|
+
|
|
31
|
+
================================================================================
|
|
32
|
+
When
|
|
33
|
+
================================================================================
|
|
34
|
+
|
|
35
|
+
module palm
|
|
36
|
+
|
|
37
|
+
pub fn main() {
|
|
38
|
+
when a + 5 + 8 {
|
|
39
|
+
11 -> 123
|
|
40
|
+
_ -> 0
|
|
41
|
+
}
|
|
42
|
+
when b {
|
|
18
|
-
|
|
43
|
+
1 -> "Hello"
|
|
19
|
-
|
|
44
|
+
2 -> "Game"
|
|
20
|
-
(UNEXPECTED 'o')
|
|
21
|
-
|
|
45
|
+
3 || 4 -> "Threes"
|
|
46
|
+
{ 5 * 1 } && { 5 + 1 } -> "Threes"
|
|
47
|
+
_ -> "World"
|
|
48
|
+
}
|
|
49
|
+
when {
|
|
50
|
+
1 -> 1
|
|
51
|
+
_ -> 0
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
--------------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
(source_file
|
|
58
|
+
(module
|
|
59
|
+
(module_name))
|
|
60
|
+
(function
|
|
61
|
+
(visibility_modifier)
|
|
62
|
+
(identifier)
|
|
63
|
+
(when
|
|
64
|
+
(binary_expression
|
|
65
|
+
(binary_expression
|
|
66
|
+
(identifier)
|
|
67
|
+
(integer))
|
|
68
|
+
(integer))
|
|
69
|
+
(when_entry
|
|
70
|
+
(integer)
|
|
71
|
+
(integer))
|
|
72
|
+
(when_entry
|
|
73
|
+
(integer)))
|
|
74
|
+
(when
|
|
75
|
+
(identifier)
|
|
76
|
+
(when_entry
|
|
77
|
+
(integer)
|
|
78
|
+
(string
|
|
79
|
+
(quoted_content)))
|
|
80
|
+
(when_entry
|
|
81
|
+
(integer)
|
|
82
|
+
(string
|
|
83
|
+
(quoted_content)))
|
|
84
|
+
(when_entry
|
|
85
|
+
(binary_expression
|
|
86
|
+
(integer)
|
|
87
|
+
(integer))
|
|
88
|
+
(string
|
|
89
|
+
(quoted_content)))
|
|
90
|
+
(when_entry
|
|
91
|
+
(binary_expression
|
|
92
|
+
(expression_group
|
|
93
|
+
(binary_expression
|
|
94
|
+
(integer)
|
|
95
|
+
(integer)))
|
|
96
|
+
(expression_group
|
|
97
|
+
(binary_expression
|
|
98
|
+
(integer)
|
|
99
|
+
(integer))))
|
|
100
|
+
(string
|
|
101
|
+
(quoted_content)))
|
|
102
|
+
(when_entry
|
|
103
|
+
(string
|
|
104
|
+
(quoted_content))))
|
|
105
|
+
(when
|
|
106
|
+
(when_entry
|
|
107
|
+
(integer)
|
|
108
|
+
(integer))
|
|
109
|
+
(when_entry
|
|
110
|
+
(integer)))))
|
|
111
|
+
|
|
112
|
+
================================================================================
|
|
113
|
+
If
|
|
114
|
+
================================================================================
|
|
115
|
+
|
|
116
|
+
module palm
|
|
117
|
+
|
|
118
|
+
pub fn main() {
|
|
119
|
+
if a + 5 > 10 {
|
|
120
|
+
5
|
|
121
|
+
}
|
|
122
|
+
1
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
--------------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
(source_file
|
|
128
|
+
(module
|
|
129
|
+
(module_name))
|
|
130
|
+
(function
|
|
131
|
+
(visibility_modifier)
|
|
132
|
+
(identifier)
|
|
133
|
+
(if
|
|
134
|
+
(binary_expression
|
|
135
|
+
(binary_expression
|
|
136
|
+
(identifier)
|
|
137
|
+
(integer))
|
|
138
|
+
(integer))
|
|
139
|
+
(integer))
|
|
140
|
+
(integer)))
|
test/corpus/statements.txt
CHANGED
|
@@ -143,9 +143,11 @@ const a = option.Some("Hello, World!")
|
|
|
143
143
|
(quoted_content))))))
|
|
144
144
|
(const
|
|
145
145
|
(identifier)
|
|
146
|
+
(const_binary_expression
|
|
147
|
+
(const_binary_expression
|
|
146
|
-
|
|
148
|
+
(integer)
|
|
147
|
-
(integer)
|
|
148
|
-
|
|
149
|
+
(integer))
|
|
150
|
+
(integer)))
|
|
149
151
|
(const
|
|
150
152
|
(identifier)
|
|
151
153
|
(integer))
|