yarp 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/CONTRIBUTING.md +7 -0
  4. data/Makefile +5 -1
  5. data/config.yml +308 -166
  6. data/docs/configuration.md +0 -1
  7. data/docs/encoding.md +5 -5
  8. data/docs/mapping.md +91 -91
  9. data/docs/serialization.md +25 -22
  10. data/ext/yarp/api_node.c +1210 -483
  11. data/ext/yarp/extension.c +22 -8
  12. data/ext/yarp/extension.h +2 -2
  13. data/include/yarp/ast.h +692 -183
  14. data/include/yarp/defines.h +2 -1
  15. data/include/yarp/diagnostic.h +200 -3
  16. data/include/yarp/enc/yp_encoding.h +10 -10
  17. data/include/yarp/node.h +0 -4
  18. data/include/yarp/parser.h +19 -19
  19. data/include/yarp/regexp.h +1 -1
  20. data/include/yarp/unescape.h +4 -4
  21. data/include/yarp/util/yp_buffer.h +3 -0
  22. data/include/yarp/util/yp_char.h +16 -16
  23. data/include/yarp/util/yp_constant_pool.h +12 -5
  24. data/include/yarp/util/yp_newline_list.h +5 -5
  25. data/include/yarp/util/yp_string.h +4 -4
  26. data/include/yarp/util/yp_string_list.h +0 -3
  27. data/include/yarp/util/yp_strpbrk.h +1 -1
  28. data/include/yarp/version.h +2 -2
  29. data/include/yarp.h +5 -4
  30. data/lib/yarp/desugar_visitor.rb +59 -122
  31. data/lib/yarp/mutation_visitor.rb +22 -12
  32. data/lib/yarp/node.rb +3081 -501
  33. data/lib/yarp/parse_result/comments.rb +172 -0
  34. data/lib/yarp/parse_result/newlines.rb +60 -0
  35. data/lib/yarp/pattern.rb +239 -0
  36. data/lib/yarp/serialize.rb +152 -129
  37. data/lib/yarp.rb +109 -49
  38. data/src/diagnostic.c +254 -2
  39. data/src/enc/yp_big5.c +15 -42
  40. data/src/enc/yp_euc_jp.c +16 -43
  41. data/src/enc/yp_gbk.c +19 -46
  42. data/src/enc/yp_shift_jis.c +16 -43
  43. data/src/enc/yp_tables.c +36 -38
  44. data/src/enc/yp_unicode.c +20 -25
  45. data/src/enc/yp_windows_31j.c +16 -43
  46. data/src/node.c +1871 -1466
  47. data/src/prettyprint.c +463 -230
  48. data/src/regexp.c +21 -21
  49. data/src/serialize.c +352 -184
  50. data/src/unescape.c +152 -122
  51. data/src/util/yp_buffer.c +7 -2
  52. data/src/util/yp_char.c +35 -40
  53. data/src/util/yp_constant_pool.c +45 -12
  54. data/src/util/yp_memchr.c +1 -1
  55. data/src/util/yp_newline_list.c +10 -5
  56. data/src/util/yp_string.c +22 -20
  57. data/src/util/yp_string_list.c +4 -7
  58. data/src/util/yp_strncasecmp.c +3 -6
  59. data/src/util/yp_strpbrk.c +8 -8
  60. data/src/yarp.c +1288 -1021
  61. data/yarp.gemspec +4 -1
  62. metadata +6 -3
data/config.yml CHANGED
@@ -361,7 +361,7 @@ flags:
361
361
  comment: "o - only interpolates values into the regular expression once"
362
362
  nodes:
363
363
  - name: AliasNode
364
- child_nodes:
364
+ fields:
365
365
  - name: new_name
366
366
  type: node
367
367
  - name: old_name
@@ -374,7 +374,7 @@ nodes:
374
374
  alias foo bar
375
375
  ^^^^^^^^^^^^^
376
376
  - name: AlternationPatternNode
377
- child_nodes:
377
+ fields:
378
378
  - name: left
379
379
  type: node
380
380
  - name: right
@@ -387,7 +387,7 @@ nodes:
387
387
  foo => bar | baz
388
388
  ^^^^^^^^^
389
389
  - name: AndNode
390
- child_nodes:
390
+ fields:
391
391
  - name: left
392
392
  type: node
393
393
  - name: right
@@ -400,7 +400,7 @@ nodes:
400
400
  left and right
401
401
  ^^^^^^^^^^^^^^
402
402
  - name: ArgumentsNode
403
- child_nodes:
403
+ fields:
404
404
  - name: arguments
405
405
  type: node[]
406
406
  comment: |
@@ -409,7 +409,7 @@ nodes:
409
409
  return foo, bar, baz
410
410
  ^^^^^^^^^^^^^
411
411
  - name: ArrayNode
412
- child_nodes:
412
+ fields:
413
413
  - name: elements
414
414
  type: node[]
415
415
  - name: opening_loc
@@ -423,7 +423,7 @@ nodes:
423
423
  [1, 2, 3]
424
424
  ^^^^^^^^^
425
425
  - name: ArrayPatternNode
426
- child_nodes:
426
+ fields:
427
427
  - name: constant
428
428
  type: node?
429
429
  - name: requireds
@@ -454,7 +454,7 @@ nodes:
454
454
  foo in Bar[1, 2, 3]
455
455
  ^^^^^^^^^^^^^^^^^^^
456
456
  - name: AssocNode
457
- child_nodes:
457
+ fields:
458
458
  - name: key
459
459
  type: node
460
460
  - name: value
@@ -467,7 +467,7 @@ nodes:
467
467
  { a => b }
468
468
  ^^^^^^
469
469
  - name: AssocSplatNode
470
- child_nodes:
470
+ fields:
471
471
  - name: value
472
472
  type: node?
473
473
  - name: operator_loc
@@ -484,7 +484,7 @@ nodes:
484
484
  $'
485
485
  ^^
486
486
  - name: BeginNode
487
- child_nodes:
487
+ fields:
488
488
  - name: begin_keyword_loc
489
489
  type: location?
490
490
  - name: statements
@@ -510,7 +510,7 @@ nodes:
510
510
  end
511
511
  ^^^^^
512
512
  - name: BlockArgumentNode
513
- child_nodes:
513
+ fields:
514
514
  - name: expression
515
515
  type: node?
516
516
  - name: operator_loc
@@ -520,8 +520,17 @@ nodes:
520
520
 
521
521
  bar(&args)
522
522
  ^^^^^^^^^^
523
+ - name: BlockLocalVariableNode
524
+ fields:
525
+ - name: name
526
+ type: constant
527
+ comment: |
528
+ Represents a block local variable.
529
+
530
+ a { |; b| }
531
+ ^
523
532
  - name: BlockNode
524
- child_nodes:
533
+ fields:
525
534
  - name: locals
526
535
  type: constant[]
527
536
  - name: parameters
@@ -539,7 +548,9 @@ nodes:
539
548
  [1, 2, 3].each { |i| puts x }
540
549
  ^^^^^^^^^^^^^^
541
550
  - name: BlockParameterNode
542
- child_nodes:
551
+ fields:
552
+ - name: name
553
+ type: constant?
543
554
  - name: name_loc
544
555
  type: location?
545
556
  - name: operator_loc
@@ -551,12 +562,12 @@ nodes:
551
562
  ^^
552
563
  end
553
564
  - name: BlockParametersNode
554
- child_nodes:
565
+ fields:
555
566
  - name: parameters
556
567
  type: node?
557
568
  kind: ParametersNode
558
569
  - name: locals
559
- type: location[]
570
+ type: node[]
560
571
  - name: opening_loc
561
572
  type: location?
562
573
  - name: closing_loc
@@ -571,7 +582,7 @@ nodes:
571
582
  ^^^^^^^^^^^^^^^^^
572
583
  end
573
584
  - name: BreakNode
574
- child_nodes:
585
+ fields:
575
586
  - name: arguments
576
587
  type: node?
577
588
  kind: ArgumentsNode
@@ -582,11 +593,42 @@ nodes:
582
593
 
583
594
  break foo
584
595
  ^^^^^^^^^
585
- - name: CallNode
586
- child_nodes:
596
+ - name: CallAndWriteNode
597
+ fields:
587
598
  - name: receiver
588
599
  type: node?
600
+ - name: call_operator_loc
601
+ type: location?
602
+ - name: message_loc
603
+ type: location?
604
+ - name: opening_loc
605
+ type: location?
606
+ - name: arguments
607
+ type: node?
608
+ kind: ArgumentsNode
609
+ - name: closing_loc
610
+ type: location?
611
+ - name: flags
612
+ type: flags
613
+ kind: CallNodeFlags
614
+ - name: read_name
615
+ type: string
616
+ - name: write_name
617
+ type: string
589
618
  - name: operator_loc
619
+ type: location
620
+ - name: value
621
+ type: node
622
+ comment: |
623
+ Represents the use of the `&&=` operator on a call.
624
+
625
+ foo.bar &&= value
626
+ ^^^^^^^^^^^^^^^^^
627
+ - name: CallNode
628
+ fields:
629
+ - name: receiver
630
+ type: node?
631
+ - name: call_operator_loc
590
632
  type: location?
591
633
  - name: message_loc
592
634
  type: location?
@@ -625,52 +667,72 @@ nodes:
625
667
 
626
668
  foo&.bar
627
669
  ^^^^^^^^
628
- - name: CallOperatorAndWriteNode
629
- child_nodes:
630
- - name: target
631
- type: node
632
- kind: CallNode
670
+ - name: CallOperatorWriteNode
671
+ fields:
672
+ - name: receiver
673
+ type: node?
674
+ - name: call_operator_loc
675
+ type: location?
676
+ - name: message_loc
677
+ type: location?
678
+ - name: opening_loc
679
+ type: location?
680
+ - name: arguments
681
+ type: node?
682
+ kind: ArgumentsNode
683
+ - name: closing_loc
684
+ type: location?
685
+ - name: flags
686
+ type: flags
687
+ kind: CallNodeFlags
688
+ - name: read_name
689
+ type: string
690
+ - name: write_name
691
+ type: string
692
+ - name: operator
693
+ type: constant
633
694
  - name: operator_loc
634
695
  type: location
635
696
  - name: value
636
697
  type: node
637
698
  comment: |
638
- Represents the use of the `&&=` operator on a call.
699
+ Represents the use of an assignment operator on a call.
639
700
 
640
- foo.bar &&= value
641
- ^^^^^^^^^^^^^^^^^
642
- - name: CallOperatorOrWriteNode
643
- child_nodes:
644
- - name: target
645
- type: node
646
- kind: CallNode
647
- - name: value
648
- type: node
701
+ foo.bar += baz
702
+ ^^^^^^^^^^^^^^
703
+ - name: CallOrWriteNode
704
+ fields:
705
+ - name: receiver
706
+ type: node?
707
+ - name: call_operator_loc
708
+ type: location?
709
+ - name: message_loc
710
+ type: location?
711
+ - name: opening_loc
712
+ type: location?
713
+ - name: arguments
714
+ type: node?
715
+ kind: ArgumentsNode
716
+ - name: closing_loc
717
+ type: location?
718
+ - name: flags
719
+ type: flags
720
+ kind: CallNodeFlags
721
+ - name: read_name
722
+ type: string
723
+ - name: write_name
724
+ type: string
649
725
  - name: operator_loc
650
726
  type: location
727
+ - name: value
728
+ type: node
651
729
  comment: |
652
730
  Represents the use of the `||=` operator on a call.
653
731
 
654
732
  foo.bar ||= value
655
733
  ^^^^^^^^^^^^^^^^^
656
- - name: CallOperatorWriteNode
657
- child_nodes:
658
- - name: target
659
- type: node
660
- kind: CallNode
661
- - name: operator_loc
662
- type: location
663
- - name: value
664
- type: node
665
- - name: operator_id
666
- type: constant
667
- comment: |
668
- Represents the use of an assignment operator on a call.
669
-
670
- foo.bar += baz
671
- ^^^^^^^^^^^^^^
672
734
  - name: CapturePatternNode
673
- child_nodes:
735
+ fields:
674
736
  - name: value
675
737
  type: node
676
738
  - name: target
@@ -683,7 +745,7 @@ nodes:
683
745
  foo => [bar => baz]
684
746
  ^^^^^^^^^^^^
685
747
  - name: CaseNode
686
- child_nodes:
748
+ fields:
687
749
  - name: predicate
688
750
  type: node?
689
751
  - name: conditions
@@ -703,7 +765,7 @@ nodes:
703
765
  when false
704
766
  end
705
767
  - name: ClassNode
706
- child_nodes:
768
+ fields:
707
769
  - name: locals
708
770
  type: constant[]
709
771
  - name: class_keyword_loc
@@ -719,14 +781,16 @@ nodes:
719
781
  - name: end_keyword_loc
720
782
  type: location
721
783
  - name: name
722
- type: string
784
+ type: constant
723
785
  comment: |
724
786
  Represents a class declaration involving the `class` keyword.
725
787
 
726
788
  class Foo end
727
789
  ^^^^^^^^^^^^^
728
790
  - name: ClassVariableAndWriteNode
729
- child_nodes:
791
+ fields:
792
+ - name: name
793
+ type: constant
730
794
  - name: name_loc
731
795
  type: location
732
796
  - name: operator_loc
@@ -739,7 +803,9 @@ nodes:
739
803
  @@target &&= value
740
804
  ^^^^^^^^^^^^^^^^
741
805
  - name: ClassVariableOperatorWriteNode
742
- child_nodes:
806
+ fields:
807
+ - name: name
808
+ type: constant
743
809
  - name: name_loc
744
810
  type: location
745
811
  - name: operator_loc
@@ -754,7 +820,9 @@ nodes:
754
820
  @@target += value
755
821
  ^^^^^^^^^^^^^^^^^
756
822
  - name: ClassVariableOrWriteNode
757
- child_nodes:
823
+ fields:
824
+ - name: name
825
+ type: constant
758
826
  - name: name_loc
759
827
  type: location
760
828
  - name: operator_loc
@@ -767,23 +835,31 @@ nodes:
767
835
  @@target ||= value
768
836
  ^^^^^^^^^^^^^^^^^^
769
837
  - name: ClassVariableReadNode
838
+ fields:
839
+ - name: name
840
+ type: constant
770
841
  comment: |
771
842
  Represents referencing a class variable.
772
843
 
773
844
  @@foo
774
845
  ^^^^^
775
846
  - name: ClassVariableTargetNode
847
+ fields:
848
+ - name: name
849
+ type: constant
776
850
  comment: |
777
851
  Represents writing to a class variable in a context that doesn't have an explicit value.
778
852
 
779
853
  @@foo, @@bar = baz
780
854
  ^^^^^ ^^^^^
781
855
  - name: ClassVariableWriteNode
782
- child_nodes:
856
+ fields:
857
+ - name: name
858
+ type: constant
783
859
  - name: name_loc
784
860
  type: location
785
861
  - name: value
786
- type: node?
862
+ type: node
787
863
  - name: operator_loc
788
864
  type: location?
789
865
  comment: |
@@ -792,7 +868,9 @@ nodes:
792
868
  @@foo = 1
793
869
  ^^^^^^^^^
794
870
  - name: ConstantAndWriteNode
795
- child_nodes:
871
+ fields:
872
+ - name: name
873
+ type: constant
796
874
  - name: name_loc
797
875
  type: location
798
876
  - name: operator_loc
@@ -805,7 +883,9 @@ nodes:
805
883
  Target &&= value
806
884
  ^^^^^^^^^^^^^^^^
807
885
  - name: ConstantOperatorWriteNode
808
- child_nodes:
886
+ fields:
887
+ - name: name
888
+ type: constant
809
889
  - name: name_loc
810
890
  type: location
811
891
  - name: operator_loc
@@ -820,7 +900,9 @@ nodes:
820
900
  Target += value
821
901
  ^^^^^^^^^^^^^^^
822
902
  - name: ConstantOrWriteNode
823
- child_nodes:
903
+ fields:
904
+ - name: name
905
+ type: constant
824
906
  - name: name_loc
825
907
  type: location
826
908
  - name: operator_loc
@@ -833,7 +915,7 @@ nodes:
833
915
  Target ||= value
834
916
  ^^^^^^^^^^^^^^^^
835
917
  - name: ConstantPathAndWriteNode
836
- child_nodes:
918
+ fields:
837
919
  - name: target
838
920
  type: node
839
921
  kind: ConstantPathNode
@@ -847,7 +929,7 @@ nodes:
847
929
  Parent::Child &&= value
848
930
  ^^^^^^^^^^^^^^^^^^^^^^^
849
931
  - name: ConstantPathNode
850
- child_nodes:
932
+ fields:
851
933
  - name: parent
852
934
  type: node?
853
935
  - name: child
@@ -860,7 +942,7 @@ nodes:
860
942
  Foo::Bar
861
943
  ^^^^^^^^
862
944
  - name: ConstantPathOperatorWriteNode
863
- child_nodes:
945
+ fields:
864
946
  - name: target
865
947
  type: node
866
948
  kind: ConstantPathNode
@@ -876,7 +958,7 @@ nodes:
876
958
  Parent::Child += value
877
959
  ^^^^^^^^^^^^^^^^^^^^^^
878
960
  - name: ConstantPathOrWriteNode
879
- child_nodes:
961
+ fields:
880
962
  - name: target
881
963
  type: node
882
964
  kind: ConstantPathNode
@@ -890,7 +972,7 @@ nodes:
890
972
  Parent::Child ||= value
891
973
  ^^^^^^^^^^^^^^^^^^^^^^^
892
974
  - name: ConstantPathTargetNode
893
- child_nodes:
975
+ fields:
894
976
  - name: parent
895
977
  type: node?
896
978
  - name: child
@@ -903,7 +985,7 @@ nodes:
903
985
  Foo::Foo, Bar::Bar = baz
904
986
  ^^^^^^^^ ^^^^^^^^
905
987
  - name: ConstantPathWriteNode
906
- child_nodes:
988
+ fields:
907
989
  - name: target
908
990
  type: node
909
991
  kind: ConstantPathNode
@@ -923,19 +1005,27 @@ nodes:
923
1005
  ::Foo::Bar = 1
924
1006
  ^^^^^^^^^^^^^^
925
1007
  - name: ConstantReadNode
1008
+ fields:
1009
+ - name: name
1010
+ type: constant
926
1011
  comment: |
927
1012
  Represents referencing a constant.
928
1013
 
929
1014
  Foo
930
1015
  ^^^
931
1016
  - name: ConstantTargetNode
1017
+ fields:
1018
+ - name: name
1019
+ type: constant
932
1020
  comment: |
933
1021
  Represents writing to a constant in a context that doesn't have an explicit value.
934
1022
 
935
1023
  Foo, Bar = baz
936
1024
  ^^^ ^^^
937
1025
  - name: ConstantWriteNode
938
- child_nodes:
1026
+ fields:
1027
+ - name: name
1028
+ type: constant
939
1029
  - name: name_loc
940
1030
  type: location
941
1031
  - name: value
@@ -948,7 +1038,9 @@ nodes:
948
1038
  Foo = 1
949
1039
  ^^^^^^^
950
1040
  - name: DefNode
951
- child_nodes:
1041
+ fields:
1042
+ - name: name
1043
+ type: constant
952
1044
  - name: name_loc
953
1045
  type: location
954
1046
  - name: receiver
@@ -979,7 +1071,7 @@ nodes:
979
1071
  end
980
1072
  ^^^^^^^^^^
981
1073
  - name: DefinedNode
982
- child_nodes:
1074
+ fields:
983
1075
  - name: lparen_loc
984
1076
  type: location?
985
1077
  - name: value
@@ -994,7 +1086,7 @@ nodes:
994
1086
  defined?(a)
995
1087
  ^^^^^^^^^^^
996
1088
  - name: ElseNode
997
- child_nodes:
1089
+ fields:
998
1090
  - name: else_keyword_loc
999
1091
  type: location
1000
1092
  - name: statements
@@ -1008,7 +1100,7 @@ nodes:
1008
1100
  if a then b else c end
1009
1101
  ^^^^^^^^^^
1010
1102
  - name: EmbeddedStatementsNode
1011
- child_nodes:
1103
+ fields:
1012
1104
  - name: opening_loc
1013
1105
  type: location
1014
1106
  - name: statements
@@ -1022,7 +1114,7 @@ nodes:
1022
1114
  "foo #{bar}"
1023
1115
  ^^^^^^
1024
1116
  - name: EmbeddedVariableNode
1025
- child_nodes:
1117
+ fields:
1026
1118
  - name: operator_loc
1027
1119
  type: location
1028
1120
  - name: variable
@@ -1033,7 +1125,7 @@ nodes:
1033
1125
  "foo #@bar"
1034
1126
  ^^^^^
1035
1127
  - name: EnsureNode
1036
- child_nodes:
1128
+ fields:
1037
1129
  - name: ensure_keyword_loc
1038
1130
  type: location
1039
1131
  - name: statements
@@ -1057,7 +1149,7 @@ nodes:
1057
1149
  false
1058
1150
  ^^^^^
1059
1151
  - name: FindPatternNode
1060
- child_nodes:
1152
+ fields:
1061
1153
  - name: constant
1062
1154
  type: node?
1063
1155
  - name: left
@@ -1082,7 +1174,7 @@ nodes:
1082
1174
  foo in Foo(*bar, baz, *qux)
1083
1175
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1084
1176
  - name: FlipFlopNode
1085
- child_nodes:
1177
+ fields:
1086
1178
  - name: left
1087
1179
  type: node?
1088
1180
  - name: right
@@ -1104,7 +1196,7 @@ nodes:
1104
1196
  1.0
1105
1197
  ^^^
1106
1198
  - name: ForNode
1107
- child_nodes:
1199
+ fields:
1108
1200
  - name: index
1109
1201
  type: node
1110
1202
  - name: collection
@@ -1141,7 +1233,7 @@ nodes:
1141
1233
  ^^^
1142
1234
  end
1143
1235
  - name: ForwardingSuperNode
1144
- child_nodes:
1236
+ fields:
1145
1237
  - name: block
1146
1238
  type: node?
1147
1239
  kind: BlockNode
@@ -1151,7 +1243,9 @@ nodes:
1151
1243
  super
1152
1244
  ^^^^^
1153
1245
  - name: GlobalVariableAndWriteNode
1154
- child_nodes:
1246
+ fields:
1247
+ - name: name
1248
+ type: constant
1155
1249
  - name: name_loc
1156
1250
  type: location
1157
1251
  - name: operator_loc
@@ -1164,7 +1258,9 @@ nodes:
1164
1258
  $target &&= value
1165
1259
  ^^^^^^^^^^^^^^^^^
1166
1260
  - name: GlobalVariableOperatorWriteNode
1167
- child_nodes:
1261
+ fields:
1262
+ - name: name
1263
+ type: constant
1168
1264
  - name: name_loc
1169
1265
  type: location
1170
1266
  - name: operator_loc
@@ -1179,7 +1275,9 @@ nodes:
1179
1275
  $target += value
1180
1276
  ^^^^^^^^^^^^^^^^
1181
1277
  - name: GlobalVariableOrWriteNode
1182
- child_nodes:
1278
+ fields:
1279
+ - name: name
1280
+ type: constant
1183
1281
  - name: name_loc
1184
1282
  type: location
1185
1283
  - name: operator_loc
@@ -1192,32 +1290,40 @@ nodes:
1192
1290
  $target ||= value
1193
1291
  ^^^^^^^^^^^^^^^^^
1194
1292
  - name: GlobalVariableReadNode
1293
+ fields:
1294
+ - name: name
1295
+ type: constant
1195
1296
  comment: |
1196
1297
  Represents referencing a global variable.
1197
1298
 
1198
1299
  $foo
1199
1300
  ^^^^
1200
1301
  - name: GlobalVariableTargetNode
1302
+ fields:
1303
+ - name: name
1304
+ type: constant
1201
1305
  comment: |
1202
1306
  Represents writing to a global variable in a context that doesn't have an explicit value.
1203
1307
 
1204
1308
  $foo, $bar = baz
1205
1309
  ^^^^ ^^^^
1206
1310
  - name: GlobalVariableWriteNode
1207
- child_nodes:
1311
+ fields:
1312
+ - name: name
1313
+ type: constant
1208
1314
  - name: name_loc
1209
1315
  type: location
1210
- - name: operator_loc
1211
- type: location
1212
1316
  - name: value
1213
1317
  type: node
1318
+ - name: operator_loc
1319
+ type: location
1214
1320
  comment: |
1215
1321
  Represents writing to a global variable.
1216
1322
 
1217
1323
  $foo = 1
1218
1324
  ^^^^^^^^
1219
1325
  - name: HashNode
1220
- child_nodes:
1326
+ fields:
1221
1327
  - name: opening_loc
1222
1328
  type: location
1223
1329
  - name: elements
@@ -1230,7 +1336,7 @@ nodes:
1230
1336
  { a => b }
1231
1337
  ^^^^^^^^^^
1232
1338
  - name: HashPatternNode
1233
- child_nodes:
1339
+ fields:
1234
1340
  - name: constant
1235
1341
  type: node?
1236
1342
  - name: assocs
@@ -1250,7 +1356,7 @@ nodes:
1250
1356
  foo => { a: 1, b: 2, **c }
1251
1357
  ^^^^^^^^^^^^^^^^^^^
1252
1358
  - name: IfNode
1253
- child_nodes:
1359
+ fields:
1254
1360
  - name: if_keyword_loc
1255
1361
  type: location?
1256
1362
  - name: predicate
@@ -1272,7 +1378,7 @@ nodes:
1272
1378
  if foo then bar end
1273
1379
  ^^^^^^^^^^^^^^^^^^^
1274
1380
  - name: ImaginaryNode
1275
- child_nodes:
1381
+ fields:
1276
1382
  - name: numeric
1277
1383
  type: node
1278
1384
  comment: |
@@ -1281,7 +1387,7 @@ nodes:
1281
1387
  1.0i
1282
1388
  ^^^^
1283
1389
  - name: InNode
1284
- child_nodes:
1390
+ fields:
1285
1391
  - name: pattern
1286
1392
  type: node
1287
1393
  - name: statements
@@ -1297,7 +1403,9 @@ nodes:
1297
1403
  case a; in b then c end
1298
1404
  ^^^^^^^^^^^
1299
1405
  - name: InstanceVariableAndWriteNode
1300
- child_nodes:
1406
+ fields:
1407
+ - name: name
1408
+ type: constant
1301
1409
  - name: name_loc
1302
1410
  type: location
1303
1411
  - name: operator_loc
@@ -1310,7 +1418,9 @@ nodes:
1310
1418
  @target &&= value
1311
1419
  ^^^^^^^^^^^^^^^^^
1312
1420
  - name: InstanceVariableOperatorWriteNode
1313
- child_nodes:
1421
+ fields:
1422
+ - name: name
1423
+ type: constant
1314
1424
  - name: name_loc
1315
1425
  type: location
1316
1426
  - name: operator_loc
@@ -1325,7 +1435,9 @@ nodes:
1325
1435
  @target += value
1326
1436
  ^^^^^^^^^^^^^^^^
1327
1437
  - name: InstanceVariableOrWriteNode
1328
- child_nodes:
1438
+ fields:
1439
+ - name: name
1440
+ type: constant
1329
1441
  - name: name_loc
1330
1442
  type: location
1331
1443
  - name: operator_loc
@@ -1338,19 +1450,27 @@ nodes:
1338
1450
  @target ||= value
1339
1451
  ^^^^^^^^^^^^^^^^^
1340
1452
  - name: InstanceVariableReadNode
1453
+ fields:
1454
+ - name: name
1455
+ type: constant
1341
1456
  comment: |
1342
1457
  Represents referencing an instance variable.
1343
1458
 
1344
1459
  @foo
1345
1460
  ^^^^
1346
1461
  - name: InstanceVariableTargetNode
1462
+ fields:
1463
+ - name: name
1464
+ type: constant
1347
1465
  comment: |
1348
1466
  Represents writing to an instance variable in a context that doesn't have an explicit value.
1349
1467
 
1350
1468
  @foo, @bar = baz
1351
1469
  ^^^^ ^^^^
1352
1470
  - name: InstanceVariableWriteNode
1353
- child_nodes:
1471
+ fields:
1472
+ - name: name
1473
+ type: constant
1354
1474
  - name: name_loc
1355
1475
  type: location
1356
1476
  - name: value
@@ -1369,7 +1489,7 @@ nodes:
1369
1489
  1
1370
1490
  ^
1371
1491
  - name: InterpolatedRegularExpressionNode
1372
- child_nodes:
1492
+ fields:
1373
1493
  - name: opening_loc
1374
1494
  type: location
1375
1495
  - name: parts
@@ -1386,7 +1506,7 @@ nodes:
1386
1506
  /foo #{bar} baz/
1387
1507
  ^^^^^^^^^^^^^^^^
1388
1508
  - name: InterpolatedStringNode
1389
- child_nodes:
1509
+ fields:
1390
1510
  - name: opening_loc
1391
1511
  type: location?
1392
1512
  - name: parts
@@ -1400,7 +1520,7 @@ nodes:
1400
1520
  "foo #{bar} baz"
1401
1521
  ^^^^^^^^^^^^^^^^
1402
1522
  - name: InterpolatedSymbolNode
1403
- child_nodes:
1523
+ fields:
1404
1524
  - name: opening_loc
1405
1525
  type: location?
1406
1526
  - name: parts
@@ -1414,7 +1534,7 @@ nodes:
1414
1534
  :"foo #{bar} baz"
1415
1535
  ^^^^^^^^^^^^^^^^^
1416
1536
  - name: InterpolatedXStringNode
1417
- child_nodes:
1537
+ fields:
1418
1538
  - name: opening_loc
1419
1539
  type: location
1420
1540
  - name: parts
@@ -1428,7 +1548,7 @@ nodes:
1428
1548
  `foo #{bar} baz`
1429
1549
  ^^^^^^^^^^^^^^^^
1430
1550
  - name: KeywordHashNode
1431
- child_nodes:
1551
+ fields:
1432
1552
  - name: elements
1433
1553
  type: node[]
1434
1554
  comment: |
@@ -1437,7 +1557,9 @@ nodes:
1437
1557
  foo(a: b)
1438
1558
  ^^^^
1439
1559
  - name: KeywordParameterNode
1440
- child_nodes:
1560
+ fields:
1561
+ - name: name
1562
+ type: constant
1441
1563
  - name: name_loc
1442
1564
  type: location
1443
1565
  - name: value
@@ -1453,11 +1575,13 @@ nodes:
1453
1575
  ^^^^
1454
1576
  end
1455
1577
  - name: KeywordRestParameterNode
1456
- child_nodes:
1457
- - name: operator_loc
1458
- type: location
1578
+ fields:
1579
+ - name: name
1580
+ type: constant?
1459
1581
  - name: name_loc
1460
1582
  type: location?
1583
+ - name: operator_loc
1584
+ type: location
1461
1585
  comment: |
1462
1586
  Represents a keyword rest parameter to a method, block, or lambda definition.
1463
1587
 
@@ -1465,7 +1589,7 @@ nodes:
1465
1589
  ^^^
1466
1590
  end
1467
1591
  - name: LambdaNode
1468
- child_nodes:
1592
+ fields:
1469
1593
  - name: locals
1470
1594
  type: constant[]
1471
1595
  - name: operator_loc
@@ -1485,14 +1609,14 @@ nodes:
1485
1609
  ->(value) { value * 2 }
1486
1610
  ^^^^^^^^^^^^^^^^^^^^^^^
1487
1611
  - name: LocalVariableAndWriteNode
1488
- child_nodes:
1612
+ fields:
1489
1613
  - name: name_loc
1490
1614
  type: location
1491
1615
  - name: operator_loc
1492
1616
  type: location
1493
1617
  - name: value
1494
1618
  type: node
1495
- - name: constant_id
1619
+ - name: name
1496
1620
  type: constant
1497
1621
  - name: depth
1498
1622
  type: uint32
@@ -1502,16 +1626,16 @@ nodes:
1502
1626
  target &&= value
1503
1627
  ^^^^^^^^^^^^^^^^
1504
1628
  - name: LocalVariableOperatorWriteNode
1505
- child_nodes:
1629
+ fields:
1506
1630
  - name: name_loc
1507
1631
  type: location
1508
1632
  - name: operator_loc
1509
1633
  type: location
1510
1634
  - name: value
1511
1635
  type: node
1512
- - name: constant_id
1636
+ - name: name
1513
1637
  type: constant
1514
- - name: operator_id
1638
+ - name: operator
1515
1639
  type: constant
1516
1640
  - name: depth
1517
1641
  type: uint32
@@ -1521,14 +1645,14 @@ nodes:
1521
1645
  target += value
1522
1646
  ^^^^^^^^^^^^^^^
1523
1647
  - name: LocalVariableOrWriteNode
1524
- child_nodes:
1648
+ fields:
1525
1649
  - name: name_loc
1526
1650
  type: location
1527
1651
  - name: operator_loc
1528
1652
  type: location
1529
1653
  - name: value
1530
1654
  type: node
1531
- - name: constant_id
1655
+ - name: name
1532
1656
  type: constant
1533
1657
  - name: depth
1534
1658
  type: uint32
@@ -1538,8 +1662,8 @@ nodes:
1538
1662
  target ||= value
1539
1663
  ^^^^^^^^^^^^^^^^
1540
1664
  - name: LocalVariableReadNode
1541
- child_nodes:
1542
- - name: constant_id
1665
+ fields:
1666
+ - name: name
1543
1667
  type: constant
1544
1668
  - name: depth
1545
1669
  type: uint32
@@ -1551,8 +1675,8 @@ nodes:
1551
1675
  foo
1552
1676
  ^^^
1553
1677
  - name: LocalVariableTargetNode
1554
- child_nodes:
1555
- - name: constant_id
1678
+ fields:
1679
+ - name: name
1556
1680
  type: constant
1557
1681
  - name: depth
1558
1682
  type: uint32
@@ -1562,15 +1686,15 @@ nodes:
1562
1686
  foo, bar = baz
1563
1687
  ^^^ ^^^
1564
1688
  - name: LocalVariableWriteNode
1565
- child_nodes:
1566
- - name: constant_id
1689
+ fields:
1690
+ - name: name
1567
1691
  type: constant
1568
1692
  - name: depth
1569
1693
  type: uint32
1570
- - name: value
1571
- type: node
1572
1694
  - name: name_loc
1573
1695
  type: location
1696
+ - name: value
1697
+ type: node
1574
1698
  - name: operator_loc
1575
1699
  type: location
1576
1700
  comment: |
@@ -1579,7 +1703,7 @@ nodes:
1579
1703
  foo = 1
1580
1704
  ^^^^^^^
1581
1705
  - name: MatchPredicateNode
1582
- child_nodes:
1706
+ fields:
1583
1707
  - name: value
1584
1708
  type: node
1585
1709
  - name: pattern
@@ -1592,7 +1716,7 @@ nodes:
1592
1716
  foo in bar
1593
1717
  ^^^^^^^^^^
1594
1718
  - name: MatchRequiredNode
1595
- child_nodes:
1719
+ fields:
1596
1720
  - name: value
1597
1721
  type: node
1598
1722
  - name: pattern
@@ -1609,7 +1733,7 @@ nodes:
1609
1733
  Represents a node that is missing from the source and results in a syntax
1610
1734
  error.
1611
1735
  - name: ModuleNode
1612
- child_nodes:
1736
+ fields:
1613
1737
  - name: locals
1614
1738
  type: constant[]
1615
1739
  - name: module_keyword_loc
@@ -1621,20 +1745,16 @@ nodes:
1621
1745
  - name: end_keyword_loc
1622
1746
  type: location
1623
1747
  - name: name
1624
- type: string
1748
+ type: constant
1625
1749
  comment: |
1626
1750
  Represents a module declaration involving the `module` keyword.
1627
1751
 
1628
1752
  module Foo end
1629
1753
  ^^^^^^^^^^^^^^
1630
- - name: MultiWriteNode
1631
- child_nodes:
1754
+ - name: MultiTargetNode
1755
+ fields:
1632
1756
  - name: targets
1633
1757
  type: node[]
1634
- - name: operator_loc
1635
- type: location?
1636
- - name: value
1637
- type: node?
1638
1758
  - name: lparen_loc
1639
1759
  type: location?
1640
1760
  - name: rparen_loc
@@ -1642,10 +1762,27 @@ nodes:
1642
1762
  comment: |
1643
1763
  Represents a multi-target expression.
1644
1764
 
1765
+ a, b, c = 1, 2, 3
1766
+ ^^^^^^^
1767
+ - name: MultiWriteNode
1768
+ fields:
1769
+ - name: targets
1770
+ type: node[]
1771
+ - name: lparen_loc
1772
+ type: location?
1773
+ - name: rparen_loc
1774
+ type: location?
1775
+ - name: operator_loc
1776
+ type: location
1777
+ - name: value
1778
+ type: node
1779
+ comment: |
1780
+ Represents a write to a multi-target expression.
1781
+
1645
1782
  a, b, c = 1, 2, 3
1646
1783
  ^^^^^^^^^^^^^^^^^
1647
1784
  - name: NextNode
1648
- child_nodes:
1785
+ fields:
1649
1786
  - name: arguments
1650
1787
  type: node?
1651
1788
  kind: ArgumentsNode
@@ -1663,7 +1800,7 @@ nodes:
1663
1800
  nil
1664
1801
  ^^^
1665
1802
  - name: NoKeywordsParameterNode
1666
- child_nodes:
1803
+ fields:
1667
1804
  - name: operator_loc
1668
1805
  type: location
1669
1806
  - name: keyword_loc
@@ -1675,14 +1812,17 @@ nodes:
1675
1812
  ^^^^^
1676
1813
  end
1677
1814
  - name: NumberedReferenceReadNode
1815
+ fields:
1816
+ - name: number
1817
+ type: uint32
1678
1818
  comment: |
1679
1819
  Represents reading a numbered reference to a capture in the previous match.
1680
1820
 
1681
1821
  $1
1682
1822
  ^^
1683
1823
  - name: OptionalParameterNode
1684
- child_nodes:
1685
- - name: constant_id
1824
+ fields:
1825
+ - name: name
1686
1826
  type: constant
1687
1827
  - name: name_loc
1688
1828
  type: location
@@ -1697,7 +1837,7 @@ nodes:
1697
1837
  ^^^^^
1698
1838
  end
1699
1839
  - name: OrNode
1700
- child_nodes:
1840
+ fields:
1701
1841
  - name: left
1702
1842
  type: node
1703
1843
  - name: right
@@ -1710,7 +1850,7 @@ nodes:
1710
1850
  left or right
1711
1851
  ^^^^^^^^^^^^^
1712
1852
  - name: ParametersNode
1713
- child_nodes:
1853
+ fields:
1714
1854
  - name: requireds
1715
1855
  type: node[]
1716
1856
  - name: optionals
@@ -1734,7 +1874,7 @@ nodes:
1734
1874
  ^^^^^^^
1735
1875
  end
1736
1876
  - name: ParenthesesNode
1737
- child_nodes:
1877
+ fields:
1738
1878
  - name: body
1739
1879
  type: node?
1740
1880
  - name: opening_loc
@@ -1748,7 +1888,7 @@ nodes:
1748
1888
  (10 + 34)
1749
1889
  ^^^^^^^^^
1750
1890
  - name: PinnedExpressionNode
1751
- child_nodes:
1891
+ fields:
1752
1892
  - name: expression
1753
1893
  type: node
1754
1894
  - name: operator_loc
@@ -1764,7 +1904,7 @@ nodes:
1764
1904
  foo in ^(bar)
1765
1905
  ^^^^^^
1766
1906
  - name: PinnedVariableNode
1767
- child_nodes:
1907
+ fields:
1768
1908
  - name: variable
1769
1909
  type: node
1770
1910
  - name: operator_loc
@@ -1776,7 +1916,7 @@ nodes:
1776
1916
  foo in ^bar
1777
1917
  ^^^^
1778
1918
  - name: PostExecutionNode
1779
- child_nodes:
1919
+ fields:
1780
1920
  - name: statements
1781
1921
  type: node?
1782
1922
  kind: StatementsNode
@@ -1792,7 +1932,7 @@ nodes:
1792
1932
  END { foo }
1793
1933
  ^^^^^^^^^^^
1794
1934
  - name: PreExecutionNode
1795
- child_nodes:
1935
+ fields:
1796
1936
  - name: statements
1797
1937
  type: node?
1798
1938
  kind: StatementsNode
@@ -1808,7 +1948,7 @@ nodes:
1808
1948
  BEGIN { foo }
1809
1949
  ^^^^^^^^^^^^^
1810
1950
  - name: ProgramNode
1811
- child_nodes:
1951
+ fields:
1812
1952
  - name: locals
1813
1953
  type: constant[]
1814
1954
  - name: statements
@@ -1816,7 +1956,7 @@ nodes:
1816
1956
  kind: StatementsNode
1817
1957
  comment: The top level node of any parse tree.
1818
1958
  - name: RangeNode
1819
- child_nodes:
1959
+ fields:
1820
1960
  - name: left
1821
1961
  type: node?
1822
1962
  - name: right
@@ -1835,7 +1975,7 @@ nodes:
1835
1975
  c if a =~ /left/ ... b =~ /right/
1836
1976
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1837
1977
  - name: RationalNode
1838
- child_nodes:
1978
+ fields:
1839
1979
  - name: numeric
1840
1980
  type: node
1841
1981
  comment: |
@@ -1850,7 +1990,7 @@ nodes:
1850
1990
  redo
1851
1991
  ^^^^
1852
1992
  - name: RegularExpressionNode
1853
- child_nodes:
1993
+ fields:
1854
1994
  - name: opening_loc
1855
1995
  type: location
1856
1996
  - name: content_loc
@@ -1868,7 +2008,7 @@ nodes:
1868
2008
  /foo/i
1869
2009
  ^^^^^^
1870
2010
  - name: RequiredDestructuredParameterNode
1871
- child_nodes:
2011
+ fields:
1872
2012
  - name: parameters
1873
2013
  type: node[]
1874
2014
  - name: opening_loc
@@ -1882,8 +2022,8 @@ nodes:
1882
2022
  ^^^^^^^^^^
1883
2023
  end
1884
2024
  - name: RequiredParameterNode
1885
- child_nodes:
1886
- - name: constant_id
2025
+ fields:
2026
+ - name: name
1887
2027
  type: constant
1888
2028
  comment: |
1889
2029
  Represents a required parameter to a method, block, or lambda definition.
@@ -1892,7 +2032,7 @@ nodes:
1892
2032
  ^
1893
2033
  end
1894
2034
  - name: RescueModifierNode
1895
- child_nodes:
2035
+ fields:
1896
2036
  - name: expression
1897
2037
  type: node
1898
2038
  - name: keyword_loc
@@ -1906,7 +2046,7 @@ nodes:
1906
2046
  foo rescue nil
1907
2047
  ^^^^^^^^^^^^^^
1908
2048
  - name: RescueNode
1909
- child_nodes:
2049
+ fields:
1910
2050
  - name: keyword_loc
1911
2051
  type: location
1912
2052
  - name: exceptions
@@ -1933,11 +2073,13 @@ nodes:
1933
2073
  `Foo, *splat, Bar` are in the `exceptions` field.
1934
2074
  `ex` is in the `exception` field.
1935
2075
  - name: RestParameterNode
1936
- child_nodes:
1937
- - name: operator_loc
1938
- type: location
2076
+ fields:
2077
+ - name: name
2078
+ type: constant?
1939
2079
  - name: name_loc
1940
2080
  type: location?
2081
+ - name: operator_loc
2082
+ type: location
1941
2083
  comment: |
1942
2084
  Represents a rest parameter to a method, block, or lambda definition.
1943
2085
 
@@ -1951,7 +2093,7 @@ nodes:
1951
2093
  retry
1952
2094
  ^^^^^
1953
2095
  - name: ReturnNode
1954
- child_nodes:
2096
+ fields:
1955
2097
  - name: keyword_loc
1956
2098
  type: location
1957
2099
  - name: arguments
@@ -1969,7 +2111,7 @@ nodes:
1969
2111
  self
1970
2112
  ^^^^
1971
2113
  - name: SingletonClassNode
1972
- child_nodes:
2114
+ fields:
1973
2115
  - name: locals
1974
2116
  type: constant[]
1975
2117
  - name: class_keyword_loc
@@ -1994,7 +2136,7 @@ nodes:
1994
2136
  __ENCODING__
1995
2137
  ^^^^^^^^^^^^
1996
2138
  - name: SourceFileNode
1997
- child_nodes:
2139
+ fields:
1998
2140
  - name: filepath
1999
2141
  type: string
2000
2142
  comment: |
@@ -2009,7 +2151,7 @@ nodes:
2009
2151
  __LINE__
2010
2152
  ^^^^^^^^
2011
2153
  - name: SplatNode
2012
- child_nodes:
2154
+ fields:
2013
2155
  - name: operator_loc
2014
2156
  type: location
2015
2157
  - name: expression
@@ -2020,7 +2162,7 @@ nodes:
2020
2162
  [*a]
2021
2163
  ^^
2022
2164
  - name: StatementsNode
2023
- child_nodes:
2165
+ fields:
2024
2166
  - name: body
2025
2167
  type: node[]
2026
2168
  comment: |
@@ -2029,7 +2171,7 @@ nodes:
2029
2171
  foo; bar; baz
2030
2172
  ^^^^^^^^^^^^^
2031
2173
  - name: StringConcatNode
2032
- child_nodes:
2174
+ fields:
2033
2175
  - name: left
2034
2176
  type: node
2035
2177
  - name: right
@@ -2040,7 +2182,7 @@ nodes:
2040
2182
  "foo" "bar"
2041
2183
  ^^^^^^^^^^^
2042
2184
  - name: StringNode
2043
- child_nodes:
2185
+ fields:
2044
2186
  - name: opening_loc
2045
2187
  type: location?
2046
2188
  - name: content_loc
@@ -2062,7 +2204,7 @@ nodes:
2062
2204
  "foo #{bar} baz"
2063
2205
  ^^^^ ^^^^
2064
2206
  - name: SuperNode
2065
- child_nodes:
2207
+ fields:
2066
2208
  - name: keyword_loc
2067
2209
  type: location
2068
2210
  - name: lparen_loc
@@ -2084,7 +2226,7 @@ nodes:
2084
2226
  super foo, bar
2085
2227
  ^^^^^^^^^^^^^^
2086
2228
  - name: SymbolNode
2087
- child_nodes:
2229
+ fields:
2088
2230
  - name: opening_loc
2089
2231
  type: location?
2090
2232
  - name: value_loc
@@ -2108,7 +2250,7 @@ nodes:
2108
2250
  true
2109
2251
  ^^^^
2110
2252
  - name: UndefNode
2111
- child_nodes:
2253
+ fields:
2112
2254
  - name: names
2113
2255
  type: node[]
2114
2256
  - name: keyword_loc
@@ -2119,7 +2261,7 @@ nodes:
2119
2261
  undef :foo, :bar, :baz
2120
2262
  ^^^^^^^^^^^^^^^^^^^^^^
2121
2263
  - name: UnlessNode
2122
- child_nodes:
2264
+ fields:
2123
2265
  - name: keyword_loc
2124
2266
  type: location
2125
2267
  - name: predicate
@@ -2142,7 +2284,7 @@ nodes:
2142
2284
  unless foo then bar end
2143
2285
  ^^^^^^^^^^^^^^^^^^^^^^^
2144
2286
  - name: UntilNode
2145
- child_nodes:
2287
+ fields:
2146
2288
  - name: keyword_loc
2147
2289
  type: location
2148
2290
  - name: closing_loc
@@ -2165,7 +2307,7 @@ nodes:
2165
2307
  until foo do bar end
2166
2308
  ^^^^^^^^^^^^^^^^^^^^
2167
2309
  - name: WhenNode
2168
- child_nodes:
2310
+ fields:
2169
2311
  - name: keyword_loc
2170
2312
  type: location
2171
2313
  - name: conditions
@@ -2181,7 +2323,7 @@ nodes:
2181
2323
  ^^^^^^^^^
2182
2324
  end
2183
2325
  - name: WhileNode
2184
- child_nodes:
2326
+ fields:
2185
2327
  - name: keyword_loc
2186
2328
  type: location
2187
2329
  - name: closing_loc
@@ -2204,7 +2346,7 @@ nodes:
2204
2346
  while foo do bar end
2205
2347
  ^^^^^^^^^^^^^^^^^^^^
2206
2348
  - name: XStringNode
2207
- child_nodes:
2349
+ fields:
2208
2350
  - name: opening_loc
2209
2351
  type: location
2210
2352
  - name: content_loc
@@ -2219,7 +2361,7 @@ nodes:
2219
2361
  `foo`
2220
2362
  ^^^^^
2221
2363
  - name: YieldNode
2222
- child_nodes:
2364
+ fields:
2223
2365
  - name: keyword_loc
2224
2366
  type: location
2225
2367
  - name: lparen_loc