prism 0.26.0 → 0.28.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 +45 -1
- data/Makefile +3 -2
- data/config.yml +305 -20
- data/docs/configuration.md +1 -0
- data/ext/prism/api_node.c +884 -879
- data/ext/prism/extconf.rb +23 -4
- data/ext/prism/extension.c +16 -9
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +298 -9
- data/include/prism/diagnostic.h +15 -5
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +10 -0
- data/include/prism/static_literals.h +8 -6
- data/include/prism/version.h +2 -2
- data/lib/prism/dot_visitor.rb +22 -6
- data/lib/prism/dsl.rb +8 -8
- data/lib/prism/ffi.rb +4 -4
- data/lib/prism/inspect_visitor.rb +2156 -0
- data/lib/prism/lex_compat.rb +18 -1
- data/lib/prism/mutation_compiler.rb +2 -2
- data/lib/prism/node.rb +2345 -1964
- data/lib/prism/node_ext.rb +34 -5
- data/lib/prism/parse_result/newlines.rb +0 -2
- data/lib/prism/parse_result.rb +137 -13
- data/lib/prism/pattern.rb +12 -6
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/reflection.rb +21 -31
- data/lib/prism/serialize.rb +27 -17
- data/lib/prism/translation/parser/compiler.rb +34 -15
- data/lib/prism/translation/parser.rb +6 -6
- data/lib/prism/translation/ripper.rb +72 -68
- data/lib/prism/translation/ruby_parser.rb +69 -31
- data/lib/prism.rb +3 -2
- data/prism.gemspec +36 -38
- data/rbi/prism/compiler.rbi +3 -5
- data/rbi/prism/inspect_visitor.rbi +12 -0
- data/rbi/prism/node.rbi +359 -321
- data/rbi/prism/parse_result.rbi +85 -34
- data/rbi/prism/reflection.rbi +7 -13
- data/rbi/prism/translation/ripper.rbi +1 -11
- data/rbi/prism.rbi +9 -9
- data/sig/prism/dsl.rbs +3 -3
- data/sig/prism/inspect_visitor.rbs +22 -0
- data/sig/prism/node.rbs +68 -48
- data/sig/prism/parse_result.rbs +42 -10
- data/sig/prism/reflection.rbs +2 -8
- data/sig/prism/serialize.rbs +2 -3
- data/sig/prism.rbs +9 -9
- data/src/diagnostic.c +44 -24
- data/src/node.c +41 -16
- data/src/options.c +2 -2
- data/src/prettyprint.c +61 -18
- data/src/prism.c +623 -188
- data/src/serialize.c +5 -2
- data/src/static_literals.c +120 -34
- data/src/token_type.c +4 -4
- data/src/util/pm_integer.c +9 -2
- metadata +7 -9
- data/lib/prism/node_inspector.rb +0 -68
- data/lib/prism/polyfill/string.rb +0 -12
- data/rbi/prism/desugar_compiler.rbi +0 -5
- data/rbi/prism/mutation_compiler.rbi +0 -5
- data/rbi/prism/translation/parser/compiler.rbi +0 -13
- data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
- data/rbi/prism/translation/ruby_parser.rbi +0 -11
data/lib/prism/lex_compat.rb
CHANGED
@@ -10,6 +10,23 @@ module Prism
|
|
10
10
|
# generally lines up. However, there are a few cases that require special
|
11
11
|
# handling.
|
12
12
|
class LexCompat # :nodoc:
|
13
|
+
# A result class specialized for holding tokens produced by the lexer.
|
14
|
+
class Result < Prism::Result
|
15
|
+
# The list of tokens that were produced by the lexer.
|
16
|
+
attr_reader :value
|
17
|
+
|
18
|
+
# Create a new lex compat result object with the given values.
|
19
|
+
def initialize(value, comments, magic_comments, data_loc, errors, warnings, source)
|
20
|
+
@value = value
|
21
|
+
super(comments, magic_comments, data_loc, errors, warnings, source)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Implement the hash pattern matching interface for Result.
|
25
|
+
def deconstruct_keys(keys)
|
26
|
+
super.merge!(value: value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
13
30
|
# This is a mapping of prism token types to Ripper token types. This is a
|
14
31
|
# many-to-one mapping because we split up our token types, whereas Ripper
|
15
32
|
# tends to group them.
|
@@ -844,7 +861,7 @@ module Prism
|
|
844
861
|
# We sort by location to compare against Ripper's output
|
845
862
|
tokens.sort_by!(&:location)
|
846
863
|
|
847
|
-
|
864
|
+
Result.new(tokens, result.comments, result.magic_comments, result.data_loc, result.errors, result.warnings, Source.for(source))
|
848
865
|
end
|
849
866
|
end
|
850
867
|
|
@@ -193,7 +193,7 @@ module Prism
|
|
193
193
|
|
194
194
|
# Copy a ConstantPathNode node
|
195
195
|
def visit_constant_path_node(node)
|
196
|
-
node.copy(parent: visit(node.parent)
|
196
|
+
node.copy(parent: visit(node.parent))
|
197
197
|
end
|
198
198
|
|
199
199
|
# Copy a ConstantPathOperatorWriteNode node
|
@@ -208,7 +208,7 @@ module Prism
|
|
208
208
|
|
209
209
|
# Copy a ConstantPathTargetNode node
|
210
210
|
def visit_constant_path_target_node(node)
|
211
|
-
node.copy(parent: visit(node.parent)
|
211
|
+
node.copy(parent: visit(node.parent))
|
212
212
|
end
|
213
213
|
|
214
214
|
# Copy a ConstantPathWriteNode node
|