prism 0.30.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/README.md +3 -1
  4. data/config.yml +185 -126
  5. data/docs/serialization.md +3 -0
  6. data/ext/prism/api_node.c +2843 -2085
  7. data/ext/prism/extconf.rb +1 -1
  8. data/ext/prism/extension.c +35 -25
  9. data/ext/prism/extension.h +2 -2
  10. data/include/prism/ast.h +1048 -69
  11. data/include/prism/defines.h +9 -0
  12. data/include/prism/diagnostic.h +11 -3
  13. data/include/prism/options.h +55 -1
  14. data/include/prism/parser.h +27 -3
  15. data/include/prism/regexp.h +2 -1
  16. data/include/prism/util/pm_integer.h +6 -6
  17. data/include/prism/util/pm_newline_list.h +11 -0
  18. data/include/prism/util/pm_string.h +1 -0
  19. data/include/prism/version.h +3 -3
  20. data/lib/prism/desugar_compiler.rb +111 -74
  21. data/lib/prism/dispatcher.rb +2 -1
  22. data/lib/prism/dot_visitor.rb +21 -31
  23. data/lib/prism/dsl.rb +656 -471
  24. data/lib/prism/ffi.rb +3 -0
  25. data/lib/prism/inspect_visitor.rb +285 -57
  26. data/lib/prism/mutation_compiler.rb +5 -5
  27. data/lib/prism/node.rb +2282 -4754
  28. data/lib/prism/node_ext.rb +72 -11
  29. data/lib/prism/parse_result/errors.rb +65 -0
  30. data/lib/prism/parse_result/newlines.rb +28 -28
  31. data/lib/prism/parse_result.rb +25 -2
  32. data/lib/prism/reflection.rb +7 -7
  33. data/lib/prism/serialize.rb +468 -610
  34. data/lib/prism/translation/parser/compiler.rb +18 -18
  35. data/lib/prism/translation/parser/lexer.rb +1 -1
  36. data/lib/prism/translation/parser.rb +3 -3
  37. data/lib/prism/translation/ripper.rb +14 -14
  38. data/lib/prism/translation/ruby_parser.rb +43 -7
  39. data/prism.gemspec +3 -1
  40. data/rbi/prism/dsl.rbi +521 -0
  41. data/rbi/prism/node.rbi +1456 -5616
  42. data/rbi/prism.rbi +16 -16
  43. data/sig/prism/dsl.rbs +189 -305
  44. data/sig/prism/node.rbs +702 -603
  45. data/sig/prism/parse_result.rbs +2 -0
  46. data/src/diagnostic.c +22 -6
  47. data/src/node.c +277 -284
  48. data/src/options.c +18 -0
  49. data/src/prettyprint.c +99 -108
  50. data/src/prism.c +1282 -760
  51. data/src/regexp.c +72 -4
  52. data/src/serialize.c +165 -50
  53. data/src/token_type.c +2 -2
  54. data/src/util/pm_integer.c +14 -14
  55. data/src/util/pm_newline_list.c +29 -0
  56. data/src/util/pm_string.c +9 -5
  57. metadata +4 -2
data/config.yml CHANGED
@@ -81,8 +81,10 @@ errors:
81
81
  - ESCAPE_INVALID_META_REPEAT
82
82
  - ESCAPE_INVALID_UNICODE
83
83
  - ESCAPE_INVALID_UNICODE_CM_FLAGS
84
+ - ESCAPE_INVALID_UNICODE_LIST
84
85
  - ESCAPE_INVALID_UNICODE_LITERAL
85
86
  - ESCAPE_INVALID_UNICODE_LONG
87
+ - ESCAPE_INVALID_UNICODE_SHORT
86
88
  - ESCAPE_INVALID_UNICODE_TERM
87
89
  - EXPECT_ARGUMENT
88
90
  - EXPECT_EOL_AFTER_STATEMENT
@@ -208,6 +210,7 @@ errors:
208
210
  - PARAMETER_UNEXPECTED_FWD
209
211
  - PARAMETER_UNEXPECTED_NO_KW
210
212
  - PARAMETER_WILD_LOOSE_COMMA
213
+ - PATTERN_ARRAY_MULTIPLE_RESTS
211
214
  - PATTERN_CAPTURE_DUPLICATE
212
215
  - PATTERN_EXPRESSION_AFTER_BRACKET
213
216
  - PATTERN_EXPRESSION_AFTER_COMMA
@@ -219,6 +222,7 @@ errors:
219
222
  - PATTERN_EXPRESSION_AFTER_PIPE
220
223
  - PATTERN_EXPRESSION_AFTER_RANGE
221
224
  - PATTERN_EXPRESSION_AFTER_REST
225
+ - PATTERN_FIND_MISSING_INNER
222
226
  - PATTERN_HASH_IMPLICIT
223
227
  - PATTERN_HASH_KEY
224
228
  - PATTERN_HASH_KEY_DUPLICATE
@@ -261,11 +265,14 @@ errors:
261
265
  - TERNARY_COLON
262
266
  - TERNARY_EXPRESSION_FALSE
263
267
  - TERNARY_EXPRESSION_TRUE
268
+ - UNARY_DISALLOWED
264
269
  - UNARY_RECEIVER
265
270
  - UNDEF_ARGUMENT
266
271
  - UNEXPECTED_BLOCK_ARGUMENT
267
272
  - UNEXPECTED_INDEX_BLOCK
268
273
  - UNEXPECTED_INDEX_KEYWORDS
274
+ - UNEXPECTED_MULTI_WRITE
275
+ - UNEXPECTED_RANGE_OPERATOR
269
276
  - UNEXPECTED_SAFE_NAVIGATION
270
277
  - UNEXPECTED_TOKEN_CLOSE_CONTEXT
271
278
  - UNEXPECTED_TOKEN_IGNORE
@@ -293,10 +300,11 @@ warnings:
293
300
  - DUPLICATED_WHEN_CLAUSE
294
301
  - FLOAT_OUT_OF_RANGE
295
302
  - IGNORED_FROZEN_STRING_LITERAL
303
+ - INDENTATION_MISMATCH
296
304
  - INTEGER_IN_FLIP_FLOP
297
305
  - INVALID_CHARACTER
306
+ - INVALID_MAGIC_COMMENT_VALUE
298
307
  - INVALID_NUMBERED_REFERENCE
299
- - INVALID_SHAREABLE_CONSTANT_VALUE
300
308
  - KEYWORD_EOL
301
309
  - LITERAL_IN_CONDITION_DEFAULT
302
310
  - LITERAL_IN_CONDITION_VERBOSE
@@ -643,6 +651,8 @@ flags:
643
651
  comment: "if arguments contain keywords"
644
652
  - name: CONTAINS_KEYWORD_SPLAT
645
653
  comment: "if arguments contain keyword splat"
654
+ - name: CONTAINS_SPLAT
655
+ comment: "if arguments contain splat"
646
656
  comment: Flags for arguments nodes.
647
657
  - name: ArrayNodeFlags
648
658
  values:
@@ -730,11 +740,6 @@ flags:
730
740
  - name: FORCED_US_ASCII_ENCODING
731
741
  comment: "internal bytes forced the encoding to US-ASCII"
732
742
  comment: Flags for regular expression and match last line nodes.
733
- - name: ReturnNodeFlags
734
- values:
735
- - name: REDUNDANT
736
- comment: "a return statement that is redundant because it is the last statement in a method"
737
- comment: Flags for return nodes.
738
743
  - name: ShareableConstantNodeFlags
739
744
  values:
740
745
  - name: LITERAL
@@ -769,15 +774,25 @@ nodes:
769
774
  fields:
770
775
  - name: new_name
771
776
  type: node
777
+ kind:
778
+ - GlobalVariableReadNode
779
+ - BackReferenceReadNode
780
+ - NumberedReferenceReadNode
772
781
  comment: |
773
- Represents the new name of the global variable that can be used after aliasing. This can be either a global variable, a back reference, or a numbered reference.
782
+ Represents the new name of the global variable that can be used after aliasing.
774
783
 
775
784
  alias $foo $bar
776
785
  ^^^^
777
786
  - name: old_name
778
787
  type: node
788
+ kind:
789
+ - GlobalVariableReadNode
790
+ - BackReferenceReadNode
791
+ - NumberedReferenceReadNode
792
+ - SymbolNode # On parsing error of `alias $a b`
793
+ - MissingNode # On parsing error of `alias $a 42`
779
794
  comment: |
780
- Represents the old name of the global variable that could be used before aliasing. This can be either a global variable, a back reference, or a numbered reference.
795
+ Represents the old name of the global variable that can be used before aliasing.
781
796
 
782
797
  alias $foo $bar
783
798
  ^^^^
@@ -797,8 +812,16 @@ nodes:
797
812
  fields:
798
813
  - name: new_name
799
814
  type: node
815
+ kind:
816
+ - SymbolNode
817
+ - InterpolatedSymbolNode
800
818
  - name: old_name
801
819
  type: node
820
+ kind:
821
+ - SymbolNode
822
+ - InterpolatedSymbolNode
823
+ - GlobalVariableReadNode # On parsing error of `alias a $b`
824
+ - MissingNode # On parsing error of `alias a 42`
802
825
  - name: keyword_loc
803
826
  type: location
804
827
  comment: |
@@ -854,10 +877,8 @@ nodes:
854
877
  left and right
855
878
  ^^^^^^^^^^^^^^
856
879
  - name: ArgumentsNode
880
+ flags: ArgumentsNodeFlags
857
881
  fields:
858
- - name: flags
859
- type: flags
860
- kind: ArgumentsNodeFlags
861
882
  - name: arguments
862
883
  type: node[]
863
884
  comment: |
@@ -866,10 +887,8 @@ nodes:
866
887
  return foo, bar, baz
867
888
  ^^^^^^^^^^^^^
868
889
  - name: ArrayNode
890
+ flags: ArrayNodeFlags
869
891
  fields:
870
- - name: flags
871
- type: flags
872
- kind: ArrayNodeFlags
873
892
  - name: elements
874
893
  type: node[]
875
894
  comment: Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array.
@@ -1033,15 +1052,13 @@ nodes:
1033
1052
  - name: operator_loc
1034
1053
  type: location
1035
1054
  comment: |
1036
- Represents block method arguments.
1055
+ Represents a block argument using `&`.
1037
1056
 
1038
1057
  bar(&args)
1039
1058
  ^^^^^^^^^^
1040
1059
  - name: BlockLocalVariableNode
1060
+ flags: ParameterFlags
1041
1061
  fields:
1042
- - name: flags
1043
- type: flags
1044
- kind: ParameterFlags
1045
1062
  - name: name
1046
1063
  type: constant
1047
1064
  comment: |
@@ -1055,8 +1072,15 @@ nodes:
1055
1072
  type: constant[]
1056
1073
  - name: parameters
1057
1074
  type: node?
1075
+ kind:
1076
+ - BlockParametersNode
1077
+ - NumberedParametersNode
1078
+ - ItParametersNode
1058
1079
  - name: body
1059
1080
  type: node?
1081
+ kind:
1082
+ - StatementsNode
1083
+ - BeginNode
1060
1084
  - name: opening_loc
1061
1085
  type: location
1062
1086
  - name: closing_loc
@@ -1067,10 +1091,8 @@ nodes:
1067
1091
  [1, 2, 3].each { |i| puts x }
1068
1092
  ^^^^^^^^^^^^^^
1069
1093
  - name: BlockParameterNode
1094
+ flags: ParameterFlags
1070
1095
  fields:
1071
- - name: flags
1072
- type: flags
1073
- kind: ParameterFlags
1074
1096
  - name: name
1075
1097
  type: constant?
1076
1098
  - name: name_loc
@@ -1078,7 +1100,7 @@ nodes:
1078
1100
  - name: operator_loc
1079
1101
  type: location
1080
1102
  comment: |
1081
- Represents a block parameter to a method, block, or lambda definition.
1103
+ Represents a block parameter of a method, block, or lambda definition.
1082
1104
 
1083
1105
  def a(&b)
1084
1106
  ^^
@@ -1127,10 +1149,8 @@ nodes:
1127
1149
  break foo
1128
1150
  ^^^^^^^^^
1129
1151
  - name: CallAndWriteNode
1152
+ flags: CallNodeFlags
1130
1153
  fields:
1131
- - name: flags
1132
- type: flags
1133
- kind: CallNodeFlags
1134
1154
  - name: receiver
1135
1155
  type: node?
1136
1156
  - name: call_operator_loc
@@ -1151,10 +1171,8 @@ nodes:
1151
1171
  foo.bar &&= value
1152
1172
  ^^^^^^^^^^^^^^^^^
1153
1173
  - name: CallNode
1174
+ flags: CallNodeFlags
1154
1175
  fields:
1155
- - name: flags
1156
- type: flags
1157
- kind: CallNodeFlags
1158
1176
  - name: receiver
1159
1177
  type: node?
1160
1178
  comment: |
@@ -1204,10 +1222,8 @@ nodes:
1204
1222
  foo&.bar
1205
1223
  ^^^^^^^^
1206
1224
  - name: CallOperatorWriteNode
1225
+ flags: CallNodeFlags
1207
1226
  fields:
1208
- - name: flags
1209
- type: flags
1210
- kind: CallNodeFlags
1211
1227
  - name: receiver
1212
1228
  type: node?
1213
1229
  - name: call_operator_loc
@@ -1230,10 +1246,8 @@ nodes:
1230
1246
  foo.bar += baz
1231
1247
  ^^^^^^^^^^^^^^
1232
1248
  - name: CallOrWriteNode
1249
+ flags: CallNodeFlags
1233
1250
  fields:
1234
- - name: flags
1235
- type: flags
1236
- kind: CallNodeFlags
1237
1251
  - name: receiver
1238
1252
  type: node?
1239
1253
  - name: call_operator_loc
@@ -1254,10 +1268,8 @@ nodes:
1254
1268
  foo.bar ||= value
1255
1269
  ^^^^^^^^^^^^^^^^^
1256
1270
  - name: CallTargetNode
1271
+ flags: CallNodeFlags
1257
1272
  fields:
1258
- - name: flags
1259
- type: flags
1260
- kind: CallNodeFlags
1261
1273
  - name: receiver
1262
1274
  type: node
1263
1275
  - name: call_operator_loc
@@ -1298,7 +1310,7 @@ nodes:
1298
1310
  type: node?
1299
1311
  - name: conditions
1300
1312
  type: node[]
1301
- - name: consequent
1313
+ - name: else_clause
1302
1314
  type: node?
1303
1315
  kind: ElseNode
1304
1316
  - name: case_keyword_loc
@@ -1318,7 +1330,7 @@ nodes:
1318
1330
  type: node?
1319
1331
  - name: conditions
1320
1332
  type: node[]
1321
- - name: consequent
1333
+ - name: else_clause
1322
1334
  type: node?
1323
1335
  kind: ElseNode
1324
1336
  - name: case_keyword_loc
@@ -1852,10 +1864,8 @@ nodes:
1852
1864
  foo in Foo(*bar, baz, *qux)
1853
1865
  ^^^^^^^^^^^^^^^^^^^^
1854
1866
  - name: FlipFlopNode
1867
+ flags: RangeFlags
1855
1868
  fields:
1856
- - name: flags
1857
- type: flags
1858
- kind: RangeFlags
1859
1869
  - name: left
1860
1870
  type: node?
1861
1871
  - name: right
@@ -2177,8 +2187,11 @@ nodes:
2177
2187
  baz
2178
2188
  ^^^
2179
2189
  end
2180
- - name: consequent
2190
+ - name: subsequent
2181
2191
  type: node?
2192
+ kind:
2193
+ - ElseNode
2194
+ - IfNode
2182
2195
  comment: |
2183
2196
  Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
2184
2197
 
@@ -2274,10 +2287,8 @@ nodes:
2274
2287
  case a; in b then c end
2275
2288
  ^^^^^^^^^^^
2276
2289
  - name: IndexAndWriteNode
2290
+ flags: CallNodeFlags
2277
2291
  fields:
2278
- - name: flags
2279
- type: flags
2280
- kind: CallNodeFlags
2281
2292
  - name: receiver
2282
2293
  type: node?
2283
2294
  - name: call_operator_loc
@@ -2301,10 +2312,8 @@ nodes:
2301
2312
  foo.bar[baz] &&= value
2302
2313
  ^^^^^^^^^^^^^^^^^^^^^^
2303
2314
  - name: IndexOperatorWriteNode
2315
+ flags: CallNodeFlags
2304
2316
  fields:
2305
- - name: flags
2306
- type: flags
2307
- kind: CallNodeFlags
2308
2317
  - name: receiver
2309
2318
  type: node?
2310
2319
  - name: call_operator_loc
@@ -2330,10 +2339,8 @@ nodes:
2330
2339
  foo.bar[baz] += value
2331
2340
  ^^^^^^^^^^^^^^^^^^^^^
2332
2341
  - name: IndexOrWriteNode
2342
+ flags: CallNodeFlags
2333
2343
  fields:
2334
- - name: flags
2335
- type: flags
2336
- kind: CallNodeFlags
2337
2344
  - name: receiver
2338
2345
  type: node?
2339
2346
  - name: call_operator_loc
@@ -2357,10 +2364,8 @@ nodes:
2357
2364
  foo.bar[baz] ||= value
2358
2365
  ^^^^^^^^^^^^^^^^^^^^^^
2359
2366
  - name: IndexTargetNode
2367
+ flags: CallNodeFlags
2360
2368
  fields:
2361
- - name: flags
2362
- type: flags
2363
- kind: CallNodeFlags
2364
2369
  - name: receiver
2365
2370
  type: node
2366
2371
  - name: opening_loc
@@ -2496,10 +2501,8 @@ nodes:
2496
2501
  @foo = 1
2497
2502
  ^^^^^^^^
2498
2503
  - name: IntegerNode
2504
+ flags: IntegerBaseFlags
2499
2505
  fields:
2500
- - name: flags
2501
- type: flags
2502
- kind: IntegerBaseFlags
2503
2506
  - name: value
2504
2507
  type: integer
2505
2508
  comment: The value of the integer literal as a number.
@@ -2509,10 +2512,8 @@ nodes:
2509
2512
  1
2510
2513
  ^
2511
2514
  - name: InterpolatedMatchLastLineNode
2515
+ flags: RegularExpressionFlags
2512
2516
  fields:
2513
- - name: flags
2514
- type: flags
2515
- kind: RegularExpressionFlags
2516
2517
  - name: opening_loc
2517
2518
  type: location
2518
2519
  - name: parts
@@ -2530,10 +2531,8 @@ nodes:
2530
2531
  if /foo #{bar} baz/ then end
2531
2532
  ^^^^^^^^^^^^^^^^
2532
2533
  - name: InterpolatedRegularExpressionNode
2534
+ flags: RegularExpressionFlags
2533
2535
  fields:
2534
- - name: flags
2535
- type: flags
2536
- kind: RegularExpressionFlags
2537
2536
  - name: opening_loc
2538
2537
  type: location
2539
2538
  - name: parts
@@ -2551,10 +2550,8 @@ nodes:
2551
2550
  /foo #{bar} baz/
2552
2551
  ^^^^^^^^^^^^^^^^
2553
2552
  - name: InterpolatedStringNode
2553
+ flags: InterpolatedStringNodeFlags
2554
2554
  fields:
2555
- - name: flags
2556
- type: flags
2557
- kind: InterpolatedStringNodeFlags
2558
2555
  - name: opening_loc
2559
2556
  type: location?
2560
2557
  - name: parts
@@ -2621,10 +2618,8 @@ nodes:
2621
2618
  -> { it + it }
2622
2619
  ^^^^^^^^^^^^^^
2623
2620
  - name: KeywordHashNode
2621
+ flags: KeywordHashNodeFlags
2624
2622
  fields:
2625
- - name: flags
2626
- type: flags
2627
- kind: KeywordHashNodeFlags
2628
2623
  - name: elements
2629
2624
  type: node[]
2630
2625
  kind:
@@ -2636,10 +2631,8 @@ nodes:
2636
2631
  foo(a: b)
2637
2632
  ^^^^
2638
2633
  - name: KeywordRestParameterNode
2634
+ flags: ParameterFlags
2639
2635
  fields:
2640
- - name: flags
2641
- type: flags
2642
- kind: ParameterFlags
2643
2636
  - name: name
2644
2637
  type: constant?
2645
2638
  - name: name_loc
@@ -2819,10 +2812,8 @@ nodes:
2819
2812
  foo = 1
2820
2813
  ^^^^^^^
2821
2814
  - name: MatchLastLineNode
2815
+ flags: RegularExpressionFlags
2822
2816
  fields:
2823
- - name: flags
2824
- type: flags
2825
- kind: RegularExpressionFlags
2826
2817
  - name: opening_loc
2827
2818
  type: location
2828
2819
  - name: content_loc
@@ -2914,8 +2905,36 @@ nodes:
2914
2905
  - RequiredParameterNode
2915
2906
  - BackReferenceReadNode # On parsing error of `$',`
2916
2907
  - NumberedReferenceReadNode # On parsing error of `$1,`
2908
+ comment: |
2909
+ Represents the targets expressions before a splat node.
2910
+
2911
+ a, (b, c, *) = 1, 2, 3, 4, 5
2912
+ ^^^^
2913
+
2914
+ The splat node can be absent, in that case all target expressions are in the left field.
2915
+
2916
+ a, (b, c) = 1, 2, 3, 4, 5
2917
+ ^^^^
2917
2918
  - name: rest
2918
2919
  type: node?
2920
+ kind:
2921
+ - ImplicitRestNode
2922
+ - SplatNode
2923
+ comment: |
2924
+ Represents a splat node in the target expression.
2925
+
2926
+ a, (b, *c) = 1, 2, 3, 4
2927
+ ^^
2928
+
2929
+ The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
2930
+
2931
+ a, (b, *) = 1, 2, 3, 4
2932
+ ^
2933
+
2934
+ If the `*` is omitted, the field will containt an `ImplicitRestNode`
2935
+
2936
+ a, (b,) = 1, 2, 3, 4
2937
+ ^
2919
2938
  - name: rights
2920
2939
  type: node[]
2921
2940
  kind:
@@ -2930,15 +2949,35 @@ nodes:
2930
2949
  - MultiTargetNode
2931
2950
  - RequiredParameterNode
2932
2951
  - BackReferenceReadNode # On parsing error of `*,$'`
2952
+ comment: |
2953
+ Represents the targets expressions after a splat node.
2954
+
2955
+ a, (*, b, c) = 1, 2, 3, 4, 5
2956
+ ^^^^
2933
2957
  - name: lparen_loc
2934
2958
  type: location?
2959
+ comment: |
2960
+ The location of the opening parenthesis.
2961
+
2962
+ a, (b, c) = 1, 2, 3
2963
+ ^
2935
2964
  - name: rparen_loc
2936
2965
  type: location?
2966
+ comment: |
2967
+ The location of the closing parenthesis.
2968
+
2969
+ a, (b, c) = 1, 2, 3
2970
+ ^
2937
2971
  comment: |
2938
2972
  Represents a multi-target expression.
2939
2973
 
2940
2974
  a, (b, c) = 1, 2, 3
2941
2975
  ^^^^^^
2976
+
2977
+ This can be a part of `MultiWriteNode` as above, or the target of a `for` loop
2978
+
2979
+ for a, b in [[1, 2], [3, 4]]
2980
+ ^^^^
2942
2981
  - name: MultiWriteNode
2943
2982
  fields:
2944
2983
  - name: lefts
@@ -2953,8 +2992,36 @@ nodes:
2953
2992
  - CallTargetNode
2954
2993
  - IndexTargetNode
2955
2994
  - MultiTargetNode
2995
+ comment: |
2996
+ Represents the targets expressions before a splat node.
2997
+
2998
+ a, b, * = 1, 2, 3, 4, 5
2999
+ ^^^^
3000
+
3001
+ The splat node can be absent, in that case all target expressions are in the left field.
3002
+
3003
+ a, b, c = 1, 2, 3, 4, 5
3004
+ ^^^^^^^
2956
3005
  - name: rest
2957
3006
  type: node?
3007
+ kind:
3008
+ - ImplicitRestNode
3009
+ - SplatNode
3010
+ comment: |
3011
+ Represents a splat node in the target expression.
3012
+
3013
+ a, b, *c = 1, 2, 3, 4
3014
+ ^^
3015
+
3016
+ The variable can be empty, this results in a `SplatNode` with a `nil` expression field.
3017
+
3018
+ a, b, * = 1, 2, 3, 4
3019
+ ^
3020
+
3021
+ If the `*` is omitted, the field will containt an `ImplicitRestNode`
3022
+
3023
+ a, b, = 1, 2, 3, 4
3024
+ ^
2958
3025
  - name: rights
2959
3026
  type: node[]
2960
3027
  kind:
@@ -2967,14 +3034,39 @@ nodes:
2967
3034
  - CallTargetNode
2968
3035
  - IndexTargetNode
2969
3036
  - MultiTargetNode
3037
+ comment: |
3038
+ Represents the targets expressions after a splat node.
3039
+
3040
+ a, *, b, c = 1, 2, 3, 4, 5
3041
+ ^^^^
2970
3042
  - name: lparen_loc
2971
3043
  type: location?
3044
+ comment: |
3045
+ The location of the opening parenthesis.
3046
+
3047
+ (a, b, c) = 1, 2, 3
3048
+ ^
2972
3049
  - name: rparen_loc
2973
3050
  type: location?
3051
+ comment: |
3052
+ The location of the closing parenthesis.
3053
+
3054
+ (a, b, c) = 1, 2, 3
3055
+ ^
2974
3056
  - name: operator_loc
2975
3057
  type: location
3058
+ comment: |
3059
+ The location of the operator.
3060
+
3061
+ a, b, c = 1, 2, 3
3062
+ ^
2976
3063
  - name: value
2977
3064
  type: node
3065
+ comment: |
3066
+ The value to write to the targets. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
3067
+
3068
+ a, b, c = 1, 2, 3
3069
+ ^^^^^^^
2978
3070
  comment: |
2979
3071
  Represents a write to a multi-target expression.
2980
3072
 
@@ -3037,10 +3129,8 @@ nodes:
3037
3129
  $1
3038
3130
  ^^
3039
3131
  - name: OptionalKeywordParameterNode
3132
+ flags: ParameterFlags
3040
3133
  fields:
3041
- - name: flags
3042
- type: flags
3043
- kind: ParameterFlags
3044
3134
  - name: name
3045
3135
  type: constant
3046
3136
  - name: name_loc
@@ -3054,10 +3144,8 @@ nodes:
3054
3144
  ^^^^
3055
3145
  end
3056
3146
  - name: OptionalParameterNode
3147
+ flags: ParameterFlags
3057
3148
  fields:
3058
- - name: flags
3059
- type: flags
3060
- kind: ParameterFlags
3061
3149
  - name: name
3062
3150
  type: constant
3063
3151
  - name: name_loc
@@ -3232,10 +3320,8 @@ nodes:
3232
3320
  kind: StatementsNode
3233
3321
  comment: The top level node of any parse tree.
3234
3322
  - name: RangeNode
3323
+ flags: RangeFlags
3235
3324
  fields:
3236
- - name: flags
3237
- type: flags
3238
- kind: RangeFlags
3239
3325
  - name: left
3240
3326
  type: node?
3241
3327
  comment: |
@@ -3270,10 +3356,8 @@ nodes:
3270
3356
  c if a =~ /left/ ... b =~ /right/
3271
3357
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3272
3358
  - name: RationalNode
3359
+ flags: IntegerBaseFlags
3273
3360
  fields:
3274
- - name: flags
3275
- type: flags
3276
- kind: IntegerBaseFlags
3277
3361
  - name: numerator
3278
3362
  type: integer
3279
3363
  comment: |
@@ -3298,10 +3382,8 @@ nodes:
3298
3382
  redo
3299
3383
  ^^^^
3300
3384
  - name: RegularExpressionNode
3385
+ flags: RegularExpressionFlags
3301
3386
  fields:
3302
- - name: flags
3303
- type: flags
3304
- kind: RegularExpressionFlags
3305
3387
  - name: opening_loc
3306
3388
  type: location
3307
3389
  - name: content_loc
@@ -3316,10 +3398,8 @@ nodes:
3316
3398
  /foo/i
3317
3399
  ^^^^^^
3318
3400
  - name: RequiredKeywordParameterNode
3401
+ flags: ParameterFlags
3319
3402
  fields:
3320
- - name: flags
3321
- type: flags
3322
- kind: ParameterFlags
3323
3403
  - name: name
3324
3404
  type: constant
3325
3405
  - name: name_loc
@@ -3331,10 +3411,8 @@ nodes:
3331
3411
  ^^
3332
3412
  end
3333
3413
  - name: RequiredParameterNode
3414
+ flags: ParameterFlags
3334
3415
  fields:
3335
- - name: flags
3336
- type: flags
3337
- kind: ParameterFlags
3338
3416
  - name: name
3339
3417
  type: constant
3340
3418
  comment: |
@@ -3370,7 +3448,7 @@ nodes:
3370
3448
  - name: statements
3371
3449
  type: node?
3372
3450
  kind: StatementsNode
3373
- - name: consequent
3451
+ - name: subsequent
3374
3452
  type: node?
3375
3453
  kind: RescueNode
3376
3454
  comment: |
@@ -3384,10 +3462,8 @@ nodes:
3384
3462
 
3385
3463
  `Foo, *splat, Bar` are in the `exceptions` field. `ex` is in the `exception` field.
3386
3464
  - name: RestParameterNode
3465
+ flags: ParameterFlags
3387
3466
  fields:
3388
- - name: flags
3389
- type: flags
3390
- kind: ParameterFlags
3391
3467
  - name: name
3392
3468
  type: constant?
3393
3469
  - name: name_loc
@@ -3408,9 +3484,6 @@ nodes:
3408
3484
  ^^^^^
3409
3485
  - name: ReturnNode
3410
3486
  fields:
3411
- - name: flags
3412
- type: flags
3413
- kind: ReturnNodeFlags
3414
3487
  - name: keyword_loc
3415
3488
  type: location
3416
3489
  - name: arguments
@@ -3428,10 +3501,8 @@ nodes:
3428
3501
  self
3429
3502
  ^^^^
3430
3503
  - name: ShareableConstantNode
3504
+ flags: ShareableConstantNodeFlags
3431
3505
  fields:
3432
- - name: flags
3433
- type: flags
3434
- kind: ShareableConstantNodeFlags
3435
3506
  - name: write
3436
3507
  type: node
3437
3508
  kind:
@@ -3476,10 +3547,8 @@ nodes:
3476
3547
  __ENCODING__
3477
3548
  ^^^^^^^^^^^^
3478
3549
  - name: SourceFileNode
3550
+ flags: StringFlags
3479
3551
  fields:
3480
- - name: flags
3481
- type: flags
3482
- kind: StringFlags
3483
3552
  - name: filepath
3484
3553
  type: string
3485
3554
  comment: Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism::parse*` APIs.
@@ -3515,10 +3584,8 @@ nodes:
3515
3584
  foo; bar; baz
3516
3585
  ^^^^^^^^^^^^^
3517
3586
  - name: StringNode
3587
+ flags: StringFlags
3518
3588
  fields:
3519
- - name: flags
3520
- type: flags
3521
- kind: StringFlags
3522
3589
  - name: opening_loc
3523
3590
  type: location?
3524
3591
  - name: content_loc
@@ -3560,10 +3627,8 @@ nodes:
3560
3627
  super foo, bar
3561
3628
  ^^^^^^^^^^^^^^
3562
3629
  - name: SymbolNode
3630
+ flags: SymbolFlags
3563
3631
  fields:
3564
- - name: flags
3565
- type: flags
3566
- kind: SymbolFlags
3567
3632
  - name: opening_loc
3568
3633
  type: location?
3569
3634
  - name: value_loc
@@ -3638,7 +3703,7 @@ nodes:
3638
3703
 
3639
3704
  unless cond then bar end
3640
3705
  ^^^
3641
- - name: consequent
3706
+ - name: else_clause
3642
3707
  type: node?
3643
3708
  kind: ElseNode
3644
3709
  comment: |
@@ -3663,10 +3728,8 @@ nodes:
3663
3728
  unless foo then bar end
3664
3729
  ^^^^^^^^^^^^^^^^^^^^^^^
3665
3730
  - name: UntilNode
3731
+ flags: LoopFlags
3666
3732
  fields:
3667
- - name: flags
3668
- type: flags
3669
- kind: LoopFlags
3670
3733
  - name: keyword_loc
3671
3734
  type: location
3672
3735
  - name: closing_loc
@@ -3704,10 +3767,8 @@ nodes:
3704
3767
  ^^^^^^^^^
3705
3768
  end
3706
3769
  - name: WhileNode
3770
+ flags: LoopFlags
3707
3771
  fields:
3708
- - name: flags
3709
- type: flags
3710
- kind: LoopFlags
3711
3772
  - name: keyword_loc
3712
3773
  type: location
3713
3774
  - name: closing_loc
@@ -3727,10 +3788,8 @@ nodes:
3727
3788
  while foo do bar end
3728
3789
  ^^^^^^^^^^^^^^^^^^^^
3729
3790
  - name: XStringNode
3791
+ flags: EncodingFlags
3730
3792
  fields:
3731
- - name: flags
3732
- type: flags
3733
- kind: EncodingFlags
3734
3793
  - name: opening_loc
3735
3794
  type: location
3736
3795
  - name: content_loc