prism 0.27.0 → 0.29.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/config.yml +68 -44
- data/docs/configuration.md +1 -0
- data/ext/prism/api_node.c +854 -847
- data/ext/prism/extconf.rb +27 -23
- data/ext/prism/extension.c +5 -3
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +70 -48
- data/include/prism/diagnostic.h +23 -6
- 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/desugar_compiler.rb +4 -4
- data/lib/prism/dot_visitor.rb +54 -38
- data/lib/prism/dsl.rb +24 -24
- data/lib/prism/ffi.rb +4 -4
- data/lib/prism/inspect_visitor.rb +2156 -0
- data/lib/prism/lex_compat.rb +1 -1
- data/lib/prism/mutation_compiler.rb +2 -2
- data/lib/prism/node.rb +737 -1863
- data/lib/prism/node_ext.rb +176 -5
- data/lib/prism/parse_result/comments.rb +1 -1
- data/lib/prism/parse_result/newlines.rb +1 -1
- data/lib/prism/parse_result.rb +78 -0
- 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 +20 -20
- data/lib/prism/serialize.rb +32 -15
- data/lib/prism/translation/parser/compiler.rb +156 -26
- data/lib/prism/translation/parser.rb +7 -7
- data/lib/prism/translation/ripper.rb +29 -25
- data/lib/prism/translation/ruby_parser.rb +13 -13
- data/lib/prism.rb +2 -1
- data/prism.gemspec +37 -38
- data/rbi/prism/compiler.rbi +3 -5
- data/rbi/prism/inspect_visitor.rbi +12 -0
- data/rbi/prism/node.rbi +405 -370
- data/rbi/prism/node_ext.rbi +5 -0
- data/rbi/prism/parse_result.rbi +23 -0
- data/rbi/prism/translation/ripper.rbi +1 -11
- data/sig/prism/dsl.rbs +12 -12
- data/sig/prism/inspect_visitor.rbs +22 -0
- data/sig/prism/lex_compat.rbs +10 -0
- data/sig/prism/node.rbs +108 -91
- data/sig/prism/node_ext.rbs +4 -0
- data/sig/prism/parse_result.rbs +12 -0
- data/src/diagnostic.c +66 -33
- data/src/node.c +89 -64
- data/src/options.c +2 -2
- data/src/prettyprint.c +109 -66
- data/src/prism.c +862 -317
- data/src/serialize.c +21 -18
- data/src/static_literals.c +120 -34
- data/src/token_type.c +6 -6
- metadata +8 -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/rbi/prism/node_ext.rbi
CHANGED
@@ -100,3 +100,8 @@ class Prism::ParametersNode < Prism::Node
|
|
100
100
|
sig { returns(T::Array[T.any([Symbol, Symbol], [Symbol])]) }
|
101
101
|
def signature; end
|
102
102
|
end
|
103
|
+
|
104
|
+
class Prism::CallNode < Prism::Node
|
105
|
+
sig { returns(T.nilable(Prism::Location)) }
|
106
|
+
def full_message_loc; end
|
107
|
+
end
|
data/rbi/prism/parse_result.rbi
CHANGED
@@ -16,6 +16,9 @@ class Prism::Source
|
|
16
16
|
sig { returns(Encoding) }
|
17
17
|
def encoding; end
|
18
18
|
|
19
|
+
sig { returns(T::Array[String]) }
|
20
|
+
def lines; end
|
21
|
+
|
19
22
|
sig { params(byte_offset: Integer, length: Integer).returns(String) }
|
20
23
|
def slice(byte_offset, length); end
|
21
24
|
|
@@ -41,6 +44,20 @@ class Prism::Source
|
|
41
44
|
def code_units_column(byte_offset, encoding); end
|
42
45
|
end
|
43
46
|
|
47
|
+
class Prism::ASCIISource < Prism::Source
|
48
|
+
sig { params(byte_offset: Integer).returns(Integer) }
|
49
|
+
def character_offset(byte_offset); end
|
50
|
+
|
51
|
+
sig { params(byte_offset: Integer).returns(Integer) }
|
52
|
+
def character_column(byte_offset); end
|
53
|
+
|
54
|
+
sig { params(byte_offset: Integer, encoding: Encoding).returns(Integer) }
|
55
|
+
def code_units_offset(byte_offset, encoding); end
|
56
|
+
|
57
|
+
sig { params(byte_offset: Integer, encoding: Encoding).returns(Integer) }
|
58
|
+
def code_units_column(byte_offset, encoding); end
|
59
|
+
end
|
60
|
+
|
44
61
|
class Prism::Location
|
45
62
|
sig { returns(Prism::Source) }
|
46
63
|
def source; end
|
@@ -78,6 +95,9 @@ class Prism::Location
|
|
78
95
|
sig { returns(String) }
|
79
96
|
def inspect; end
|
80
97
|
|
98
|
+
sig { returns(T::Array[String]) }
|
99
|
+
def source_lines; end
|
100
|
+
|
81
101
|
sig { returns(String) }
|
82
102
|
def slice; end
|
83
103
|
|
@@ -134,6 +154,9 @@ class Prism::Location
|
|
134
154
|
|
135
155
|
sig { params(other: Prism::Location).returns(Prism::Location) }
|
136
156
|
def join(other); end
|
157
|
+
|
158
|
+
sig { params(string: String).returns(Prism::Location) }
|
159
|
+
def adjoin(string); end
|
137
160
|
end
|
138
161
|
|
139
162
|
class Prism::Comment
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# typed: strict
|
2
2
|
|
3
3
|
class Prism::Translation::Ripper < Prism::Compiler
|
4
|
-
Result = type_member
|
5
|
-
|
6
4
|
sig { returns(T::Boolean) }
|
7
5
|
def error?; end
|
8
6
|
|
9
|
-
sig { returns(T.
|
7
|
+
sig { returns(T.untyped) }
|
10
8
|
def parse; end
|
11
9
|
|
12
10
|
sig { params(source: String, filename: String, lineno: Integer, raise_errors: T.untyped).returns(T.untyped) }
|
@@ -15,11 +13,3 @@ class Prism::Translation::Ripper < Prism::Compiler
|
|
15
13
|
sig { params(source: String, filename: String, lineno: Integer, raise_errors: T.untyped).returns(T.untyped) }
|
16
14
|
def self.sexp(source, filename = "-", lineno = 1, raise_errors: false); end
|
17
15
|
end
|
18
|
-
|
19
|
-
class Prism::Translation::Ripper::SexpBuilder < Prism::Translation::Ripper
|
20
|
-
Result = type_member { { fixed: T::Array[T.untyped] } }
|
21
|
-
end
|
22
|
-
|
23
|
-
class Prism::Translation::Ripper::SexpBuilderPP < Prism::Translation::Ripper::SexpBuilder
|
24
|
-
Result = type_member { { fixed: T::Array[T.untyped] } }
|
25
|
-
end
|
data/sig/prism/dsl.rbs
CHANGED
@@ -67,7 +67,7 @@ module Prism
|
|
67
67
|
def CallNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, Prism::node? block, ?Source source, ?Location location) -> CallNode
|
68
68
|
|
69
69
|
# Create a new CallOperatorWriteNode node
|
70
|
-
def CallOperatorWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol
|
70
|
+
def CallOperatorWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol binary_operator, Location binary_operator_loc, Prism::node value, ?Source source, ?Location location) -> CallOperatorWriteNode
|
71
71
|
|
72
72
|
# Create a new CallOrWriteNode node
|
73
73
|
def CallOrWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> CallOrWriteNode
|
@@ -91,7 +91,7 @@ module Prism
|
|
91
91
|
def ClassVariableAndWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ClassVariableAndWriteNode
|
92
92
|
|
93
93
|
# Create a new ClassVariableOperatorWriteNode node
|
94
|
-
def ClassVariableOperatorWriteNode: (Symbol name, Location name_loc, Location
|
94
|
+
def ClassVariableOperatorWriteNode: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, ?Source source, ?Location location) -> ClassVariableOperatorWriteNode
|
95
95
|
|
96
96
|
# Create a new ClassVariableOrWriteNode node
|
97
97
|
def ClassVariableOrWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ClassVariableOrWriteNode
|
@@ -109,7 +109,7 @@ module Prism
|
|
109
109
|
def ConstantAndWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantAndWriteNode
|
110
110
|
|
111
111
|
# Create a new ConstantOperatorWriteNode node
|
112
|
-
def ConstantOperatorWriteNode: (Symbol name, Location name_loc, Location
|
112
|
+
def ConstantOperatorWriteNode: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, ?Source source, ?Location location) -> ConstantOperatorWriteNode
|
113
113
|
|
114
114
|
# Create a new ConstantOrWriteNode node
|
115
115
|
def ConstantOrWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantOrWriteNode
|
@@ -118,16 +118,16 @@ module Prism
|
|
118
118
|
def ConstantPathAndWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathAndWriteNode
|
119
119
|
|
120
120
|
# Create a new ConstantPathNode node
|
121
|
-
def ConstantPathNode: (Prism::node? parent,
|
121
|
+
def ConstantPathNode: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, ?Source source, ?Location location) -> ConstantPathNode
|
122
122
|
|
123
123
|
# Create a new ConstantPathOperatorWriteNode node
|
124
|
-
def ConstantPathOperatorWriteNode: (ConstantPathNode target, Location
|
124
|
+
def ConstantPathOperatorWriteNode: (ConstantPathNode target, Location binary_operator_loc, Prism::node value, Symbol binary_operator, ?Source source, ?Location location) -> ConstantPathOperatorWriteNode
|
125
125
|
|
126
126
|
# Create a new ConstantPathOrWriteNode node
|
127
127
|
def ConstantPathOrWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathOrWriteNode
|
128
128
|
|
129
129
|
# Create a new ConstantPathTargetNode node
|
130
|
-
def ConstantPathTargetNode: (Prism::node? parent,
|
130
|
+
def ConstantPathTargetNode: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, ?Source source, ?Location location) -> ConstantPathTargetNode
|
131
131
|
|
132
132
|
# Create a new ConstantPathWriteNode node
|
133
133
|
def ConstantPathWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathWriteNode
|
@@ -187,7 +187,7 @@ module Prism
|
|
187
187
|
def GlobalVariableAndWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> GlobalVariableAndWriteNode
|
188
188
|
|
189
189
|
# Create a new GlobalVariableOperatorWriteNode node
|
190
|
-
def GlobalVariableOperatorWriteNode: (Symbol name, Location name_loc, Location
|
190
|
+
def GlobalVariableOperatorWriteNode: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, ?Source source, ?Location location) -> GlobalVariableOperatorWriteNode
|
191
191
|
|
192
192
|
# Create a new GlobalVariableOrWriteNode node
|
193
193
|
def GlobalVariableOrWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> GlobalVariableOrWriteNode
|
@@ -226,7 +226,7 @@ module Prism
|
|
226
226
|
def IndexAndWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> IndexAndWriteNode
|
227
227
|
|
228
228
|
# Create a new IndexOperatorWriteNode node
|
229
|
-
def IndexOperatorWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Symbol
|
229
|
+
def IndexOperatorWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Symbol binary_operator, Location binary_operator_loc, Prism::node value, ?Source source, ?Location location) -> IndexOperatorWriteNode
|
230
230
|
|
231
231
|
# Create a new IndexOrWriteNode node
|
232
232
|
def IndexOrWriteNode: (Integer flags, Prism::node? receiver, Location? call_operator_loc, Location opening_loc, ArgumentsNode? arguments, Location closing_loc, Prism::node? block, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> IndexOrWriteNode
|
@@ -238,7 +238,7 @@ module Prism
|
|
238
238
|
def InstanceVariableAndWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> InstanceVariableAndWriteNode
|
239
239
|
|
240
240
|
# Create a new InstanceVariableOperatorWriteNode node
|
241
|
-
def InstanceVariableOperatorWriteNode: (Symbol name, Location name_loc, Location
|
241
|
+
def InstanceVariableOperatorWriteNode: (Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator, ?Source source, ?Location location) -> InstanceVariableOperatorWriteNode
|
242
242
|
|
243
243
|
# Create a new InstanceVariableOrWriteNode node
|
244
244
|
def InstanceVariableOrWriteNode: (Symbol name, Location name_loc, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> InstanceVariableOrWriteNode
|
@@ -286,7 +286,7 @@ module Prism
|
|
286
286
|
def LocalVariableAndWriteNode: (Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth, ?Source source, ?Location location) -> LocalVariableAndWriteNode
|
287
287
|
|
288
288
|
# Create a new LocalVariableOperatorWriteNode node
|
289
|
-
def LocalVariableOperatorWriteNode: (Location name_loc, Location
|
289
|
+
def LocalVariableOperatorWriteNode: (Location name_loc, Location binary_operator_loc, Prism::node value, Symbol name, Symbol binary_operator, Integer depth, ?Source source, ?Location location) -> LocalVariableOperatorWriteNode
|
290
290
|
|
291
291
|
# Create a new LocalVariableOrWriteNode node
|
292
292
|
def LocalVariableOrWriteNode: (Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth, ?Source source, ?Location location) -> LocalVariableOrWriteNode
|
@@ -349,7 +349,7 @@ module Prism
|
|
349
349
|
def OrNode: (Prism::node left, Prism::node right, Location operator_loc, ?Source source, ?Location location) -> OrNode
|
350
350
|
|
351
351
|
# Create a new ParametersNode node
|
352
|
-
def ParametersNode: (Array[RequiredParameterNode | MultiTargetNode] requireds, Array[OptionalParameterNode] optionals, RestParameterNode | ImplicitRestNode | nil rest, Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode] posts, Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] keywords, KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode | nil keyword_rest, BlockParameterNode? block, ?Source source, ?Location location) -> ParametersNode
|
352
|
+
def ParametersNode: (Array[RequiredParameterNode | MultiTargetNode] requireds, Array[OptionalParameterNode] optionals, RestParameterNode | ImplicitRestNode | nil rest, Array[RequiredParameterNode | MultiTargetNode | KeywordRestParameterNode | NoKeywordsParameterNode | ForwardingParameterNode] posts, Array[RequiredKeywordParameterNode | OptionalKeywordParameterNode] keywords, KeywordRestParameterNode | ForwardingParameterNode | NoKeywordsParameterNode | nil keyword_rest, BlockParameterNode? block, ?Source source, ?Location location) -> ParametersNode
|
353
353
|
|
354
354
|
# Create a new ParenthesesNode node
|
355
355
|
def ParenthesesNode: (Prism::node? body, Location opening_loc, Location closing_loc, ?Source source, ?Location location) -> ParenthesesNode
|
@@ -400,7 +400,7 @@ module Prism
|
|
400
400
|
def RetryNode: (?Source source, ?Location location) -> RetryNode
|
401
401
|
|
402
402
|
# Create a new ReturnNode node
|
403
|
-
def ReturnNode: (Location keyword_loc, ArgumentsNode? arguments, ?Source source, ?Location location) -> ReturnNode
|
403
|
+
def ReturnNode: (Integer flags, Location keyword_loc, ArgumentsNode? arguments, ?Source source, ?Location location) -> ReturnNode
|
404
404
|
|
405
405
|
# Create a new SelfNode node
|
406
406
|
def SelfNode: (?Source source, ?Location location) -> SelfNode
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Prism
|
2
|
+
class InspectVisitor < Visitor
|
3
|
+
class Replace
|
4
|
+
attr_reader value: String
|
5
|
+
|
6
|
+
def initialize: (String value) -> void
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader indent: String
|
10
|
+
attr_reader commands: Array[[String | node | Replace, String]]
|
11
|
+
|
12
|
+
def initialize: (?String indent) -> void
|
13
|
+
def compose: () -> String
|
14
|
+
|
15
|
+
def self.compose: (node node) -> String
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def inspect_node: (String name, node node) -> String
|
20
|
+
def inspect_location: (Location? location) -> String
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Prism
|
2
|
+
class LexCompat
|
3
|
+
class Result < Prism::Result
|
4
|
+
attr_reader value: Array[[[Integer, Integer], Symbol, String, untyped]]
|
5
|
+
|
6
|
+
def initialize: (Array[[[Integer, Integer], Symbol, String, untyped]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
7
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|