prism 0.29.0 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/CONTRIBUTING.md +0 -4
- data/README.md +4 -0
- data/config.yml +498 -145
- data/docs/fuzzing.md +1 -1
- data/docs/parsing_rules.md +4 -1
- data/docs/ripper_translation.md +22 -0
- data/docs/serialization.md +3 -0
- data/ext/prism/api_node.c +2858 -2082
- data/ext/prism/extconf.rb +1 -1
- data/ext/prism/extension.c +203 -421
- data/ext/prism/extension.h +2 -2
- data/include/prism/ast.h +1732 -453
- data/include/prism/defines.h +36 -0
- data/include/prism/diagnostic.h +23 -6
- data/include/prism/node.h +0 -21
- data/include/prism/options.h +94 -3
- data/include/prism/parser.h +57 -28
- data/include/prism/regexp.h +18 -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 +22 -15
- data/include/prism/util/pm_newline_list.h +11 -0
- data/include/prism/util/pm_string.h +28 -12
- data/include/prism/version.h +3 -3
- data/include/prism.h +0 -11
- data/lib/prism/compiler.rb +3 -0
- data/lib/prism/desugar_compiler.rb +111 -74
- data/lib/prism/dispatcher.rb +16 -1
- data/lib/prism/dot_visitor.rb +45 -34
- data/lib/prism/dsl.rb +660 -468
- data/lib/prism/ffi.rb +64 -6
- data/lib/prism/inspect_visitor.rb +294 -64
- data/lib/prism/lex_compat.rb +1 -1
- data/lib/prism/mutation_compiler.rb +11 -6
- data/lib/prism/node.rb +2469 -4973
- data/lib/prism/node_ext.rb +91 -14
- data/lib/prism/parse_result/comments.rb +0 -7
- data/lib/prism/parse_result/errors.rb +65 -0
- data/lib/prism/parse_result/newlines.rb +101 -11
- data/lib/prism/parse_result.rb +43 -3
- data/lib/prism/reflection.rb +10 -8
- data/lib/prism/serialize.rb +484 -609
- data/lib/prism/translation/parser/compiler.rb +152 -132
- data/lib/prism/translation/parser/lexer.rb +26 -4
- data/lib/prism/translation/parser.rb +9 -4
- data/lib/prism/translation/ripper.rb +22 -20
- data/lib/prism/translation/ruby_parser.rb +73 -13
- data/lib/prism/visitor.rb +3 -0
- data/lib/prism.rb +0 -4
- data/prism.gemspec +3 -5
- data/rbi/prism/dsl.rbi +521 -0
- data/rbi/prism/node.rbi +744 -4837
- data/rbi/prism/visitor.rbi +3 -0
- data/rbi/prism.rbi +36 -30
- data/sig/prism/dsl.rbs +190 -303
- data/sig/prism/mutation_compiler.rbs +1 -0
- data/sig/prism/node.rbs +759 -628
- data/sig/prism/parse_result.rbs +2 -0
- data/sig/prism/visitor.rbs +1 -0
- data/sig/prism.rbs +103 -64
- data/src/diagnostic.c +62 -28
- data/src/node.c +499 -1754
- data/src/options.c +76 -27
- data/src/prettyprint.c +156 -112
- data/src/prism.c +2773 -2081
- data/src/regexp.c +202 -69
- data/src/serialize.c +170 -50
- 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 +53 -25
- data/src/util/pm_newline_list.c +29 -0
- data/src/util/pm_string.c +130 -80
- data/src/util/pm_strpbrk.c +32 -6
- metadata +4 -6
- data/include/prism/util/pm_string_list.h +0 -44
- data/lib/prism/debug.rb +0 -249
- data/lib/prism/translation/parser/rubocop.rb +0 -73
- data/src/util/pm_string_list.c +0 -28
data/lib/prism/dot_visitor.rb
CHANGED
@@ -909,10 +909,10 @@ module Prism
|
|
909
909
|
table.field("conditions", "[]")
|
910
910
|
end
|
911
911
|
|
912
|
-
#
|
913
|
-
unless (
|
914
|
-
table.field("
|
915
|
-
digraph.edge("#{id}:
|
912
|
+
# else_clause
|
913
|
+
unless (else_clause = node.else_clause).nil?
|
914
|
+
table.field("else_clause", port: true)
|
915
|
+
digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
|
916
916
|
end
|
917
917
|
|
918
918
|
# case_keyword_loc
|
@@ -954,10 +954,10 @@ module Prism
|
|
954
954
|
table.field("conditions", "[]")
|
955
955
|
end
|
956
956
|
|
957
|
-
#
|
958
|
-
unless (
|
959
|
-
table.field("
|
960
|
-
digraph.edge("#{id}:
|
957
|
+
# else_clause
|
958
|
+
unless (else_clause = node.else_clause).nil?
|
959
|
+
table.field("else_clause", port: true)
|
960
|
+
digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
|
961
961
|
end
|
962
962
|
|
963
963
|
# case_keyword_loc
|
@@ -2130,10 +2130,10 @@ module Prism
|
|
2130
2130
|
digraph.edge("#{id}:statements -> #{node_id(statements)};")
|
2131
2131
|
end
|
2132
2132
|
|
2133
|
-
#
|
2134
|
-
unless (
|
2135
|
-
table.field("
|
2136
|
-
digraph.edge("#{id}:
|
2133
|
+
# subsequent
|
2134
|
+
unless (subsequent = node.subsequent).nil?
|
2135
|
+
table.field("subsequent", port: true)
|
2136
|
+
digraph.edge("#{id}:subsequent -> #{node_id(subsequent)};")
|
2137
2137
|
end
|
2138
2138
|
|
2139
2139
|
# end_keyword_loc
|
@@ -2780,6 +2780,20 @@ module Prism
|
|
2780
2780
|
super
|
2781
2781
|
end
|
2782
2782
|
|
2783
|
+
# Visit a ItLocalVariableReadNode node.
|
2784
|
+
def visit_it_local_variable_read_node(node)
|
2785
|
+
table = Table.new("ItLocalVariableReadNode")
|
2786
|
+
id = node_id(node)
|
2787
|
+
|
2788
|
+
digraph.nodes << <<~DOT
|
2789
|
+
#{id} [
|
2790
|
+
label=<#{table.to_dot.gsub(/\n/, "\n ")}>
|
2791
|
+
];
|
2792
|
+
DOT
|
2793
|
+
|
2794
|
+
super
|
2795
|
+
end
|
2796
|
+
|
2783
2797
|
# Visit a ItParametersNode node.
|
2784
2798
|
def visit_it_parameters_node(node)
|
2785
2799
|
table = Table.new("ItParametersNode")
|
@@ -3779,9 +3793,14 @@ module Prism
|
|
3779
3793
|
table = Table.new("RationalNode")
|
3780
3794
|
id = node_id(node)
|
3781
3795
|
|
3782
|
-
#
|
3783
|
-
table.field("
|
3784
|
-
|
3796
|
+
# flags
|
3797
|
+
table.field("flags", integer_base_flags_inspect(node))
|
3798
|
+
|
3799
|
+
# numerator
|
3800
|
+
table.field("numerator", node.numerator.inspect)
|
3801
|
+
|
3802
|
+
# denominator
|
3803
|
+
table.field("denominator", node.denominator.inspect)
|
3785
3804
|
|
3786
3805
|
digraph.nodes << <<~DOT
|
3787
3806
|
#{id} [
|
@@ -3941,10 +3960,10 @@ module Prism
|
|
3941
3960
|
digraph.edge("#{id}:statements -> #{node_id(statements)};")
|
3942
3961
|
end
|
3943
3962
|
|
3944
|
-
#
|
3945
|
-
unless (
|
3946
|
-
table.field("
|
3947
|
-
digraph.edge("#{id}:
|
3963
|
+
# subsequent
|
3964
|
+
unless (subsequent = node.subsequent).nil?
|
3965
|
+
table.field("subsequent", port: true)
|
3966
|
+
digraph.edge("#{id}:subsequent -> #{node_id(subsequent)};")
|
3948
3967
|
end
|
3949
3968
|
|
3950
3969
|
digraph.nodes << <<~DOT
|
@@ -4003,9 +4022,6 @@ module Prism
|
|
4003
4022
|
table = Table.new("ReturnNode")
|
4004
4023
|
id = node_id(node)
|
4005
4024
|
|
4006
|
-
# flags
|
4007
|
-
table.field("flags", return_node_flags_inspect(node))
|
4008
|
-
|
4009
4025
|
# keyword_loc
|
4010
4026
|
table.field("keyword_loc", location_inspect(node.keyword_loc))
|
4011
4027
|
|
@@ -4367,10 +4383,10 @@ module Prism
|
|
4367
4383
|
digraph.edge("#{id}:statements -> #{node_id(statements)};")
|
4368
4384
|
end
|
4369
4385
|
|
4370
|
-
#
|
4371
|
-
unless (
|
4372
|
-
table.field("
|
4373
|
-
digraph.edge("#{id}:
|
4386
|
+
# else_clause
|
4387
|
+
unless (else_clause = node.else_clause).nil?
|
4388
|
+
table.field("else_clause", port: true)
|
4389
|
+
digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
|
4374
4390
|
end
|
4375
4391
|
|
4376
4392
|
# end_keyword_loc
|
@@ -4576,8 +4592,11 @@ module Prism
|
|
4576
4592
|
# comma-separated list.
|
4577
4593
|
def arguments_node_flags_inspect(node)
|
4578
4594
|
flags = [] #: Array[String]
|
4595
|
+
flags << "contains_forwarding" if node.contains_forwarding?
|
4579
4596
|
flags << "contains_keywords" if node.contains_keywords?
|
4580
4597
|
flags << "contains_keyword_splat" if node.contains_keyword_splat?
|
4598
|
+
flags << "contains_splat" if node.contains_splat?
|
4599
|
+
flags << "contains_multiple_splats" if node.contains_multiple_splats?
|
4581
4600
|
flags.join(", ")
|
4582
4601
|
end
|
4583
4602
|
|
@@ -4679,14 +4698,6 @@ module Prism
|
|
4679
4698
|
flags.join(", ")
|
4680
4699
|
end
|
4681
4700
|
|
4682
|
-
# Inspect a node that has return_node_flags flags to display the flags as a
|
4683
|
-
# comma-separated list.
|
4684
|
-
def return_node_flags_inspect(node)
|
4685
|
-
flags = [] #: Array[String]
|
4686
|
-
flags << "redundant" if node.redundant?
|
4687
|
-
flags.join(", ")
|
4688
|
-
end
|
4689
|
-
|
4690
4701
|
# Inspect a node that has shareable_constant_node_flags flags to display the flags as a
|
4691
4702
|
# comma-separated list.
|
4692
4703
|
def shareable_constant_node_flags_inspect(node)
|