yarp 0.8.0 → 0.10.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +48 -1
  3. data/Makefile +5 -1
  4. data/README.md +4 -3
  5. data/config.yml +461 -150
  6. data/docs/configuration.md +1 -0
  7. data/docs/encoding.md +5 -5
  8. data/docs/ruby_api.md +2 -0
  9. data/docs/serialization.md +3 -3
  10. data/docs/testing.md +2 -2
  11. data/ext/yarp/api_node.c +810 -199
  12. data/ext/yarp/extension.c +94 -31
  13. data/ext/yarp/extension.h +2 -2
  14. data/include/yarp/ast.h +653 -150
  15. data/include/yarp/defines.h +2 -1
  16. data/include/yarp/diagnostic.h +3 -3
  17. data/include/yarp/enc/yp_encoding.h +10 -10
  18. data/include/yarp/node.h +10 -0
  19. data/include/yarp/parser.h +19 -19
  20. data/include/yarp/regexp.h +1 -1
  21. data/include/yarp/unescape.h +7 -5
  22. data/include/yarp/util/yp_buffer.h +3 -0
  23. data/include/yarp/util/yp_char.h +16 -16
  24. data/include/yarp/util/yp_constant_pool.h +2 -2
  25. data/include/yarp/util/yp_newline_list.h +7 -4
  26. data/include/yarp/util/yp_string.h +4 -4
  27. data/include/yarp/util/yp_string_list.h +0 -3
  28. data/include/yarp/util/yp_strpbrk.h +1 -1
  29. data/include/yarp/version.h +2 -2
  30. data/include/yarp.h +14 -3
  31. data/lib/yarp/desugar_visitor.rb +204 -0
  32. data/lib/yarp/ffi.rb +27 -1
  33. data/lib/yarp/lex_compat.rb +93 -25
  34. data/lib/yarp/mutation_visitor.rb +683 -0
  35. data/lib/yarp/node.rb +3121 -597
  36. data/lib/yarp/serialize.rb +198 -126
  37. data/lib/yarp.rb +53 -7
  38. data/src/diagnostic.c +1 -1
  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 +1444 -836
  47. data/src/prettyprint.c +324 -103
  48. data/src/regexp.c +21 -21
  49. data/src/serialize.c +429 -276
  50. data/src/token_type.c +2 -2
  51. data/src/unescape.c +184 -136
  52. data/src/util/yp_buffer.c +7 -2
  53. data/src/util/yp_char.c +34 -34
  54. data/src/util/yp_constant_pool.c +4 -4
  55. data/src/util/yp_memchr.c +1 -1
  56. data/src/util/yp_newline_list.c +14 -3
  57. data/src/util/yp_string.c +22 -20
  58. data/src/util/yp_string_list.c +0 -6
  59. data/src/util/yp_strncasecmp.c +3 -6
  60. data/src/util/yp_strpbrk.c +8 -8
  61. data/src/yarp.c +1504 -615
  62. data/yarp.gemspec +3 -1
  63. metadata +4 -2
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
@@ -399,21 +399,8 @@ nodes:
399
399
 
400
400
  left and right
401
401
  ^^^^^^^^^^^^^^
402
- - name: AndWriteNode
403
- child_nodes:
404
- - name: target
405
- type: node
406
- - name: value
407
- type: node
408
- - name: operator_loc
409
- type: location
410
- comment: |
411
- Represents the use of the `&&=` operator.
412
-
413
- target &&= value
414
- ^^^^^^^^^^^^^^^^
415
402
  - name: ArgumentsNode
416
- child_nodes:
403
+ fields:
417
404
  - name: arguments
418
405
  type: node[]
419
406
  comment: |
@@ -422,7 +409,7 @@ nodes:
422
409
  return foo, bar, baz
423
410
  ^^^^^^^^^^^^^
424
411
  - name: ArrayNode
425
- child_nodes:
412
+ fields:
426
413
  - name: elements
427
414
  type: node[]
428
415
  - name: opening_loc
@@ -436,7 +423,7 @@ nodes:
436
423
  [1, 2, 3]
437
424
  ^^^^^^^^^
438
425
  - name: ArrayPatternNode
439
- child_nodes:
426
+ fields:
440
427
  - name: constant
441
428
  type: node?
442
429
  - name: requireds
@@ -467,7 +454,7 @@ nodes:
467
454
  foo in Bar[1, 2, 3]
468
455
  ^^^^^^^^^^^^^^^^^^^
469
456
  - name: AssocNode
470
- child_nodes:
457
+ fields:
471
458
  - name: key
472
459
  type: node
473
460
  - name: value
@@ -480,7 +467,7 @@ nodes:
480
467
  { a => b }
481
468
  ^^^^^^
482
469
  - name: AssocSplatNode
483
- child_nodes:
470
+ fields:
484
471
  - name: value
485
472
  type: node?
486
473
  - name: operator_loc
@@ -497,7 +484,7 @@ nodes:
497
484
  $'
498
485
  ^^
499
486
  - name: BeginNode
500
- child_nodes:
487
+ fields:
501
488
  - name: begin_keyword_loc
502
489
  type: location?
503
490
  - name: statements
@@ -523,7 +510,7 @@ nodes:
523
510
  end
524
511
  ^^^^^
525
512
  - name: BlockArgumentNode
526
- child_nodes:
513
+ fields:
527
514
  - name: expression
528
515
  type: node?
529
516
  - name: operator_loc
@@ -534,7 +521,7 @@ nodes:
534
521
  bar(&args)
535
522
  ^^^^^^^^^^
536
523
  - name: BlockNode
537
- child_nodes:
524
+ fields:
538
525
  - name: locals
539
526
  type: constant[]
540
527
  - name: parameters
@@ -552,7 +539,7 @@ nodes:
552
539
  [1, 2, 3].each { |i| puts x }
553
540
  ^^^^^^^^^^^^^^
554
541
  - name: BlockParameterNode
555
- child_nodes:
542
+ fields:
556
543
  - name: name_loc
557
544
  type: location?
558
545
  - name: operator_loc
@@ -564,7 +551,7 @@ nodes:
564
551
  ^^
565
552
  end
566
553
  - name: BlockParametersNode
567
- child_nodes:
554
+ fields:
568
555
  - name: parameters
569
556
  type: node?
570
557
  kind: ParametersNode
@@ -584,7 +571,7 @@ nodes:
584
571
  ^^^^^^^^^^^^^^^^^
585
572
  end
586
573
  - name: BreakNode
587
- child_nodes:
574
+ fields:
588
575
  - name: arguments
589
576
  type: node?
590
577
  kind: ArgumentsNode
@@ -596,7 +583,7 @@ nodes:
596
583
  break foo
597
584
  ^^^^^^^^^
598
585
  - name: CallNode
599
- child_nodes:
586
+ fields:
600
587
  - name: receiver
601
588
  type: node?
602
589
  - name: operator_loc
@@ -639,7 +626,7 @@ nodes:
639
626
  foo&.bar
640
627
  ^^^^^^^^
641
628
  - name: CallOperatorAndWriteNode
642
- child_nodes:
629
+ fields:
643
630
  - name: target
644
631
  type: node
645
632
  kind: CallNode
@@ -653,7 +640,7 @@ nodes:
653
640
  foo.bar &&= value
654
641
  ^^^^^^^^^^^^^^^^^
655
642
  - name: CallOperatorOrWriteNode
656
- child_nodes:
643
+ fields:
657
644
  - name: target
658
645
  type: node
659
646
  kind: CallNode
@@ -667,7 +654,7 @@ nodes:
667
654
  foo.bar ||= value
668
655
  ^^^^^^^^^^^^^^^^^
669
656
  - name: CallOperatorWriteNode
670
- child_nodes:
657
+ fields:
671
658
  - name: target
672
659
  type: node
673
660
  kind: CallNode
@@ -675,7 +662,7 @@ nodes:
675
662
  type: location
676
663
  - name: value
677
664
  type: node
678
- - name: operator_id
665
+ - name: operator
679
666
  type: constant
680
667
  comment: |
681
668
  Represents the use of an assignment operator on a call.
@@ -683,7 +670,7 @@ nodes:
683
670
  foo.bar += baz
684
671
  ^^^^^^^^^^^^^^
685
672
  - name: CapturePatternNode
686
- child_nodes:
673
+ fields:
687
674
  - name: value
688
675
  type: node
689
676
  - name: target
@@ -696,7 +683,7 @@ nodes:
696
683
  foo => [bar => baz]
697
684
  ^^^^^^^^^^^^
698
685
  - name: CaseNode
699
- child_nodes:
686
+ fields:
700
687
  - name: predicate
701
688
  type: node?
702
689
  - name: conditions
@@ -716,7 +703,7 @@ nodes:
716
703
  when false
717
704
  end
718
705
  - name: ClassNode
719
- child_nodes:
706
+ fields:
720
707
  - name: locals
721
708
  type: constant[]
722
709
  - name: class_keyword_loc
@@ -731,19 +718,82 @@ nodes:
731
718
  type: node?
732
719
  - name: end_keyword_loc
733
720
  type: location
721
+ - name: name
722
+ type: string
734
723
  comment: |
735
724
  Represents a class declaration involving the `class` keyword.
736
725
 
737
726
  class Foo end
738
727
  ^^^^^^^^^^^^^
728
+ - name: ClassVariableAndWriteNode
729
+ fields:
730
+ - name: name
731
+ type: constant
732
+ - name: name_loc
733
+ type: location
734
+ - name: operator_loc
735
+ type: location
736
+ - name: value
737
+ type: node
738
+ comment: |
739
+ Represents the use of the `&&=` operator for assignment to a class variable.
740
+
741
+ @@target &&= value
742
+ ^^^^^^^^^^^^^^^^
743
+ - name: ClassVariableOperatorWriteNode
744
+ fields:
745
+ - name: name
746
+ type: constant
747
+ - name: name_loc
748
+ type: location
749
+ - name: operator_loc
750
+ type: location
751
+ - name: value
752
+ type: node
753
+ - name: operator
754
+ type: constant
755
+ comment: |
756
+ Represents assigning to a class variable using an operator that isn't `=`.
757
+
758
+ @@target += value
759
+ ^^^^^^^^^^^^^^^^^
760
+ - name: ClassVariableOrWriteNode
761
+ fields:
762
+ - name: name
763
+ type: constant
764
+ - name: name_loc
765
+ type: location
766
+ - name: operator_loc
767
+ type: location
768
+ - name: value
769
+ type: node
770
+ comment: |
771
+ Represents the use of the `||=` operator for assignment to a class variable.
772
+
773
+ @@target ||= value
774
+ ^^^^^^^^^^^^^^^^^^
739
775
  - name: ClassVariableReadNode
776
+ fields:
777
+ - name: name
778
+ type: constant
740
779
  comment: |
741
780
  Represents referencing a class variable.
742
781
 
743
782
  @@foo
744
783
  ^^^^^
784
+ - name: ClassVariableTargetNode
785
+ fields:
786
+ - name: name
787
+ type: constant
788
+ comment: |
789
+ Represents writing to a class variable in a context that doesn't have an explicit value.
790
+
791
+ @@foo, @@bar = baz
792
+ ^^^^^ ^^^^^
745
793
  - name: ClassVariableWriteNode
746
- child_nodes:
794
+ fields:
795
+ - name: name
796
+ type: constant
747
797
  - name: name_loc
748
798
  type: location
749
799
  - name: value
@@ -755,8 +805,63 @@ nodes:
755
805
 
756
806
  @@foo = 1
757
807
  ^^^^^^^^^
808
+ - name: ConstantAndWriteNode
809
+ fields:
810
+ - name: name_loc
811
+ type: location
812
+ - name: operator_loc
813
+ type: location
814
+ - name: value
815
+ type: node
816
+ comment: |
817
+ Represents the use of the `&&=` operator for assignment to a constant.
818
+
819
+ Target &&= value
820
+ ^^^^^^^^^^^^^^^^
821
+ - name: ConstantOperatorWriteNode
822
+ fields:
823
+ - name: name_loc
824
+ type: location
825
+ - name: operator_loc
826
+ type: location
827
+ - name: value
828
+ type: node
829
+ - name: operator
830
+ type: constant
831
+ comment: |
832
+ Represents assigning to a constant using an operator that isn't `=`.
833
+
834
+ Target += value
835
+ ^^^^^^^^^^^^^^^
836
+ - name: ConstantOrWriteNode
837
+ fields:
838
+ - name: name_loc
839
+ type: location
840
+ - name: operator_loc
841
+ type: location
842
+ - name: value
843
+ type: node
844
+ comment: |
845
+ Represents the use of the `||=` operator for assignment to a constant.
846
+
847
+ Target ||= value
848
+ ^^^^^^^^^^^^^^^^
849
+ - name: ConstantPathAndWriteNode
850
+ fields:
851
+ - name: target
852
+ type: node
853
+ kind: ConstantPathNode
854
+ - name: operator_loc
855
+ type: location
856
+ - name: value
857
+ type: node
858
+ comment: |
859
+ Represents the use of the `&&=` operator for assignment to a constant path.
860
+
861
+ Parent::Child &&= value
862
+ ^^^^^^^^^^^^^^^^^^^^^^^
758
863
  - name: ConstantPathNode
759
- child_nodes:
864
+ fields:
760
865
  - name: parent
761
866
  type: node?
762
867
  - name: child
@@ -768,15 +873,58 @@ nodes:
768
873
 
769
874
  Foo::Bar
770
875
  ^^^^^^^^
771
- - name: ConstantPathWriteNode
772
- child_nodes:
876
+ - name: ConstantPathOperatorWriteNode
877
+ fields:
773
878
  - name: target
774
879
  type: node
775
880
  kind: ConstantPathNode
776
881
  - name: operator_loc
777
- type: location?
882
+ type: location
778
883
  - name: value
884
+ type: node
885
+ - name: operator
886
+ type: constant
887
+ comment: |
888
+ Represents assigning to a constant path using an operator that isn't `=`.
889
+
890
+ Parent::Child += value
891
+ ^^^^^^^^^^^^^^^^^^^^^^
892
+ - name: ConstantPathOrWriteNode
893
+ fields:
894
+ - name: target
895
+ type: node
896
+ kind: ConstantPathNode
897
+ - name: operator_loc
898
+ type: location
899
+ - name: value
900
+ type: node
901
+ comment: |
902
+ Represents the use of the `||=` operator for assignment to a constant path.
903
+
904
+ Parent::Child ||= value
905
+ ^^^^^^^^^^^^^^^^^^^^^^^
906
+ - name: ConstantPathTargetNode
907
+ fields:
908
+ - name: parent
779
909
  type: node?
910
+ - name: child
911
+ type: node
912
+ - name: delimiter_loc
913
+ type: location
914
+ comment: |
915
+ Represents writing to a constant path in a context that doesn't have an explicit value.
916
+
917
+ Foo::Foo, Bar::Bar = baz
918
+ ^^^^^^^^ ^^^^^^^^
919
+ - name: ConstantPathWriteNode
920
+ fields:
921
+ - name: target
922
+ type: node
923
+ kind: ConstantPathNode
924
+ - name: operator_loc
925
+ type: location
926
+ - name: value
927
+ type: node
780
928
  comment: |
781
929
  Represents writing to a constant path.
782
930
 
@@ -794,21 +942,27 @@ nodes:
794
942
 
795
943
  Foo
796
944
  ^^^
945
+ - name: ConstantTargetNode
946
+ comment: |
947
+ Represents writing to a constant in a context that doesn't have an explicit value.
948
+
949
+ Foo, Bar = baz
950
+ ^^^ ^^^
797
951
  - name: ConstantWriteNode
798
- child_nodes:
952
+ fields:
799
953
  - name: name_loc
800
954
  type: location
801
955
  - name: value
802
- type: node?
956
+ type: node
803
957
  - name: operator_loc
804
- type: location?
958
+ type: location
805
959
  comment: |
806
960
  Represents writing to a constant.
807
961
 
808
962
  Foo = 1
809
963
  ^^^^^^^
810
964
  - name: DefNode
811
- child_nodes:
965
+ fields:
812
966
  - name: name_loc
813
967
  type: location
814
968
  - name: receiver
@@ -839,7 +993,7 @@ nodes:
839
993
  end
840
994
  ^^^^^^^^^^
841
995
  - name: DefinedNode
842
- child_nodes:
996
+ fields:
843
997
  - name: lparen_loc
844
998
  type: location?
845
999
  - name: value
@@ -854,7 +1008,7 @@ nodes:
854
1008
  defined?(a)
855
1009
  ^^^^^^^^^^^
856
1010
  - name: ElseNode
857
- child_nodes:
1011
+ fields:
858
1012
  - name: else_keyword_loc
859
1013
  type: location
860
1014
  - name: statements
@@ -868,7 +1022,7 @@ nodes:
868
1022
  if a then b else c end
869
1023
  ^^^^^^^^^^
870
1024
  - name: EmbeddedStatementsNode
871
- child_nodes:
1025
+ fields:
872
1026
  - name: opening_loc
873
1027
  type: location
874
1028
  - name: statements
@@ -882,7 +1036,7 @@ nodes:
882
1036
  "foo #{bar}"
883
1037
  ^^^^^^
884
1038
  - name: EmbeddedVariableNode
885
- child_nodes:
1039
+ fields:
886
1040
  - name: operator_loc
887
1041
  type: location
888
1042
  - name: variable
@@ -893,7 +1047,7 @@ nodes:
893
1047
  "foo #@bar"
894
1048
  ^^^^^
895
1049
  - name: EnsureNode
896
- child_nodes:
1050
+ fields:
897
1051
  - name: ensure_keyword_loc
898
1052
  type: location
899
1053
  - name: statements
@@ -917,7 +1071,7 @@ nodes:
917
1071
  false
918
1072
  ^^^^^
919
1073
  - name: FindPatternNode
920
- child_nodes:
1074
+ fields:
921
1075
  - name: constant
922
1076
  type: node?
923
1077
  - name: left
@@ -942,7 +1096,7 @@ nodes:
942
1096
  foo in Foo(*bar, baz, *qux)
943
1097
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
944
1098
  - name: FlipFlopNode
945
- child_nodes:
1099
+ fields:
946
1100
  - name: left
947
1101
  type: node?
948
1102
  - name: right
@@ -964,7 +1118,7 @@ nodes:
964
1118
  1.0
965
1119
  ^^^
966
1120
  - name: ForNode
967
- child_nodes:
1121
+ fields:
968
1122
  - name: index
969
1123
  type: node
970
1124
  - name: collection
@@ -1001,7 +1155,7 @@ nodes:
1001
1155
  ^^^
1002
1156
  end
1003
1157
  - name: ForwardingSuperNode
1004
- child_nodes:
1158
+ fields:
1005
1159
  - name: block
1006
1160
  type: node?
1007
1161
  kind: BlockNode
@@ -1010,27 +1164,74 @@ nodes:
1010
1164
 
1011
1165
  super
1012
1166
  ^^^^^
1167
+ - name: GlobalVariableAndWriteNode
1168
+ fields:
1169
+ - name: name_loc
1170
+ type: location
1171
+ - name: operator_loc
1172
+ type: location
1173
+ - name: value
1174
+ type: node
1175
+ comment: |
1176
+ Represents the use of the `&&=` operator for assignment to a global variable.
1177
+
1178
+ $target &&= value
1179
+ ^^^^^^^^^^^^^^^^^
1180
+ - name: GlobalVariableOperatorWriteNode
1181
+ fields:
1182
+ - name: name_loc
1183
+ type: location
1184
+ - name: operator_loc
1185
+ type: location
1186
+ - name: value
1187
+ type: node
1188
+ - name: operator
1189
+ type: constant
1190
+ comment: |
1191
+ Represents assigning to a global variable using an operator that isn't `=`.
1192
+
1193
+ $target += value
1194
+ ^^^^^^^^^^^^^^^^
1195
+ - name: GlobalVariableOrWriteNode
1196
+ fields:
1197
+ - name: name_loc
1198
+ type: location
1199
+ - name: operator_loc
1200
+ type: location
1201
+ - name: value
1202
+ type: node
1203
+ comment: |
1204
+ Represents the use of the `||=` operator for assignment to a global variable.
1205
+
1206
+ $target ||= value
1207
+ ^^^^^^^^^^^^^^^^^
1013
1208
  - name: GlobalVariableReadNode
1014
1209
  comment: |
1015
1210
  Represents referencing a global variable.
1016
1211
 
1017
1212
  $foo
1018
1213
  ^^^^
1214
+ - name: GlobalVariableTargetNode
1215
+ comment: |
1216
+ Represents writing to a global variable in a context that doesn't have an explicit value.
1217
+
1218
+ $foo, $bar = baz
1219
+ ^^^^ ^^^^
1019
1220
  - name: GlobalVariableWriteNode
1020
- child_nodes:
1221
+ fields:
1021
1222
  - name: name_loc
1022
1223
  type: location
1023
- - name: operator_loc
1024
- type: location?
1025
1224
  - name: value
1026
- type: node?
1225
+ type: node
1226
+ - name: operator_loc
1227
+ type: location
1027
1228
  comment: |
1028
1229
  Represents writing to a global variable.
1029
1230
 
1030
1231
  $foo = 1
1031
1232
  ^^^^^^^^
1032
1233
  - name: HashNode
1033
- child_nodes:
1234
+ fields:
1034
1235
  - name: opening_loc
1035
1236
  type: location
1036
1237
  - name: elements
@@ -1043,7 +1244,7 @@ nodes:
1043
1244
  { a => b }
1044
1245
  ^^^^^^^^^^
1045
1246
  - name: HashPatternNode
1046
- child_nodes:
1247
+ fields:
1047
1248
  - name: constant
1048
1249
  type: node?
1049
1250
  - name: assocs
@@ -1063,7 +1264,7 @@ nodes:
1063
1264
  foo => { a: 1, b: 2, **c }
1064
1265
  ^^^^^^^^^^^^^^^^^^^
1065
1266
  - name: IfNode
1066
- child_nodes:
1267
+ fields:
1067
1268
  - name: if_keyword_loc
1068
1269
  type: location?
1069
1270
  - name: predicate
@@ -1085,7 +1286,7 @@ nodes:
1085
1286
  if foo then bar end
1086
1287
  ^^^^^^^^^^^^^^^^^^^
1087
1288
  - name: ImaginaryNode
1088
- child_nodes:
1289
+ fields:
1089
1290
  - name: numeric
1090
1291
  type: node
1091
1292
  comment: |
@@ -1094,7 +1295,7 @@ nodes:
1094
1295
  1.0i
1095
1296
  ^^^^
1096
1297
  - name: InNode
1097
- child_nodes:
1298
+ fields:
1098
1299
  - name: pattern
1099
1300
  type: node
1100
1301
  - name: statements
@@ -1109,20 +1310,81 @@ nodes:
1109
1310
 
1110
1311
  case a; in b then c end
1111
1312
  ^^^^^^^^^^^
1313
+ - name: InstanceVariableAndWriteNode
1314
+ fields:
1315
+ - name: name
1316
+ type: constant
1317
+ - name: name_loc
1318
+ type: location
1319
+ - name: operator_loc
1320
+ type: location
1321
+ - name: value
1322
+ type: node
1323
+ comment: |
1324
+ Represents the use of the `&&=` operator for assignment to an instance variable.
1325
+
1326
+ @target &&= value
1327
+ ^^^^^^^^^^^^^^^^^
1328
+ - name: InstanceVariableOperatorWriteNode
1329
+ fields:
1330
+ - name: name
1331
+ type: constant
1332
+ - name: name_loc
1333
+ type: location
1334
+ - name: operator_loc
1335
+ type: location
1336
+ - name: value
1337
+ type: node
1338
+ - name: operator
1339
+ type: constant
1340
+ comment: |
1341
+ Represents assigning to an instance variable using an operator that isn't `=`.
1342
+
1343
+ @target += value
1344
+ ^^^^^^^^^^^^^^^^
1345
+ - name: InstanceVariableOrWriteNode
1346
+ fields:
1347
+ - name: name
1348
+ type: constant
1349
+ - name: name_loc
1350
+ type: location
1351
+ - name: operator_loc
1352
+ type: location
1353
+ - name: value
1354
+ type: node
1355
+ comment: |
1356
+ Represents the use of the `||=` operator for assignment to an instance variable.
1357
+
1358
+ @target ||= value
1359
+ ^^^^^^^^^^^^^^^^^
1112
1360
  - name: InstanceVariableReadNode
1361
+ fields:
1362
+ - name: name
1363
+ type: constant
1113
1364
  comment: |
1114
1365
  Represents referencing an instance variable.
1115
1366
 
1116
1367
  @foo
1117
1368
  ^^^^
1369
+ - name: InstanceVariableTargetNode
1370
+ fields:
1371
+ - name: name
1372
+ type: constant
1373
+ comment: |
1374
+ Represents writing to an instance variable in a context that doesn't have an explicit value.
1375
+
1376
+ @foo, @bar = baz
1377
+ ^^^^ ^^^^
1118
1378
  - name: InstanceVariableWriteNode
1119
- child_nodes:
1379
+ fields:
1380
+ - name: name
1381
+ type: constant
1120
1382
  - name: name_loc
1121
1383
  type: location
1122
1384
  - name: value
1123
- type: node?
1385
+ type: node
1124
1386
  - name: operator_loc
1125
- type: location?
1387
+ type: location
1126
1388
  comment: |
1127
1389
  Represents writing to an instance variable.
1128
1390
 
@@ -1135,7 +1397,7 @@ nodes:
1135
1397
  1
1136
1398
  ^
1137
1399
  - name: InterpolatedRegularExpressionNode
1138
- child_nodes:
1400
+ fields:
1139
1401
  - name: opening_loc
1140
1402
  type: location
1141
1403
  - name: parts
@@ -1152,7 +1414,7 @@ nodes:
1152
1414
  /foo #{bar} baz/
1153
1415
  ^^^^^^^^^^^^^^^^
1154
1416
  - name: InterpolatedStringNode
1155
- child_nodes:
1417
+ fields:
1156
1418
  - name: opening_loc
1157
1419
  type: location?
1158
1420
  - name: parts
@@ -1166,7 +1428,7 @@ nodes:
1166
1428
  "foo #{bar} baz"
1167
1429
  ^^^^^^^^^^^^^^^^
1168
1430
  - name: InterpolatedSymbolNode
1169
- child_nodes:
1431
+ fields:
1170
1432
  - name: opening_loc
1171
1433
  type: location?
1172
1434
  - name: parts
@@ -1180,7 +1442,7 @@ nodes:
1180
1442
  :"foo #{bar} baz"
1181
1443
  ^^^^^^^^^^^^^^^^^
1182
1444
  - name: InterpolatedXStringNode
1183
- child_nodes:
1445
+ fields:
1184
1446
  - name: opening_loc
1185
1447
  type: location
1186
1448
  - name: parts
@@ -1194,7 +1456,7 @@ nodes:
1194
1456
  `foo #{bar} baz`
1195
1457
  ^^^^^^^^^^^^^^^^
1196
1458
  - name: KeywordHashNode
1197
- child_nodes:
1459
+ fields:
1198
1460
  - name: elements
1199
1461
  type: node[]
1200
1462
  comment: |
@@ -1203,7 +1465,7 @@ nodes:
1203
1465
  foo(a: b)
1204
1466
  ^^^^
1205
1467
  - name: KeywordParameterNode
1206
- child_nodes:
1468
+ fields:
1207
1469
  - name: name_loc
1208
1470
  type: location
1209
1471
  - name: value
@@ -1219,7 +1481,7 @@ nodes:
1219
1481
  ^^^^
1220
1482
  end
1221
1483
  - name: KeywordRestParameterNode
1222
- child_nodes:
1484
+ fields:
1223
1485
  - name: operator_loc
1224
1486
  type: location
1225
1487
  - name: name_loc
@@ -1231,11 +1493,15 @@ nodes:
1231
1493
  ^^^
1232
1494
  end
1233
1495
  - name: LambdaNode
1234
- child_nodes:
1496
+ fields:
1235
1497
  - name: locals
1236
1498
  type: constant[]
1499
+ - name: operator_loc
1500
+ type: location
1237
1501
  - name: opening_loc
1238
1502
  type: location
1503
+ - name: closing_loc
1504
+ type: location
1239
1505
  - name: parameters
1240
1506
  type: node?
1241
1507
  kind: BlockParametersNode
@@ -1246,9 +1512,62 @@ nodes:
1246
1512
 
1247
1513
  ->(value) { value * 2 }
1248
1514
  ^^^^^^^^^^^^^^^^^^^^^^^
1515
+ - name: LocalVariableAndWriteNode
1516
+ fields:
1517
+ - name: name_loc
1518
+ type: location
1519
+ - name: operator_loc
1520
+ type: location
1521
+ - name: value
1522
+ type: node
1523
+ - name: name
1524
+ type: constant
1525
+ - name: depth
1526
+ type: uint32
1527
+ comment: |
1528
+ Represents the use of the `&&=` operator for assignment to a local variable.
1529
+
1530
+ target &&= value
1531
+ ^^^^^^^^^^^^^^^^
1532
+ - name: LocalVariableOperatorWriteNode
1533
+ fields:
1534
+ - name: name_loc
1535
+ type: location
1536
+ - name: operator_loc
1537
+ type: location
1538
+ - name: value
1539
+ type: node
1540
+ - name: name
1541
+ type: constant
1542
+ - name: operator
1543
+ type: constant
1544
+ - name: depth
1545
+ type: uint32
1546
+ comment: |
1547
+ Represents assigning to a local variable using an operator that isn't `=`.
1548
+
1549
+ target += value
1550
+ ^^^^^^^^^^^^^^^
1551
+ - name: LocalVariableOrWriteNode
1552
+ fields:
1553
+ - name: name_loc
1554
+ type: location
1555
+ - name: operator_loc
1556
+ type: location
1557
+ - name: value
1558
+ type: node
1559
+ - name: name
1560
+ type: constant
1561
+ - name: depth
1562
+ type: uint32
1563
+ comment: |
1564
+ Represents the use of the `||=` operator for assignment to a local variable.
1565
+
1566
+ target ||= value
1567
+ ^^^^^^^^^^^^^^^^
1249
1568
  - name: LocalVariableReadNode
1250
- child_nodes:
1251
- - name: constant_id
1569
+ fields:
1570
+ - name: name
1252
1571
  type: constant
1253
1572
  - name: depth
1254
1573
  type: uint32
@@ -1259,25 +1578,36 @@ nodes:
1259
1578
 
1260
1579
  foo
1261
1580
  ^^^
1581
+ - name: LocalVariableTargetNode
1582
+ fields:
1583
+ - name: name
1584
+ type: constant
1585
+ - name: depth
1586
+ type: uint32
1587
+ comment: |
1588
+ Represents writing to a local variable in a context that doesn't have an explicit value.
1589
+
1590
+ foo, bar = baz
1591
+ ^^^ ^^^
1262
1592
  - name: LocalVariableWriteNode
1263
- child_nodes:
1264
- - name: constant_id
1593
+ fields:
1594
+ - name: name
1265
1595
  type: constant
1266
1596
  - name: depth
1267
1597
  type: uint32
1268
- - name: value
1269
- type: node?
1270
1598
  - name: name_loc
1271
1599
  type: location
1600
+ - name: value
1601
+ type: node
1272
1602
  - name: operator_loc
1273
- type: location?
1603
+ type: location
1274
1604
  comment: |
1275
1605
  Represents writing to a local variable.
1276
1606
 
1277
1607
  foo = 1
1278
1608
  ^^^^^^^
1279
1609
  - name: MatchPredicateNode
1280
- child_nodes:
1610
+ fields:
1281
1611
  - name: value
1282
1612
  type: node
1283
1613
  - name: pattern
@@ -1290,7 +1620,7 @@ nodes:
1290
1620
  foo in bar
1291
1621
  ^^^^^^^^^^
1292
1622
  - name: MatchRequiredNode
1293
- child_nodes:
1623
+ fields:
1294
1624
  - name: value
1295
1625
  type: node
1296
1626
  - name: pattern
@@ -1307,7 +1637,7 @@ nodes:
1307
1637
  Represents a node that is missing from the source and results in a syntax
1308
1638
  error.
1309
1639
  - name: ModuleNode
1310
- child_nodes:
1640
+ fields:
1311
1641
  - name: locals
1312
1642
  type: constant[]
1313
1643
  - name: module_keyword_loc
@@ -1318,13 +1648,15 @@ nodes:
1318
1648
  type: node?
1319
1649
  - name: end_keyword_loc
1320
1650
  type: location
1651
+ - name: name
1652
+ type: string
1321
1653
  comment: |
1322
1654
  Represents a module declaration involving the `module` keyword.
1323
1655
 
1324
1656
  module Foo end
1325
1657
  ^^^^^^^^^^^^^^
1326
1658
  - name: MultiWriteNode
1327
- child_nodes:
1659
+ fields:
1328
1660
  - name: targets
1329
1661
  type: node[]
1330
1662
  - name: operator_loc
@@ -1341,7 +1673,7 @@ nodes:
1341
1673
  a, b, c = 1, 2, 3
1342
1674
  ^^^^^^^^^^^^^^^^^
1343
1675
  - name: NextNode
1344
- child_nodes:
1676
+ fields:
1345
1677
  - name: arguments
1346
1678
  type: node?
1347
1679
  kind: ArgumentsNode
@@ -1359,7 +1691,7 @@ nodes:
1359
1691
  nil
1360
1692
  ^^^
1361
1693
  - name: NoKeywordsParameterNode
1362
- child_nodes:
1694
+ fields:
1363
1695
  - name: operator_loc
1364
1696
  type: location
1365
1697
  - name: keyword_loc
@@ -1371,29 +1703,17 @@ nodes:
1371
1703
  ^^^^^
1372
1704
  end
1373
1705
  - name: NumberedReferenceReadNode
1706
+ fields:
1707
+ - name: number
1708
+ type: uint32
1374
1709
  comment: |
1375
1710
  Represents reading a numbered reference to a capture in the previous match.
1376
1711
 
1377
1712
  $1
1378
1713
  ^^
1379
- - name: OperatorWriteNode
1380
- child_nodes:
1381
- - name: target
1382
- type: node
1383
- - name: operator_loc
1384
- type: location
1385
- - name: operator
1386
- type: constant
1387
- - name: value
1388
- type: node
1389
- comment: |
1390
- Represents the use of an operator on a write.
1391
-
1392
- target += value
1393
- ^^^^^^^^^^^^^^^
1394
1714
  - name: OptionalParameterNode
1395
- child_nodes:
1396
- - name: constant_id
1715
+ fields:
1716
+ - name: name
1397
1717
  type: constant
1398
1718
  - name: name_loc
1399
1719
  type: location
@@ -1408,7 +1728,7 @@ nodes:
1408
1728
  ^^^^^
1409
1729
  end
1410
1730
  - name: OrNode
1411
- child_nodes:
1731
+ fields:
1412
1732
  - name: left
1413
1733
  type: node
1414
1734
  - name: right
@@ -1420,21 +1740,8 @@ nodes:
1420
1740
 
1421
1741
  left or right
1422
1742
  ^^^^^^^^^^^^^
1423
- - name: OrWriteNode
1424
- child_nodes:
1425
- - name: target
1426
- type: node
1427
- - name: value
1428
- type: node
1429
- - name: operator_loc
1430
- type: location
1431
- comment: |
1432
- Represents the use of the `||=` operator.
1433
-
1434
- target ||= value
1435
- ^^^^^^^^^^^^^^^^
1436
1743
  - name: ParametersNode
1437
- child_nodes:
1744
+ fields:
1438
1745
  - name: requireds
1439
1746
  type: node[]
1440
1747
  - name: optionals
@@ -1458,7 +1765,7 @@ nodes:
1458
1765
  ^^^^^^^
1459
1766
  end
1460
1767
  - name: ParenthesesNode
1461
- child_nodes:
1768
+ fields:
1462
1769
  - name: body
1463
1770
  type: node?
1464
1771
  - name: opening_loc
@@ -1472,7 +1779,7 @@ nodes:
1472
1779
  (10 + 34)
1473
1780
  ^^^^^^^^^
1474
1781
  - name: PinnedExpressionNode
1475
- child_nodes:
1782
+ fields:
1476
1783
  - name: expression
1477
1784
  type: node
1478
1785
  - name: operator_loc
@@ -1488,7 +1795,7 @@ nodes:
1488
1795
  foo in ^(bar)
1489
1796
  ^^^^^^
1490
1797
  - name: PinnedVariableNode
1491
- child_nodes:
1798
+ fields:
1492
1799
  - name: variable
1493
1800
  type: node
1494
1801
  - name: operator_loc
@@ -1500,7 +1807,7 @@ nodes:
1500
1807
  foo in ^bar
1501
1808
  ^^^^
1502
1809
  - name: PostExecutionNode
1503
- child_nodes:
1810
+ fields:
1504
1811
  - name: statements
1505
1812
  type: node?
1506
1813
  kind: StatementsNode
@@ -1516,7 +1823,7 @@ nodes:
1516
1823
  END { foo }
1517
1824
  ^^^^^^^^^^^
1518
1825
  - name: PreExecutionNode
1519
- child_nodes:
1826
+ fields:
1520
1827
  - name: statements
1521
1828
  type: node?
1522
1829
  kind: StatementsNode
@@ -1532,7 +1839,7 @@ nodes:
1532
1839
  BEGIN { foo }
1533
1840
  ^^^^^^^^^^^^^
1534
1841
  - name: ProgramNode
1535
- child_nodes:
1842
+ fields:
1536
1843
  - name: locals
1537
1844
  type: constant[]
1538
1845
  - name: statements
@@ -1540,7 +1847,7 @@ nodes:
1540
1847
  kind: StatementsNode
1541
1848
  comment: The top level node of any parse tree.
1542
1849
  - name: RangeNode
1543
- child_nodes:
1850
+ fields:
1544
1851
  - name: left
1545
1852
  type: node?
1546
1853
  - name: right
@@ -1559,7 +1866,7 @@ nodes:
1559
1866
  c if a =~ /left/ ... b =~ /right/
1560
1867
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1561
1868
  - name: RationalNode
1562
- child_nodes:
1869
+ fields:
1563
1870
  - name: numeric
1564
1871
  type: node
1565
1872
  comment: |
@@ -1574,7 +1881,7 @@ nodes:
1574
1881
  redo
1575
1882
  ^^^^
1576
1883
  - name: RegularExpressionNode
1577
- child_nodes:
1884
+ fields:
1578
1885
  - name: opening_loc
1579
1886
  type: location
1580
1887
  - name: content_loc
@@ -1592,7 +1899,7 @@ nodes:
1592
1899
  /foo/i
1593
1900
  ^^^^^^
1594
1901
  - name: RequiredDestructuredParameterNode
1595
- child_nodes:
1902
+ fields:
1596
1903
  - name: parameters
1597
1904
  type: node[]
1598
1905
  - name: opening_loc
@@ -1606,8 +1913,8 @@ nodes:
1606
1913
  ^^^^^^^^^^
1607
1914
  end
1608
1915
  - name: RequiredParameterNode
1609
- child_nodes:
1610
- - name: constant_id
1916
+ fields:
1917
+ - name: name
1611
1918
  type: constant
1612
1919
  comment: |
1613
1920
  Represents a required parameter to a method, block, or lambda definition.
@@ -1616,7 +1923,7 @@ nodes:
1616
1923
  ^
1617
1924
  end
1618
1925
  - name: RescueModifierNode
1619
- child_nodes:
1926
+ fields:
1620
1927
  - name: expression
1621
1928
  type: node
1622
1929
  - name: keyword_loc
@@ -1630,7 +1937,7 @@ nodes:
1630
1937
  foo rescue nil
1631
1938
  ^^^^^^^^^^^^^^
1632
1939
  - name: RescueNode
1633
- child_nodes:
1940
+ fields:
1634
1941
  - name: keyword_loc
1635
1942
  type: location
1636
1943
  - name: exceptions
@@ -1657,7 +1964,7 @@ nodes:
1657
1964
  `Foo, *splat, Bar` are in the `exceptions` field.
1658
1965
  `ex` is in the `exception` field.
1659
1966
  - name: RestParameterNode
1660
- child_nodes:
1967
+ fields:
1661
1968
  - name: operator_loc
1662
1969
  type: location
1663
1970
  - name: name_loc
@@ -1675,7 +1982,7 @@ nodes:
1675
1982
  retry
1676
1983
  ^^^^^
1677
1984
  - name: ReturnNode
1678
- child_nodes:
1985
+ fields:
1679
1986
  - name: keyword_loc
1680
1987
  type: location
1681
1988
  - name: arguments
@@ -1693,7 +2000,7 @@ nodes:
1693
2000
  self
1694
2001
  ^^^^
1695
2002
  - name: SingletonClassNode
1696
- child_nodes:
2003
+ fields:
1697
2004
  - name: locals
1698
2005
  type: constant[]
1699
2006
  - name: class_keyword_loc
@@ -1718,7 +2025,7 @@ nodes:
1718
2025
  __ENCODING__
1719
2026
  ^^^^^^^^^^^^
1720
2027
  - name: SourceFileNode
1721
- child_nodes:
2028
+ fields:
1722
2029
  - name: filepath
1723
2030
  type: string
1724
2031
  comment: |
@@ -1733,7 +2040,7 @@ nodes:
1733
2040
  __LINE__
1734
2041
  ^^^^^^^^
1735
2042
  - name: SplatNode
1736
- child_nodes:
2043
+ fields:
1737
2044
  - name: operator_loc
1738
2045
  type: location
1739
2046
  - name: expression
@@ -1744,7 +2051,7 @@ nodes:
1744
2051
  [*a]
1745
2052
  ^^
1746
2053
  - name: StatementsNode
1747
- child_nodes:
2054
+ fields:
1748
2055
  - name: body
1749
2056
  type: node[]
1750
2057
  comment: |
@@ -1753,7 +2060,7 @@ nodes:
1753
2060
  foo; bar; baz
1754
2061
  ^^^^^^^^^^^^^
1755
2062
  - name: StringConcatNode
1756
- child_nodes:
2063
+ fields:
1757
2064
  - name: left
1758
2065
  type: node
1759
2066
  - name: right
@@ -1764,7 +2071,7 @@ nodes:
1764
2071
  "foo" "bar"
1765
2072
  ^^^^^^^^^^^
1766
2073
  - name: StringNode
1767
- child_nodes:
2074
+ fields:
1768
2075
  - name: opening_loc
1769
2076
  type: location?
1770
2077
  - name: content_loc
@@ -1786,7 +2093,7 @@ nodes:
1786
2093
  "foo #{bar} baz"
1787
2094
  ^^^^ ^^^^
1788
2095
  - name: SuperNode
1789
- child_nodes:
2096
+ fields:
1790
2097
  - name: keyword_loc
1791
2098
  type: location
1792
2099
  - name: lparen_loc
@@ -1808,11 +2115,11 @@ nodes:
1808
2115
  super foo, bar
1809
2116
  ^^^^^^^^^^^^^^
1810
2117
  - name: SymbolNode
1811
- child_nodes:
2118
+ fields:
1812
2119
  - name: opening_loc
1813
2120
  type: location?
1814
2121
  - name: value_loc
1815
- type: location
2122
+ type: location?
1816
2123
  - name: closing_loc
1817
2124
  type: location?
1818
2125
  - name: unescaped
@@ -1832,7 +2139,7 @@ nodes:
1832
2139
  true
1833
2140
  ^^^^
1834
2141
  - name: UndefNode
1835
- child_nodes:
2142
+ fields:
1836
2143
  - name: names
1837
2144
  type: node[]
1838
2145
  - name: keyword_loc
@@ -1843,7 +2150,7 @@ nodes:
1843
2150
  undef :foo, :bar, :baz
1844
2151
  ^^^^^^^^^^^^^^^^^^^^^^
1845
2152
  - name: UnlessNode
1846
- child_nodes:
2153
+ fields:
1847
2154
  - name: keyword_loc
1848
2155
  type: location
1849
2156
  - name: predicate
@@ -1866,9 +2173,11 @@ nodes:
1866
2173
  unless foo then bar end
1867
2174
  ^^^^^^^^^^^^^^^^^^^^^^^
1868
2175
  - name: UntilNode
1869
- child_nodes:
2176
+ fields:
1870
2177
  - name: keyword_loc
1871
2178
  type: location
2179
+ - name: closing_loc
2180
+ type: location?
1872
2181
  - name: predicate
1873
2182
  type: node
1874
2183
  - name: statements
@@ -1887,7 +2196,7 @@ nodes:
1887
2196
  until foo do bar end
1888
2197
  ^^^^^^^^^^^^^^^^^^^^
1889
2198
  - name: WhenNode
1890
- child_nodes:
2199
+ fields:
1891
2200
  - name: keyword_loc
1892
2201
  type: location
1893
2202
  - name: conditions
@@ -1903,9 +2212,11 @@ nodes:
1903
2212
  ^^^^^^^^^
1904
2213
  end
1905
2214
  - name: WhileNode
1906
- child_nodes:
2215
+ fields:
1907
2216
  - name: keyword_loc
1908
2217
  type: location
2218
+ - name: closing_loc
2219
+ type: location?
1909
2220
  - name: predicate
1910
2221
  type: node
1911
2222
  - name: statements
@@ -1924,7 +2235,7 @@ nodes:
1924
2235
  while foo do bar end
1925
2236
  ^^^^^^^^^^^^^^^^^^^^
1926
2237
  - name: XStringNode
1927
- child_nodes:
2238
+ fields:
1928
2239
  - name: opening_loc
1929
2240
  type: location
1930
2241
  - name: content_loc
@@ -1939,7 +2250,7 @@ nodes:
1939
2250
  `foo`
1940
2251
  ^^^^^
1941
2252
  - name: YieldNode
1942
- child_nodes:
2253
+ fields:
1943
2254
  - name: keyword_loc
1944
2255
  type: location
1945
2256
  - name: lparen_loc