prism 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +172 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +62 -0
- data/LICENSE.md +7 -0
- data/Makefile +84 -0
- data/README.md +89 -0
- data/config.yml +2481 -0
- data/docs/build_system.md +74 -0
- data/docs/building.md +22 -0
- data/docs/configuration.md +60 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +117 -0
- data/docs/fuzzing.md +93 -0
- data/docs/heredocs.md +36 -0
- data/docs/mapping.md +117 -0
- data/docs/ripper.md +36 -0
- data/docs/ruby_api.md +25 -0
- data/docs/serialization.md +181 -0
- data/docs/testing.md +55 -0
- data/ext/prism/api_node.c +4725 -0
- data/ext/prism/api_pack.c +256 -0
- data/ext/prism/extconf.rb +136 -0
- data/ext/prism/extension.c +626 -0
- data/ext/prism/extension.h +18 -0
- data/include/prism/ast.h +1932 -0
- data/include/prism/defines.h +45 -0
- data/include/prism/diagnostic.h +231 -0
- data/include/prism/enc/pm_encoding.h +95 -0
- data/include/prism/node.h +41 -0
- data/include/prism/pack.h +141 -0
- data/include/prism/parser.h +418 -0
- data/include/prism/regexp.h +19 -0
- data/include/prism/unescape.h +48 -0
- data/include/prism/util/pm_buffer.h +51 -0
- data/include/prism/util/pm_char.h +91 -0
- data/include/prism/util/pm_constant_pool.h +78 -0
- data/include/prism/util/pm_list.h +67 -0
- data/include/prism/util/pm_memchr.h +14 -0
- data/include/prism/util/pm_newline_list.h +61 -0
- data/include/prism/util/pm_state_stack.h +24 -0
- data/include/prism/util/pm_string.h +61 -0
- data/include/prism/util/pm_string_list.h +25 -0
- data/include/prism/util/pm_strpbrk.h +29 -0
- data/include/prism/version.h +4 -0
- data/include/prism.h +82 -0
- data/lib/prism/compiler.rb +465 -0
- data/lib/prism/debug.rb +157 -0
- data/lib/prism/desugar_compiler.rb +206 -0
- data/lib/prism/dispatcher.rb +2051 -0
- data/lib/prism/dsl.rb +750 -0
- data/lib/prism/ffi.rb +251 -0
- data/lib/prism/lex_compat.rb +838 -0
- data/lib/prism/mutation_compiler.rb +718 -0
- data/lib/prism/node.rb +14540 -0
- data/lib/prism/node_ext.rb +55 -0
- data/lib/prism/node_inspector.rb +68 -0
- data/lib/prism/pack.rb +185 -0
- data/lib/prism/parse_result/comments.rb +172 -0
- data/lib/prism/parse_result/newlines.rb +60 -0
- data/lib/prism/parse_result.rb +266 -0
- data/lib/prism/pattern.rb +239 -0
- data/lib/prism/ripper_compat.rb +174 -0
- data/lib/prism/serialize.rb +662 -0
- data/lib/prism/visitor.rb +470 -0
- data/lib/prism.rb +64 -0
- data/prism.gemspec +113 -0
- data/src/diagnostic.c +287 -0
- data/src/enc/pm_big5.c +52 -0
- data/src/enc/pm_euc_jp.c +58 -0
- data/src/enc/pm_gbk.c +61 -0
- data/src/enc/pm_shift_jis.c +56 -0
- data/src/enc/pm_tables.c +507 -0
- data/src/enc/pm_unicode.c +2324 -0
- data/src/enc/pm_windows_31j.c +56 -0
- data/src/node.c +2633 -0
- data/src/pack.c +493 -0
- data/src/prettyprint.c +2136 -0
- data/src/prism.c +14587 -0
- data/src/regexp.c +580 -0
- data/src/serialize.c +1899 -0
- data/src/token_type.c +349 -0
- data/src/unescape.c +637 -0
- data/src/util/pm_buffer.c +103 -0
- data/src/util/pm_char.c +272 -0
- data/src/util/pm_constant_pool.c +252 -0
- data/src/util/pm_list.c +41 -0
- data/src/util/pm_memchr.c +33 -0
- data/src/util/pm_newline_list.c +134 -0
- data/src/util/pm_state_stack.c +19 -0
- data/src/util/pm_string.c +200 -0
- data/src/util/pm_string_list.c +29 -0
- data/src/util/pm_strncasecmp.c +17 -0
- data/src/util/pm_strpbrk.c +66 -0
- metadata +138 -0
@@ -0,0 +1,662 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
=begin
|
3
|
+
This file is generated by the templates/template.rb script and should not be
|
4
|
+
modified manually. See templates/lib/prism/serialize.rb.erb
|
5
|
+
if you are looking to modify the template
|
6
|
+
=end
|
7
|
+
|
8
|
+
require "stringio"
|
9
|
+
|
10
|
+
# Polyfill for String#unpack1 with the offset parameter.
|
11
|
+
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
|
12
|
+
String.prepend(
|
13
|
+
Module.new {
|
14
|
+
def unpack1(format, offset: 0)
|
15
|
+
offset == 0 ? super(format) : self[offset..].unpack1(format)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
module Prism
|
22
|
+
module Serialize
|
23
|
+
MAJOR_VERSION = 0
|
24
|
+
MINOR_VERSION = 13
|
25
|
+
PATCH_VERSION = 0
|
26
|
+
|
27
|
+
def self.load(input, serialized)
|
28
|
+
input = input.dup
|
29
|
+
source = Source.new(input)
|
30
|
+
loader = Loader.new(source, serialized)
|
31
|
+
result = loader.load_result
|
32
|
+
|
33
|
+
input.force_encoding(loader.encoding)
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.load_tokens(source, serialized)
|
38
|
+
Loader.new(source, serialized).load_tokens_result
|
39
|
+
end
|
40
|
+
|
41
|
+
class Loader
|
42
|
+
attr_reader :encoding, :input, :serialized, :io
|
43
|
+
attr_reader :constant_pool_offset, :constant_pool, :source
|
44
|
+
|
45
|
+
def initialize(source, serialized)
|
46
|
+
@encoding = Encoding::UTF_8
|
47
|
+
|
48
|
+
@input = source.source.dup
|
49
|
+
@serialized = serialized
|
50
|
+
@io = StringIO.new(serialized)
|
51
|
+
@io.set_encoding(Encoding::BINARY)
|
52
|
+
|
53
|
+
@constant_pool_offset = nil
|
54
|
+
@constant_pool = nil
|
55
|
+
|
56
|
+
@source = source
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_encoding
|
60
|
+
Encoding.find(io.read(load_varint))
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_metadata
|
64
|
+
comments = load_varint.times.map { Comment.new(Comment::TYPES.fetch(load_varint), load_location) }
|
65
|
+
errors = load_varint.times.map { ParseError.new(load_embedded_string, load_location) }
|
66
|
+
warnings = load_varint.times.map { ParseWarning.new(load_embedded_string, load_location) }
|
67
|
+
[comments, errors, warnings]
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_tokens
|
71
|
+
tokens = []
|
72
|
+
while type = TOKEN_TYPES.fetch(load_varint)
|
73
|
+
start = load_varint
|
74
|
+
length = load_varint
|
75
|
+
lex_state = load_varint
|
76
|
+
location = Location.new(@source, start, length)
|
77
|
+
tokens << [Prism::Token.new(type, location.slice, location), lex_state]
|
78
|
+
end
|
79
|
+
|
80
|
+
tokens
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_tokens_result
|
84
|
+
tokens = load_tokens
|
85
|
+
encoding = load_encoding
|
86
|
+
comments, errors, warnings = load_metadata
|
87
|
+
|
88
|
+
if encoding != @encoding
|
89
|
+
tokens.each { |token,| token.value.force_encoding(encoding) }
|
90
|
+
end
|
91
|
+
|
92
|
+
raise "Expected to consume all bytes while deserializing" unless @io.eof?
|
93
|
+
Prism::ParseResult.new(tokens, comments, errors, warnings, @source)
|
94
|
+
end
|
95
|
+
|
96
|
+
def load_nodes
|
97
|
+
raise "Invalid serialization" if io.read(5) != "PRISM"
|
98
|
+
raise "Invalid serialization" if io.read(3).unpack("C3") != [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION]
|
99
|
+
only_semantic_fields = io.read(1).unpack1("C")
|
100
|
+
unless only_semantic_fields == 0
|
101
|
+
raise "Invalid serialization (location fields must be included but are not)"
|
102
|
+
end
|
103
|
+
|
104
|
+
@encoding = load_encoding
|
105
|
+
@input = input.force_encoding(@encoding).freeze
|
106
|
+
|
107
|
+
comments, errors, warnings = load_metadata
|
108
|
+
|
109
|
+
@constant_pool_offset = io.read(4).unpack1("L")
|
110
|
+
@constant_pool = Array.new(load_varint, nil)
|
111
|
+
|
112
|
+
[load_node, comments, errors, warnings]
|
113
|
+
end
|
114
|
+
|
115
|
+
def load_result
|
116
|
+
node, comments, errors, warnings = load_nodes
|
117
|
+
Prism::ParseResult.new(node, comments, errors, warnings, @source)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
# variable-length integer using https://en.wikipedia.org/wiki/LEB128
|
123
|
+
# This is also what protobuf uses: https://protobuf.dev/programming-guides/encoding/#varints
|
124
|
+
def load_varint
|
125
|
+
n = io.getbyte
|
126
|
+
if n < 128
|
127
|
+
n
|
128
|
+
else
|
129
|
+
n -= 128
|
130
|
+
shift = 0
|
131
|
+
while (b = io.getbyte) >= 128
|
132
|
+
n += (b - 128) << (shift += 7)
|
133
|
+
end
|
134
|
+
n + (b << (shift + 7))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def load_serialized_length
|
139
|
+
io.read(4).unpack1("L")
|
140
|
+
end
|
141
|
+
|
142
|
+
def load_optional_node
|
143
|
+
if io.getbyte != 0
|
144
|
+
io.pos -= 1
|
145
|
+
load_node
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def load_embedded_string
|
150
|
+
io.read(load_varint).force_encoding(encoding)
|
151
|
+
end
|
152
|
+
|
153
|
+
def load_string
|
154
|
+
case io.getbyte
|
155
|
+
when 1
|
156
|
+
input.byteslice(load_varint, load_varint).force_encoding(encoding)
|
157
|
+
when 2
|
158
|
+
load_embedded_string
|
159
|
+
else
|
160
|
+
raise
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def load_location
|
165
|
+
Location.new(source, load_varint, load_varint)
|
166
|
+
end
|
167
|
+
|
168
|
+
def load_optional_location
|
169
|
+
load_location if io.getbyte != 0
|
170
|
+
end
|
171
|
+
|
172
|
+
def load_constant(index)
|
173
|
+
constant = constant_pool[index]
|
174
|
+
|
175
|
+
unless constant
|
176
|
+
offset = constant_pool_offset + index * 8
|
177
|
+
start = serialized.unpack1("L", offset: offset)
|
178
|
+
length = serialized.unpack1("L", offset: offset + 4)
|
179
|
+
|
180
|
+
constant =
|
181
|
+
if start.nobits?(1 << 31)
|
182
|
+
input.byteslice(start, length).to_sym
|
183
|
+
else
|
184
|
+
serialized.byteslice(start & ((1 << 31) - 1), length).to_sym
|
185
|
+
end
|
186
|
+
|
187
|
+
constant_pool[index] = constant
|
188
|
+
end
|
189
|
+
|
190
|
+
constant
|
191
|
+
end
|
192
|
+
|
193
|
+
def load_required_constant
|
194
|
+
load_constant(load_varint - 1)
|
195
|
+
end
|
196
|
+
|
197
|
+
def load_optional_constant
|
198
|
+
index = load_varint
|
199
|
+
load_constant(index - 1) if index != 0
|
200
|
+
end
|
201
|
+
|
202
|
+
def load_node
|
203
|
+
type = io.getbyte
|
204
|
+
location = load_location
|
205
|
+
|
206
|
+
case type
|
207
|
+
when 1 then
|
208
|
+
AliasGlobalVariableNode.new(load_node, load_node, load_location, location)
|
209
|
+
when 2 then
|
210
|
+
AliasMethodNode.new(load_node, load_node, load_location, location)
|
211
|
+
when 3 then
|
212
|
+
AlternationPatternNode.new(load_node, load_node, load_location, location)
|
213
|
+
when 4 then
|
214
|
+
AndNode.new(load_node, load_node, load_location, location)
|
215
|
+
when 5 then
|
216
|
+
ArgumentsNode.new(Array.new(load_varint) { load_node }, location)
|
217
|
+
when 6 then
|
218
|
+
ArrayNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
|
219
|
+
when 7 then
|
220
|
+
ArrayPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
|
221
|
+
when 8 then
|
222
|
+
AssocNode.new(load_node, load_optional_node, load_optional_location, location)
|
223
|
+
when 9 then
|
224
|
+
AssocSplatNode.new(load_optional_node, load_location, location)
|
225
|
+
when 10 then
|
226
|
+
BackReferenceReadNode.new(location)
|
227
|
+
when 11 then
|
228
|
+
BeginNode.new(load_optional_location, load_optional_node, load_optional_node, load_optional_node, load_optional_node, load_optional_location, location)
|
229
|
+
when 12 then
|
230
|
+
BlockArgumentNode.new(load_optional_node, load_location, location)
|
231
|
+
when 13 then
|
232
|
+
BlockLocalVariableNode.new(load_required_constant, location)
|
233
|
+
when 14 then
|
234
|
+
BlockNode.new(Array.new(load_varint) { load_required_constant }, load_optional_node, load_optional_node, load_location, load_location, location)
|
235
|
+
when 15 then
|
236
|
+
BlockParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
|
237
|
+
when 16 then
|
238
|
+
BlockParametersNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
|
239
|
+
when 17 then
|
240
|
+
BreakNode.new(load_optional_node, load_location, location)
|
241
|
+
when 18 then
|
242
|
+
CallAndWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_string, load_string, load_location, load_node, location)
|
243
|
+
when 19 then
|
244
|
+
CallNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, load_varint, load_string, location)
|
245
|
+
when 20 then
|
246
|
+
CallOperatorWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_string, load_string, load_required_constant, load_location, load_node, location)
|
247
|
+
when 21 then
|
248
|
+
CallOrWriteNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_varint, load_string, load_string, load_location, load_node, location)
|
249
|
+
when 22 then
|
250
|
+
CapturePatternNode.new(load_node, load_node, load_location, location)
|
251
|
+
when 23 then
|
252
|
+
CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
|
253
|
+
when 24 then
|
254
|
+
ClassNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_location, load_required_constant, location)
|
255
|
+
when 25 then
|
256
|
+
ClassVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
257
|
+
when 26 then
|
258
|
+
ClassVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
|
259
|
+
when 27 then
|
260
|
+
ClassVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
261
|
+
when 28 then
|
262
|
+
ClassVariableReadNode.new(load_required_constant, location)
|
263
|
+
when 29 then
|
264
|
+
ClassVariableTargetNode.new(load_required_constant, location)
|
265
|
+
when 30 then
|
266
|
+
ClassVariableWriteNode.new(load_required_constant, load_location, load_node, load_optional_location, location)
|
267
|
+
when 31 then
|
268
|
+
ConstantAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
269
|
+
when 32 then
|
270
|
+
ConstantOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
|
271
|
+
when 33 then
|
272
|
+
ConstantOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
273
|
+
when 34 then
|
274
|
+
ConstantPathAndWriteNode.new(load_node, load_location, load_node, location)
|
275
|
+
when 35 then
|
276
|
+
ConstantPathNode.new(load_optional_node, load_node, load_location, location)
|
277
|
+
when 36 then
|
278
|
+
ConstantPathOperatorWriteNode.new(load_node, load_location, load_node, load_required_constant, location)
|
279
|
+
when 37 then
|
280
|
+
ConstantPathOrWriteNode.new(load_node, load_location, load_node, location)
|
281
|
+
when 38 then
|
282
|
+
ConstantPathTargetNode.new(load_optional_node, load_node, load_location, location)
|
283
|
+
when 39 then
|
284
|
+
ConstantPathWriteNode.new(load_node, load_location, load_node, location)
|
285
|
+
when 40 then
|
286
|
+
ConstantReadNode.new(load_required_constant, location)
|
287
|
+
when 41 then
|
288
|
+
ConstantTargetNode.new(load_required_constant, location)
|
289
|
+
when 42 then
|
290
|
+
ConstantWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
|
291
|
+
when 43 then
|
292
|
+
load_serialized_length
|
293
|
+
DefNode.new(load_required_constant, load_location, load_optional_node, load_optional_node, load_optional_node, Array.new(load_varint) { load_required_constant }, load_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, location)
|
294
|
+
when 44 then
|
295
|
+
DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
|
296
|
+
when 45 then
|
297
|
+
ElseNode.new(load_location, load_optional_node, load_optional_location, location)
|
298
|
+
when 46 then
|
299
|
+
EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
|
300
|
+
when 47 then
|
301
|
+
EmbeddedVariableNode.new(load_location, load_node, location)
|
302
|
+
when 48 then
|
303
|
+
EnsureNode.new(load_location, load_optional_node, load_location, location)
|
304
|
+
when 49 then
|
305
|
+
FalseNode.new(location)
|
306
|
+
when 50 then
|
307
|
+
FindPatternNode.new(load_optional_node, load_node, Array.new(load_varint) { load_node }, load_node, load_optional_location, load_optional_location, location)
|
308
|
+
when 51 then
|
309
|
+
FlipFlopNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
|
310
|
+
when 52 then
|
311
|
+
FloatNode.new(location)
|
312
|
+
when 53 then
|
313
|
+
ForNode.new(load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
|
314
|
+
when 54 then
|
315
|
+
ForwardingArgumentsNode.new(location)
|
316
|
+
when 55 then
|
317
|
+
ForwardingParameterNode.new(location)
|
318
|
+
when 56 then
|
319
|
+
ForwardingSuperNode.new(load_optional_node, location)
|
320
|
+
when 57 then
|
321
|
+
GlobalVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
322
|
+
when 58 then
|
323
|
+
GlobalVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
|
324
|
+
when 59 then
|
325
|
+
GlobalVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
326
|
+
when 60 then
|
327
|
+
GlobalVariableReadNode.new(load_required_constant, location)
|
328
|
+
when 61 then
|
329
|
+
GlobalVariableTargetNode.new(load_required_constant, location)
|
330
|
+
when 62 then
|
331
|
+
GlobalVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
|
332
|
+
when 63 then
|
333
|
+
HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
|
334
|
+
when 64 then
|
335
|
+
HashPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_location, load_optional_location, location)
|
336
|
+
when 65 then
|
337
|
+
IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
|
338
|
+
when 66 then
|
339
|
+
ImaginaryNode.new(load_node, location)
|
340
|
+
when 67 then
|
341
|
+
ImplicitNode.new(load_node, location)
|
342
|
+
when 68 then
|
343
|
+
InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
|
344
|
+
when 69 then
|
345
|
+
InstanceVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
346
|
+
when 70 then
|
347
|
+
InstanceVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
|
348
|
+
when 71 then
|
349
|
+
InstanceVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
|
350
|
+
when 72 then
|
351
|
+
InstanceVariableReadNode.new(load_required_constant, location)
|
352
|
+
when 73 then
|
353
|
+
InstanceVariableTargetNode.new(load_required_constant, location)
|
354
|
+
when 74 then
|
355
|
+
InstanceVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
|
356
|
+
when 75 then
|
357
|
+
IntegerNode.new(load_varint, location)
|
358
|
+
when 76 then
|
359
|
+
InterpolatedMatchLastLineNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
|
360
|
+
when 77 then
|
361
|
+
InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
|
362
|
+
when 78 then
|
363
|
+
InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
|
364
|
+
when 79 then
|
365
|
+
InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
|
366
|
+
when 80 then
|
367
|
+
InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
|
368
|
+
when 81 then
|
369
|
+
KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
|
370
|
+
when 82 then
|
371
|
+
KeywordParameterNode.new(load_required_constant, load_location, load_optional_node, location)
|
372
|
+
when 83 then
|
373
|
+
KeywordRestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
|
374
|
+
when 84 then
|
375
|
+
LambdaNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_location, load_optional_node, load_optional_node, location)
|
376
|
+
when 85 then
|
377
|
+
LocalVariableAndWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
|
378
|
+
when 86 then
|
379
|
+
LocalVariableOperatorWriteNode.new(load_location, load_location, load_node, load_required_constant, load_required_constant, load_varint, location)
|
380
|
+
when 87 then
|
381
|
+
LocalVariableOrWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
|
382
|
+
when 88 then
|
383
|
+
LocalVariableReadNode.new(load_required_constant, load_varint, location)
|
384
|
+
when 89 then
|
385
|
+
LocalVariableTargetNode.new(load_required_constant, load_varint, location)
|
386
|
+
when 90 then
|
387
|
+
LocalVariableWriteNode.new(load_required_constant, load_varint, load_location, load_node, load_location, location)
|
388
|
+
when 91 then
|
389
|
+
MatchLastLineNode.new(load_location, load_location, load_location, load_string, load_varint, location)
|
390
|
+
when 92 then
|
391
|
+
MatchPredicateNode.new(load_node, load_node, load_location, location)
|
392
|
+
when 93 then
|
393
|
+
MatchRequiredNode.new(load_node, load_node, load_location, location)
|
394
|
+
when 94 then
|
395
|
+
MatchWriteNode.new(load_node, Array.new(load_varint) { load_required_constant }, location)
|
396
|
+
when 95 then
|
397
|
+
MissingNode.new(location)
|
398
|
+
when 96 then
|
399
|
+
ModuleNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_node, load_optional_node, load_location, load_required_constant, location)
|
400
|
+
when 97 then
|
401
|
+
MultiTargetNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
|
402
|
+
when 98 then
|
403
|
+
MultiWriteNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, load_location, load_node, location)
|
404
|
+
when 99 then
|
405
|
+
NextNode.new(load_optional_node, load_location, location)
|
406
|
+
when 100 then
|
407
|
+
NilNode.new(location)
|
408
|
+
when 101 then
|
409
|
+
NoKeywordsParameterNode.new(load_location, load_location, location)
|
410
|
+
when 102 then
|
411
|
+
NumberedReferenceReadNode.new(load_varint, location)
|
412
|
+
when 103 then
|
413
|
+
OptionalParameterNode.new(load_required_constant, load_location, load_location, load_node, location)
|
414
|
+
when 104 then
|
415
|
+
OrNode.new(load_node, load_node, load_location, location)
|
416
|
+
when 105 then
|
417
|
+
ParametersNode.new(Array.new(load_varint) { load_node }, Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, Array.new(load_varint) { load_node }, load_optional_node, load_optional_node, location)
|
418
|
+
when 106 then
|
419
|
+
ParenthesesNode.new(load_optional_node, load_location, load_location, location)
|
420
|
+
when 107 then
|
421
|
+
PinnedExpressionNode.new(load_node, load_location, load_location, load_location, location)
|
422
|
+
when 108 then
|
423
|
+
PinnedVariableNode.new(load_node, load_location, location)
|
424
|
+
when 109 then
|
425
|
+
PostExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
|
426
|
+
when 110 then
|
427
|
+
PreExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
|
428
|
+
when 111 then
|
429
|
+
ProgramNode.new(Array.new(load_varint) { load_required_constant }, load_node, location)
|
430
|
+
when 112 then
|
431
|
+
RangeNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
|
432
|
+
when 113 then
|
433
|
+
RationalNode.new(load_node, location)
|
434
|
+
when 114 then
|
435
|
+
RedoNode.new(location)
|
436
|
+
when 115 then
|
437
|
+
RegularExpressionNode.new(load_location, load_location, load_location, load_string, load_varint, location)
|
438
|
+
when 116 then
|
439
|
+
RequiredDestructuredParameterNode.new(Array.new(load_varint) { load_node }, load_location, load_location, location)
|
440
|
+
when 117 then
|
441
|
+
RequiredParameterNode.new(load_required_constant, location)
|
442
|
+
when 118 then
|
443
|
+
RescueModifierNode.new(load_node, load_location, load_node, location)
|
444
|
+
when 119 then
|
445
|
+
RescueNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
|
446
|
+
when 120 then
|
447
|
+
RestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
|
448
|
+
when 121 then
|
449
|
+
RetryNode.new(location)
|
450
|
+
when 122 then
|
451
|
+
ReturnNode.new(load_location, load_optional_node, location)
|
452
|
+
when 123 then
|
453
|
+
SelfNode.new(location)
|
454
|
+
when 124 then
|
455
|
+
SingletonClassNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
|
456
|
+
when 125 then
|
457
|
+
SourceEncodingNode.new(location)
|
458
|
+
when 126 then
|
459
|
+
SourceFileNode.new(load_string, location)
|
460
|
+
when 127 then
|
461
|
+
SourceLineNode.new(location)
|
462
|
+
when 128 then
|
463
|
+
SplatNode.new(load_location, load_optional_node, location)
|
464
|
+
when 129 then
|
465
|
+
StatementsNode.new(Array.new(load_varint) { load_node }, location)
|
466
|
+
when 130 then
|
467
|
+
StringConcatNode.new(load_node, load_node, location)
|
468
|
+
when 131 then
|
469
|
+
StringNode.new(load_varint, load_optional_location, load_location, load_optional_location, load_string, location)
|
470
|
+
when 132 then
|
471
|
+
SuperNode.new(load_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, location)
|
472
|
+
when 133 then
|
473
|
+
SymbolNode.new(load_optional_location, load_optional_location, load_optional_location, load_string, location)
|
474
|
+
when 134 then
|
475
|
+
TrueNode.new(location)
|
476
|
+
when 135 then
|
477
|
+
UndefNode.new(Array.new(load_varint) { load_node }, load_location, location)
|
478
|
+
when 136 then
|
479
|
+
UnlessNode.new(load_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
|
480
|
+
when 137 then
|
481
|
+
UntilNode.new(load_location, load_optional_location, load_node, load_optional_node, load_varint, location)
|
482
|
+
when 138 then
|
483
|
+
WhenNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_node, location)
|
484
|
+
when 139 then
|
485
|
+
WhileNode.new(load_location, load_optional_location, load_node, load_optional_node, load_varint, location)
|
486
|
+
when 140 then
|
487
|
+
XStringNode.new(load_location, load_location, load_location, load_string, location)
|
488
|
+
when 141 then
|
489
|
+
YieldNode.new(load_location, load_optional_location, load_optional_node, load_optional_location, location)
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
TOKEN_TYPES = [
|
495
|
+
nil,
|
496
|
+
:EOF,
|
497
|
+
:MISSING,
|
498
|
+
:NOT_PROVIDED,
|
499
|
+
:AMPERSAND,
|
500
|
+
:AMPERSAND_AMPERSAND,
|
501
|
+
:AMPERSAND_AMPERSAND_EQUAL,
|
502
|
+
:AMPERSAND_DOT,
|
503
|
+
:AMPERSAND_EQUAL,
|
504
|
+
:BACKTICK,
|
505
|
+
:BACK_REFERENCE,
|
506
|
+
:BANG,
|
507
|
+
:BANG_EQUAL,
|
508
|
+
:BANG_TILDE,
|
509
|
+
:BRACE_LEFT,
|
510
|
+
:BRACE_RIGHT,
|
511
|
+
:BRACKET_LEFT,
|
512
|
+
:BRACKET_LEFT_ARRAY,
|
513
|
+
:BRACKET_LEFT_RIGHT,
|
514
|
+
:BRACKET_LEFT_RIGHT_EQUAL,
|
515
|
+
:BRACKET_RIGHT,
|
516
|
+
:CARET,
|
517
|
+
:CARET_EQUAL,
|
518
|
+
:CHARACTER_LITERAL,
|
519
|
+
:CLASS_VARIABLE,
|
520
|
+
:COLON,
|
521
|
+
:COLON_COLON,
|
522
|
+
:COMMA,
|
523
|
+
:COMMENT,
|
524
|
+
:CONSTANT,
|
525
|
+
:DOT,
|
526
|
+
:DOT_DOT,
|
527
|
+
:DOT_DOT_DOT,
|
528
|
+
:EMBDOC_BEGIN,
|
529
|
+
:EMBDOC_END,
|
530
|
+
:EMBDOC_LINE,
|
531
|
+
:EMBEXPR_BEGIN,
|
532
|
+
:EMBEXPR_END,
|
533
|
+
:EMBVAR,
|
534
|
+
:EQUAL,
|
535
|
+
:EQUAL_EQUAL,
|
536
|
+
:EQUAL_EQUAL_EQUAL,
|
537
|
+
:EQUAL_GREATER,
|
538
|
+
:EQUAL_TILDE,
|
539
|
+
:FLOAT,
|
540
|
+
:FLOAT_IMAGINARY,
|
541
|
+
:FLOAT_RATIONAL,
|
542
|
+
:FLOAT_RATIONAL_IMAGINARY,
|
543
|
+
:GLOBAL_VARIABLE,
|
544
|
+
:GREATER,
|
545
|
+
:GREATER_EQUAL,
|
546
|
+
:GREATER_GREATER,
|
547
|
+
:GREATER_GREATER_EQUAL,
|
548
|
+
:HEREDOC_END,
|
549
|
+
:HEREDOC_START,
|
550
|
+
:IDENTIFIER,
|
551
|
+
:IGNORED_NEWLINE,
|
552
|
+
:INSTANCE_VARIABLE,
|
553
|
+
:INTEGER,
|
554
|
+
:INTEGER_IMAGINARY,
|
555
|
+
:INTEGER_RATIONAL,
|
556
|
+
:INTEGER_RATIONAL_IMAGINARY,
|
557
|
+
:KEYWORD_ALIAS,
|
558
|
+
:KEYWORD_AND,
|
559
|
+
:KEYWORD_BEGIN,
|
560
|
+
:KEYWORD_BEGIN_UPCASE,
|
561
|
+
:KEYWORD_BREAK,
|
562
|
+
:KEYWORD_CASE,
|
563
|
+
:KEYWORD_CLASS,
|
564
|
+
:KEYWORD_DEF,
|
565
|
+
:KEYWORD_DEFINED,
|
566
|
+
:KEYWORD_DO,
|
567
|
+
:KEYWORD_DO_LOOP,
|
568
|
+
:KEYWORD_ELSE,
|
569
|
+
:KEYWORD_ELSIF,
|
570
|
+
:KEYWORD_END,
|
571
|
+
:KEYWORD_END_UPCASE,
|
572
|
+
:KEYWORD_ENSURE,
|
573
|
+
:KEYWORD_FALSE,
|
574
|
+
:KEYWORD_FOR,
|
575
|
+
:KEYWORD_IF,
|
576
|
+
:KEYWORD_IF_MODIFIER,
|
577
|
+
:KEYWORD_IN,
|
578
|
+
:KEYWORD_MODULE,
|
579
|
+
:KEYWORD_NEXT,
|
580
|
+
:KEYWORD_NIL,
|
581
|
+
:KEYWORD_NOT,
|
582
|
+
:KEYWORD_OR,
|
583
|
+
:KEYWORD_REDO,
|
584
|
+
:KEYWORD_RESCUE,
|
585
|
+
:KEYWORD_RESCUE_MODIFIER,
|
586
|
+
:KEYWORD_RETRY,
|
587
|
+
:KEYWORD_RETURN,
|
588
|
+
:KEYWORD_SELF,
|
589
|
+
:KEYWORD_SUPER,
|
590
|
+
:KEYWORD_THEN,
|
591
|
+
:KEYWORD_TRUE,
|
592
|
+
:KEYWORD_UNDEF,
|
593
|
+
:KEYWORD_UNLESS,
|
594
|
+
:KEYWORD_UNLESS_MODIFIER,
|
595
|
+
:KEYWORD_UNTIL,
|
596
|
+
:KEYWORD_UNTIL_MODIFIER,
|
597
|
+
:KEYWORD_WHEN,
|
598
|
+
:KEYWORD_WHILE,
|
599
|
+
:KEYWORD_WHILE_MODIFIER,
|
600
|
+
:KEYWORD_YIELD,
|
601
|
+
:KEYWORD___ENCODING__,
|
602
|
+
:KEYWORD___FILE__,
|
603
|
+
:KEYWORD___LINE__,
|
604
|
+
:LABEL,
|
605
|
+
:LABEL_END,
|
606
|
+
:LAMBDA_BEGIN,
|
607
|
+
:LESS,
|
608
|
+
:LESS_EQUAL,
|
609
|
+
:LESS_EQUAL_GREATER,
|
610
|
+
:LESS_LESS,
|
611
|
+
:LESS_LESS_EQUAL,
|
612
|
+
:METHOD_NAME,
|
613
|
+
:MINUS,
|
614
|
+
:MINUS_EQUAL,
|
615
|
+
:MINUS_GREATER,
|
616
|
+
:NEWLINE,
|
617
|
+
:NUMBERED_REFERENCE,
|
618
|
+
:PARENTHESIS_LEFT,
|
619
|
+
:PARENTHESIS_LEFT_PARENTHESES,
|
620
|
+
:PARENTHESIS_RIGHT,
|
621
|
+
:PERCENT,
|
622
|
+
:PERCENT_EQUAL,
|
623
|
+
:PERCENT_LOWER_I,
|
624
|
+
:PERCENT_LOWER_W,
|
625
|
+
:PERCENT_LOWER_X,
|
626
|
+
:PERCENT_UPPER_I,
|
627
|
+
:PERCENT_UPPER_W,
|
628
|
+
:PIPE,
|
629
|
+
:PIPE_EQUAL,
|
630
|
+
:PIPE_PIPE,
|
631
|
+
:PIPE_PIPE_EQUAL,
|
632
|
+
:PLUS,
|
633
|
+
:PLUS_EQUAL,
|
634
|
+
:QUESTION_MARK,
|
635
|
+
:REGEXP_BEGIN,
|
636
|
+
:REGEXP_END,
|
637
|
+
:SEMICOLON,
|
638
|
+
:SLASH,
|
639
|
+
:SLASH_EQUAL,
|
640
|
+
:STAR,
|
641
|
+
:STAR_EQUAL,
|
642
|
+
:STAR_STAR,
|
643
|
+
:STAR_STAR_EQUAL,
|
644
|
+
:STRING_BEGIN,
|
645
|
+
:STRING_CONTENT,
|
646
|
+
:STRING_END,
|
647
|
+
:SYMBOL_BEGIN,
|
648
|
+
:TILDE,
|
649
|
+
:UAMPERSAND,
|
650
|
+
:UCOLON_COLON,
|
651
|
+
:UDOT_DOT,
|
652
|
+
:UDOT_DOT_DOT,
|
653
|
+
:UMINUS,
|
654
|
+
:UMINUS_NUM,
|
655
|
+
:UPLUS,
|
656
|
+
:USTAR,
|
657
|
+
:USTAR_STAR,
|
658
|
+
:WORDS_SEP,
|
659
|
+
:__END__,
|
660
|
+
]
|
661
|
+
end
|
662
|
+
end
|