prism 0.28.0 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -1
- data/CONTRIBUTING.md +0 -4
- data/README.md +1 -0
- data/config.yml +95 -26
- data/docs/fuzzing.md +1 -1
- data/docs/ripper_translation.md +22 -0
- data/ext/prism/api_node.c +70 -52
- data/ext/prism/extconf.rb +27 -23
- data/ext/prism/extension.c +107 -372
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +170 -102
- data/include/prism/diagnostic.h +18 -3
- data/include/prism/node.h +0 -21
- data/include/prism/parser.h +23 -25
- data/include/prism/regexp.h +17 -8
- data/include/prism/static_literals.h +3 -2
- data/include/prism/util/pm_char.h +1 -2
- data/include/prism/util/pm_constant_pool.h +0 -8
- data/include/prism/util/pm_integer.h +16 -9
- data/include/prism/util/pm_string.h +0 -8
- data/include/prism/version.h +2 -2
- data/include/prism.h +0 -11
- data/lib/prism/compiler.rb +3 -0
- data/lib/prism/desugar_compiler.rb +4 -4
- data/lib/prism/dispatcher.rb +14 -0
- data/lib/prism/dot_visitor.rb +54 -35
- data/lib/prism/dsl.rb +23 -18
- data/lib/prism/ffi.rb +25 -4
- data/lib/prism/inspect_visitor.rb +26 -24
- data/lib/prism/mutation_compiler.rb +6 -1
- data/lib/prism/node.rb +314 -389
- data/lib/prism/node_ext.rb +175 -17
- data/lib/prism/parse_result/comments.rb +1 -8
- data/lib/prism/parse_result/newlines.rb +102 -12
- data/lib/prism/parse_result.rb +17 -0
- data/lib/prism/reflection.rb +11 -9
- data/lib/prism/serialize.rb +91 -68
- data/lib/prism/translation/parser/compiler.rb +288 -138
- data/lib/prism/translation/parser.rb +7 -2
- data/lib/prism/translation/ripper.rb +24 -22
- data/lib/prism/translation/ruby_parser.rb +32 -14
- data/lib/prism/visitor.rb +3 -0
- data/lib/prism.rb +0 -4
- data/prism.gemspec +2 -4
- data/rbi/prism/node.rbi +114 -57
- data/rbi/prism/node_ext.rbi +5 -0
- data/rbi/prism/parse_result.rbi +1 -1
- data/rbi/prism/visitor.rbi +3 -0
- data/rbi/prism.rbi +6 -0
- data/sig/prism/dsl.rbs +13 -10
- data/sig/prism/lex_compat.rbs +10 -0
- data/sig/prism/mutation_compiler.rbs +1 -0
- data/sig/prism/node.rbs +72 -48
- data/sig/prism/node_ext.rbs +4 -0
- data/sig/prism/visitor.rbs +1 -0
- data/sig/prism.rbs +21 -0
- data/src/diagnostic.c +56 -27
- data/src/node.c +432 -1690
- data/src/prettyprint.c +97 -54
- data/src/prism.c +1286 -1196
- data/src/regexp.c +133 -68
- data/src/serialize.c +22 -17
- data/src/static_literals.c +63 -84
- data/src/token_type.c +4 -4
- data/src/util/pm_constant_pool.c +0 -8
- data/src/util/pm_integer.c +39 -11
- data/src/util/pm_string.c +0 -12
- data/src/util/pm_strpbrk.c +32 -6
- metadata +3 -5
- data/include/prism/util/pm_string_list.h +0 -44
- data/lib/prism/debug.rb +0 -249
- data/src/util/pm_string_list.c +0 -28
data/lib/prism/serialize.rb
CHANGED
@@ -18,7 +18,7 @@ module Prism
|
|
18
18
|
|
19
19
|
# The minor version of prism that we are expecting to find in the serialized
|
20
20
|
# strings.
|
21
|
-
MINOR_VERSION =
|
21
|
+
MINOR_VERSION = 30
|
22
22
|
|
23
23
|
# The patch version of prism that we are expecting to find in the serialized
|
24
24
|
# strings.
|
@@ -133,13 +133,16 @@ module Prism
|
|
133
133
|
:argument_bare_hash,
|
134
134
|
:argument_block_forwarding,
|
135
135
|
:argument_block_multi,
|
136
|
+
:argument_conflict_ampersand,
|
137
|
+
:argument_conflict_star,
|
138
|
+
:argument_conflict_star_star,
|
136
139
|
:argument_formal_class,
|
137
140
|
:argument_formal_constant,
|
138
141
|
:argument_formal_global,
|
139
142
|
:argument_formal_ivar,
|
140
143
|
:argument_forwarding_unbound,
|
141
144
|
:argument_in,
|
142
|
-
:
|
145
|
+
:argument_no_forwarding_ampersand,
|
143
146
|
:argument_no_forwarding_ellipses,
|
144
147
|
:argument_no_forwarding_star,
|
145
148
|
:argument_no_forwarding_star_star,
|
@@ -221,6 +224,7 @@ module Prism
|
|
221
224
|
:expect_expression_after_splat_hash,
|
222
225
|
:expect_expression_after_star,
|
223
226
|
:expect_ident_req_parameter,
|
227
|
+
:expect_in_delimiter,
|
224
228
|
:expect_lparen_req_parameter,
|
225
229
|
:expect_message,
|
226
230
|
:expect_rbracket,
|
@@ -236,6 +240,7 @@ module Prism
|
|
236
240
|
:expression_not_writable_file,
|
237
241
|
:expression_not_writable_line,
|
238
242
|
:expression_not_writable_nil,
|
243
|
+
:expression_not_writable_numbered,
|
239
244
|
:expression_not_writable_self,
|
240
245
|
:expression_not_writable_true,
|
241
246
|
:float_parse,
|
@@ -260,6 +265,7 @@ module Prism
|
|
260
265
|
:invalid_block_exit,
|
261
266
|
:invalid_character,
|
262
267
|
:invalid_encoding_magic_comment,
|
268
|
+
:invalid_escape_character,
|
263
269
|
:invalid_float_exponent,
|
264
270
|
:invalid_local_variable_read,
|
265
271
|
:invalid_local_variable_write,
|
@@ -268,11 +274,13 @@ module Prism
|
|
268
274
|
:invalid_multibyte_escape,
|
269
275
|
:invalid_number_binary,
|
270
276
|
:invalid_number_decimal,
|
277
|
+
:invalid_number_fraction,
|
271
278
|
:invalid_number_hexadecimal,
|
272
279
|
:invalid_number_octal,
|
273
280
|
:invalid_number_underscore_inner,
|
274
281
|
:invalid_number_underscore_trailing,
|
275
282
|
:invalid_percent,
|
283
|
+
:invalid_percent_eof,
|
276
284
|
:invalid_printable_character,
|
277
285
|
:invalid_retry_after_else,
|
278
286
|
:invalid_retry_after_ensure,
|
@@ -304,15 +312,17 @@ module Prism
|
|
304
312
|
:no_local_variable,
|
305
313
|
:not_expression,
|
306
314
|
:number_literal_underscore,
|
315
|
+
:numbered_parameter_inner_block,
|
307
316
|
:numbered_parameter_it,
|
308
317
|
:numbered_parameter_ordinary,
|
309
|
-
:
|
318
|
+
:numbered_parameter_outer_block,
|
310
319
|
:operator_multi_assign,
|
311
320
|
:operator_write_arguments,
|
312
321
|
:operator_write_block,
|
313
322
|
:parameter_assoc_splat_multi,
|
314
323
|
:parameter_block_multi,
|
315
324
|
:parameter_circular,
|
325
|
+
:parameter_forwarding_after_rest,
|
316
326
|
:parameter_method_name,
|
317
327
|
:parameter_name_duplicated,
|
318
328
|
:parameter_no_default,
|
@@ -322,8 +332,8 @@ module Prism
|
|
322
332
|
:parameter_splat_multi,
|
323
333
|
:parameter_star,
|
324
334
|
:parameter_unexpected_fwd,
|
325
|
-
:parameter_wild_loose_comma,
|
326
335
|
:parameter_unexpected_no_kw,
|
336
|
+
:parameter_wild_loose_comma,
|
327
337
|
:pattern_capture_duplicate,
|
328
338
|
:pattern_expression_after_bracket,
|
329
339
|
:pattern_expression_after_comma,
|
@@ -335,8 +345,10 @@ module Prism
|
|
335
345
|
:pattern_expression_after_pipe,
|
336
346
|
:pattern_expression_after_range,
|
337
347
|
:pattern_expression_after_rest,
|
348
|
+
:pattern_hash_implicit,
|
338
349
|
:pattern_hash_key,
|
339
350
|
:pattern_hash_key_duplicate,
|
351
|
+
:pattern_hash_key_interpolated,
|
340
352
|
:pattern_hash_key_label,
|
341
353
|
:pattern_hash_key_locals,
|
342
354
|
:pattern_ident_after_hrocket,
|
@@ -350,6 +362,7 @@ module Prism
|
|
350
362
|
:regexp_incompat_char_encoding,
|
351
363
|
:regexp_invalid_unicode_range,
|
352
364
|
:regexp_non_escaped_mbc,
|
365
|
+
:regexp_parse_error,
|
353
366
|
:regexp_term,
|
354
367
|
:regexp_unknown_options,
|
355
368
|
:regexp_utf8_char_non_utf8_regexp,
|
@@ -389,6 +402,7 @@ module Prism
|
|
389
402
|
:write_target_readonly,
|
390
403
|
:write_target_unexpected,
|
391
404
|
:xstring_term,
|
405
|
+
:ambiguous_binary_operator,
|
392
406
|
:ambiguous_first_argument_minus,
|
393
407
|
:ambiguous_first_argument_plus,
|
394
408
|
:ambiguous_prefix_ampersand,
|
@@ -411,6 +425,7 @@ module Prism
|
|
411
425
|
:keyword_eol,
|
412
426
|
:literal_in_condition_default,
|
413
427
|
:literal_in_condition_verbose,
|
428
|
+
:shareable_constant_value_line,
|
414
429
|
:shebang_carriage_return,
|
415
430
|
:unexpected_carriage_return,
|
416
431
|
:unreachable_statement,
|
@@ -881,192 +896,195 @@ module Prism
|
|
881
896
|
InterpolatedXStringNode.new(
|
882
897
|
source, load_location, Array.new(load_varuint) { load_node }, load_location, location)
|
883
898
|
when 88 then
|
884
|
-
|
899
|
+
ItLocalVariableReadNode.new(
|
885
900
|
source, location)
|
886
901
|
when 89 then
|
902
|
+
ItParametersNode.new(
|
903
|
+
source, location)
|
904
|
+
when 90 then
|
887
905
|
KeywordHashNode.new(
|
888
906
|
source, load_varuint, Array.new(load_varuint) { load_node }, location)
|
889
|
-
when
|
907
|
+
when 91 then
|
890
908
|
KeywordRestParameterNode.new(
|
891
909
|
source, load_varuint, load_optional_constant, load_optional_location, load_location, location)
|
892
|
-
when
|
910
|
+
when 92 then
|
893
911
|
LambdaNode.new(
|
894
912
|
source, Array.new(load_varuint) { load_required_constant }, load_location, load_location, load_location, load_optional_node, load_optional_node, location)
|
895
|
-
when
|
913
|
+
when 93 then
|
896
914
|
LocalVariableAndWriteNode.new(
|
897
915
|
source, load_location, load_location, load_node, load_required_constant, load_varuint, location)
|
898
|
-
when
|
916
|
+
when 94 then
|
899
917
|
LocalVariableOperatorWriteNode.new(
|
900
918
|
source, load_location, load_location, load_node, load_required_constant, load_required_constant, load_varuint, location)
|
901
|
-
when
|
919
|
+
when 95 then
|
902
920
|
LocalVariableOrWriteNode.new(
|
903
921
|
source, load_location, load_location, load_node, load_required_constant, load_varuint, location)
|
904
|
-
when
|
922
|
+
when 96 then
|
905
923
|
LocalVariableReadNode.new(
|
906
924
|
source, load_required_constant, load_varuint, location)
|
907
|
-
when
|
925
|
+
when 97 then
|
908
926
|
LocalVariableTargetNode.new(
|
909
927
|
source, load_required_constant, load_varuint, location)
|
910
|
-
when
|
928
|
+
when 98 then
|
911
929
|
LocalVariableWriteNode.new(
|
912
930
|
source, load_required_constant, load_varuint, load_location, load_node, load_location, location)
|
913
|
-
when
|
931
|
+
when 99 then
|
914
932
|
MatchLastLineNode.new(
|
915
933
|
source, load_varuint, load_location, load_location, load_location, load_string, location)
|
916
|
-
when
|
934
|
+
when 100 then
|
917
935
|
MatchPredicateNode.new(
|
918
936
|
source, load_node, load_node, load_location, location)
|
919
|
-
when
|
937
|
+
when 101 then
|
920
938
|
MatchRequiredNode.new(
|
921
939
|
source, load_node, load_node, load_location, location)
|
922
|
-
when
|
940
|
+
when 102 then
|
923
941
|
MatchWriteNode.new(
|
924
942
|
source, load_node, Array.new(load_varuint) { load_node }, location)
|
925
|
-
when
|
943
|
+
when 103 then
|
926
944
|
MissingNode.new(
|
927
945
|
source, location)
|
928
|
-
when
|
946
|
+
when 104 then
|
929
947
|
ModuleNode.new(
|
930
948
|
source, Array.new(load_varuint) { load_required_constant }, load_location, load_node, load_optional_node, load_location, load_required_constant, location)
|
931
|
-
when
|
949
|
+
when 105 then
|
932
950
|
MultiTargetNode.new(
|
933
951
|
source, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_location, location)
|
934
|
-
when
|
952
|
+
when 106 then
|
935
953
|
MultiWriteNode.new(
|
936
954
|
source, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_location, load_location, load_node, location)
|
937
|
-
when
|
955
|
+
when 107 then
|
938
956
|
NextNode.new(
|
939
957
|
source, load_optional_node, load_location, location)
|
940
|
-
when
|
958
|
+
when 108 then
|
941
959
|
NilNode.new(
|
942
960
|
source, location)
|
943
|
-
when
|
961
|
+
when 109 then
|
944
962
|
NoKeywordsParameterNode.new(
|
945
963
|
source, load_location, load_location, location)
|
946
|
-
when
|
964
|
+
when 110 then
|
947
965
|
NumberedParametersNode.new(
|
948
966
|
source, io.getbyte, location)
|
949
|
-
when
|
967
|
+
when 111 then
|
950
968
|
NumberedReferenceReadNode.new(
|
951
969
|
source, load_varuint, location)
|
952
|
-
when
|
970
|
+
when 112 then
|
953
971
|
OptionalKeywordParameterNode.new(
|
954
972
|
source, load_varuint, load_required_constant, load_location, load_node, location)
|
955
|
-
when
|
973
|
+
when 113 then
|
956
974
|
OptionalParameterNode.new(
|
957
975
|
source, load_varuint, load_required_constant, load_location, load_location, load_node, location)
|
958
|
-
when
|
976
|
+
when 114 then
|
959
977
|
OrNode.new(
|
960
978
|
source, load_node, load_node, load_location, location)
|
961
|
-
when
|
979
|
+
when 115 then
|
962
980
|
ParametersNode.new(
|
963
981
|
source, Array.new(load_varuint) { load_node }, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, Array.new(load_varuint) { load_node }, load_optional_node, load_optional_node, location)
|
964
|
-
when
|
982
|
+
when 116 then
|
965
983
|
ParenthesesNode.new(
|
966
984
|
source, load_optional_node, load_location, load_location, location)
|
967
|
-
when
|
985
|
+
when 117 then
|
968
986
|
PinnedExpressionNode.new(
|
969
987
|
source, load_node, load_location, load_location, load_location, location)
|
970
|
-
when
|
988
|
+
when 118 then
|
971
989
|
PinnedVariableNode.new(
|
972
990
|
source, load_node, load_location, location)
|
973
|
-
when
|
991
|
+
when 119 then
|
974
992
|
PostExecutionNode.new(
|
975
993
|
source, load_optional_node, load_location, load_location, load_location, location)
|
976
|
-
when
|
994
|
+
when 120 then
|
977
995
|
PreExecutionNode.new(
|
978
996
|
source, load_optional_node, load_location, load_location, load_location, location)
|
979
|
-
when
|
997
|
+
when 121 then
|
980
998
|
ProgramNode.new(
|
981
999
|
source, Array.new(load_varuint) { load_required_constant }, load_node, location)
|
982
|
-
when
|
1000
|
+
when 122 then
|
983
1001
|
RangeNode.new(
|
984
1002
|
source, load_varuint, load_optional_node, load_optional_node, load_location, location)
|
985
|
-
when 122 then
|
986
|
-
RationalNode.new(
|
987
|
-
source, load_node, location)
|
988
1003
|
when 123 then
|
1004
|
+
RationalNode.new(
|
1005
|
+
source, load_varuint, load_integer, load_integer, location)
|
1006
|
+
when 124 then
|
989
1007
|
RedoNode.new(
|
990
1008
|
source, location)
|
991
|
-
when
|
1009
|
+
when 125 then
|
992
1010
|
RegularExpressionNode.new(
|
993
1011
|
source, load_varuint, load_location, load_location, load_location, load_string, location)
|
994
|
-
when
|
1012
|
+
when 126 then
|
995
1013
|
RequiredKeywordParameterNode.new(
|
996
1014
|
source, load_varuint, load_required_constant, load_location, location)
|
997
|
-
when
|
1015
|
+
when 127 then
|
998
1016
|
RequiredParameterNode.new(
|
999
1017
|
source, load_varuint, load_required_constant, location)
|
1000
|
-
when
|
1018
|
+
when 128 then
|
1001
1019
|
RescueModifierNode.new(
|
1002
1020
|
source, load_node, load_location, load_node, location)
|
1003
|
-
when
|
1021
|
+
when 129 then
|
1004
1022
|
RescueNode.new(
|
1005
1023
|
source, load_location, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
|
1006
|
-
when
|
1024
|
+
when 130 then
|
1007
1025
|
RestParameterNode.new(
|
1008
1026
|
source, load_varuint, load_optional_constant, load_optional_location, load_location, location)
|
1009
|
-
when
|
1027
|
+
when 131 then
|
1010
1028
|
RetryNode.new(
|
1011
1029
|
source, location)
|
1012
|
-
when
|
1030
|
+
when 132 then
|
1013
1031
|
ReturnNode.new(
|
1014
1032
|
source, load_varuint, load_location, load_optional_node, location)
|
1015
|
-
when
|
1033
|
+
when 133 then
|
1016
1034
|
SelfNode.new(
|
1017
1035
|
source, location)
|
1018
|
-
when
|
1036
|
+
when 134 then
|
1019
1037
|
ShareableConstantNode.new(
|
1020
1038
|
source, load_varuint, load_node, location)
|
1021
|
-
when
|
1039
|
+
when 135 then
|
1022
1040
|
SingletonClassNode.new(
|
1023
1041
|
source, Array.new(load_varuint) { load_required_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
|
1024
|
-
when
|
1042
|
+
when 136 then
|
1025
1043
|
SourceEncodingNode.new(
|
1026
1044
|
source, location)
|
1027
|
-
when
|
1045
|
+
when 137 then
|
1028
1046
|
SourceFileNode.new(
|
1029
1047
|
source, load_varuint, load_string, location)
|
1030
|
-
when
|
1048
|
+
when 138 then
|
1031
1049
|
SourceLineNode.new(
|
1032
1050
|
source, location)
|
1033
|
-
when
|
1051
|
+
when 139 then
|
1034
1052
|
SplatNode.new(
|
1035
1053
|
source, load_location, load_optional_node, location)
|
1036
|
-
when
|
1054
|
+
when 140 then
|
1037
1055
|
StatementsNode.new(
|
1038
1056
|
source, Array.new(load_varuint) { load_node }, location)
|
1039
|
-
when
|
1057
|
+
when 141 then
|
1040
1058
|
StringNode.new(
|
1041
1059
|
source, load_varuint, load_optional_location, load_location, load_optional_location, load_string, location)
|
1042
|
-
when
|
1060
|
+
when 142 then
|
1043
1061
|
SuperNode.new(
|
1044
1062
|
source, load_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, location)
|
1045
|
-
when
|
1063
|
+
when 143 then
|
1046
1064
|
SymbolNode.new(
|
1047
1065
|
source, load_varuint, load_optional_location, load_optional_location, load_optional_location, load_string, location)
|
1048
|
-
when
|
1066
|
+
when 144 then
|
1049
1067
|
TrueNode.new(
|
1050
1068
|
source, location)
|
1051
|
-
when
|
1069
|
+
when 145 then
|
1052
1070
|
UndefNode.new(
|
1053
1071
|
source, Array.new(load_varuint) { load_node }, load_location, location)
|
1054
|
-
when
|
1072
|
+
when 146 then
|
1055
1073
|
UnlessNode.new(
|
1056
1074
|
source, load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
|
1057
|
-
when
|
1075
|
+
when 147 then
|
1058
1076
|
UntilNode.new(
|
1059
1077
|
source, load_varuint, load_location, load_optional_location, load_node, load_optional_node, location)
|
1060
|
-
when
|
1078
|
+
when 148 then
|
1061
1079
|
WhenNode.new(
|
1062
1080
|
source, load_location, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_node, location)
|
1063
|
-
when
|
1081
|
+
when 149 then
|
1064
1082
|
WhileNode.new(
|
1065
1083
|
source, load_varuint, load_location, load_optional_location, load_node, load_optional_node, location)
|
1066
|
-
when
|
1084
|
+
when 150 then
|
1067
1085
|
XStringNode.new(
|
1068
1086
|
source, load_varuint, load_location, load_location, load_location, load_string, location)
|
1069
|
-
when
|
1087
|
+
when 151 then
|
1070
1088
|
YieldNode.new(
|
1071
1089
|
source, load_location, load_optional_location, load_optional_node, load_optional_location, location)
|
1072
1090
|
end
|
@@ -1516,6 +1534,11 @@ module Prism
|
|
1516
1534
|
InterpolatedXStringNode.new(
|
1517
1535
|
source, load_location, Array.new(load_varuint) { load_node }, load_location, location)
|
1518
1536
|
},
|
1537
|
+
-> {
|
1538
|
+
location = load_location
|
1539
|
+
ItLocalVariableReadNode.new(
|
1540
|
+
source, location)
|
1541
|
+
},
|
1519
1542
|
-> {
|
1520
1543
|
location = load_location
|
1521
1544
|
ItParametersNode.new(
|
@@ -1689,7 +1712,7 @@ module Prism
|
|
1689
1712
|
-> {
|
1690
1713
|
location = load_location
|
1691
1714
|
RationalNode.new(
|
1692
|
-
source,
|
1715
|
+
source, load_varuint, load_integer, load_integer, location)
|
1693
1716
|
},
|
1694
1717
|
-> {
|
1695
1718
|
location = load_location
|