jruby-prism-parser 0.23.0.pre.SNAPSHOT-java → 1.4.0-java

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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +284 -1
  4. data/CONTRIBUTING.md +0 -4
  5. data/Makefile +25 -18
  6. data/README.md +57 -6
  7. data/config.yml +1724 -140
  8. data/docs/build_system.md +39 -11
  9. data/docs/configuration.md +4 -0
  10. data/docs/cruby_compilation.md +1 -1
  11. data/docs/fuzzing.md +1 -1
  12. data/docs/parser_translation.md +14 -9
  13. data/docs/parsing_rules.md +4 -1
  14. data/docs/releasing.md +9 -11
  15. data/docs/relocation.md +34 -0
  16. data/docs/ripper_translation.md +72 -0
  17. data/docs/ruby_api.md +2 -1
  18. data/docs/serialization.md +29 -5
  19. data/ext/prism/api_node.c +3841 -2000
  20. data/ext/prism/api_pack.c +9 -0
  21. data/ext/prism/extconf.rb +55 -34
  22. data/ext/prism/extension.c +597 -346
  23. data/ext/prism/extension.h +6 -5
  24. data/include/prism/ast.h +2612 -455
  25. data/include/prism/defines.h +160 -2
  26. data/include/prism/diagnostic.h +188 -76
  27. data/include/prism/encoding.h +22 -4
  28. data/include/prism/node.h +89 -17
  29. data/include/prism/options.h +224 -12
  30. data/include/prism/pack.h +11 -0
  31. data/include/prism/parser.h +267 -66
  32. data/include/prism/prettyprint.h +8 -0
  33. data/include/prism/regexp.h +18 -8
  34. data/include/prism/static_literals.h +121 -0
  35. data/include/prism/util/pm_buffer.h +75 -2
  36. data/include/prism/util/pm_char.h +1 -2
  37. data/include/prism/util/pm_constant_pool.h +18 -9
  38. data/include/prism/util/pm_integer.h +126 -0
  39. data/include/prism/util/pm_list.h +1 -1
  40. data/include/prism/util/pm_newline_list.h +23 -3
  41. data/include/prism/util/pm_string.h +48 -8
  42. data/include/prism/version.h +3 -3
  43. data/include/prism.h +99 -5
  44. data/jruby-prism.jar +0 -0
  45. data/lib/prism/compiler.rb +11 -1
  46. data/lib/prism/desugar_compiler.rb +264 -80
  47. data/lib/prism/dispatcher.rb +45 -1
  48. data/lib/prism/dot_visitor.rb +201 -77
  49. data/lib/prism/dsl.rb +672 -457
  50. data/lib/prism/ffi.rb +308 -94
  51. data/lib/prism/inspect_visitor.rb +2389 -0
  52. data/lib/prism/lex_compat.rb +35 -16
  53. data/lib/prism/mutation_compiler.rb +24 -8
  54. data/lib/prism/node.rb +9712 -8931
  55. data/lib/prism/node_ext.rb +328 -32
  56. data/lib/prism/pack.rb +4 -0
  57. data/lib/prism/parse_result/comments.rb +34 -24
  58. data/lib/prism/parse_result/errors.rb +65 -0
  59. data/lib/prism/parse_result/newlines.rb +102 -12
  60. data/lib/prism/parse_result.rb +458 -46
  61. data/lib/prism/pattern.rb +28 -10
  62. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  63. data/lib/prism/polyfill/byteindex.rb +13 -0
  64. data/lib/prism/polyfill/unpack1.rb +14 -0
  65. data/lib/prism/reflection.rb +413 -0
  66. data/lib/prism/relocation.rb +504 -0
  67. data/lib/prism/serialize.rb +1940 -902
  68. data/lib/prism/string_query.rb +30 -0
  69. data/lib/prism/translation/parser/builder.rb +61 -0
  70. data/lib/prism/translation/parser/compiler.rb +569 -195
  71. data/lib/prism/translation/parser/lexer.rb +516 -39
  72. data/lib/prism/translation/parser.rb +188 -11
  73. data/lib/prism/translation/parser33.rb +12 -0
  74. data/lib/prism/translation/parser34.rb +12 -0
  75. data/lib/prism/translation/parser35.rb +12 -0
  76. data/lib/prism/translation/ripper/sexp.rb +125 -0
  77. data/lib/prism/translation/ripper/shim.rb +5 -0
  78. data/lib/prism/translation/ripper.rb +3267 -386
  79. data/lib/prism/translation/ruby_parser.rb +194 -69
  80. data/lib/prism/translation.rb +4 -1
  81. data/lib/prism/version.rb +1 -1
  82. data/lib/prism/visitor.rb +13 -0
  83. data/lib/prism.rb +17 -27
  84. data/prism.gemspec +59 -17
  85. data/rbi/prism/compiler.rbi +12 -0
  86. data/rbi/prism/dsl.rbi +524 -0
  87. data/rbi/prism/inspect_visitor.rbi +12 -0
  88. data/rbi/prism/node.rbi +8722 -0
  89. data/rbi/prism/node_ext.rbi +107 -0
  90. data/rbi/prism/parse_result.rbi +404 -0
  91. data/rbi/prism/reflection.rbi +58 -0
  92. data/rbi/prism/string_query.rbi +12 -0
  93. data/rbi/prism/translation/parser.rbi +11 -0
  94. data/rbi/prism/translation/parser33.rbi +6 -0
  95. data/rbi/prism/translation/parser34.rbi +6 -0
  96. data/rbi/prism/translation/parser35.rbi +6 -0
  97. data/rbi/prism/translation/ripper.rbi +15 -0
  98. data/rbi/prism/visitor.rbi +473 -0
  99. data/rbi/prism.rbi +44 -7745
  100. data/sig/prism/compiler.rbs +9 -0
  101. data/sig/prism/dispatcher.rbs +16 -0
  102. data/sig/prism/dot_visitor.rbs +6 -0
  103. data/sig/prism/dsl.rbs +351 -0
  104. data/sig/prism/inspect_visitor.rbs +22 -0
  105. data/sig/prism/lex_compat.rbs +10 -0
  106. data/sig/prism/mutation_compiler.rbs +159 -0
  107. data/sig/prism/node.rbs +3614 -0
  108. data/sig/prism/node_ext.rbs +82 -0
  109. data/sig/prism/pack.rbs +43 -0
  110. data/sig/prism/parse_result.rbs +192 -0
  111. data/sig/prism/pattern.rbs +13 -0
  112. data/sig/prism/reflection.rbs +50 -0
  113. data/sig/prism/relocation.rbs +185 -0
  114. data/sig/prism/serialize.rbs +8 -0
  115. data/sig/prism/string_query.rbs +11 -0
  116. data/sig/prism/visitor.rbs +169 -0
  117. data/sig/prism.rbs +248 -4767
  118. data/src/diagnostic.c +672 -230
  119. data/src/encoding.c +211 -108
  120. data/src/node.c +7541 -1653
  121. data/src/options.c +135 -20
  122. data/src/pack.c +33 -17
  123. data/src/prettyprint.c +1546 -1488
  124. data/src/prism.c +7822 -3044
  125. data/src/regexp.c +225 -73
  126. data/src/serialize.c +101 -77
  127. data/src/static_literals.c +617 -0
  128. data/src/token_type.c +14 -13
  129. data/src/util/pm_buffer.c +187 -20
  130. data/src/util/pm_char.c +5 -5
  131. data/src/util/pm_constant_pool.c +39 -19
  132. data/src/util/pm_integer.c +670 -0
  133. data/src/util/pm_list.c +1 -1
  134. data/src/util/pm_newline_list.c +49 -8
  135. data/src/util/pm_string.c +213 -33
  136. data/src/util/pm_strncasecmp.c +13 -1
  137. data/src/util/pm_strpbrk.c +32 -6
  138. metadata +59 -21
  139. data/docs/ripper.md +0 -36
  140. data/include/prism/util/pm_state_stack.h +0 -42
  141. data/include/prism/util/pm_string_list.h +0 -44
  142. data/lib/prism/debug.rb +0 -206
  143. data/lib/prism/node_inspector.rb +0 -68
  144. data/lib/prism/translation/parser/rubocop.rb +0 -37
  145. data/rbi/prism_static.rbi +0 -207
  146. data/sig/prism_static.rbs +0 -201
  147. data/src/util/pm_state_stack.c +0 -25
  148. data/src/util/pm_string_list.c +0 -28
@@ -1,6 +1,255 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prism
4
+ class DesugarAndWriteNode # :nodoc:
5
+ include DSL
6
+
7
+ attr_reader :node, :default_source, :read_class, :write_class, :arguments
8
+
9
+ def initialize(node, default_source, read_class, write_class, **arguments)
10
+ @node = node
11
+ @default_source = default_source
12
+ @read_class = read_class
13
+ @write_class = write_class
14
+ @arguments = arguments
15
+ end
16
+
17
+ # Desugar `x &&= y` to `x && x = y`
18
+ def compile
19
+ and_node(
20
+ location: node.location,
21
+ left: public_send(read_class, location: node.name_loc, **arguments),
22
+ right: public_send(
23
+ write_class,
24
+ location: node.location,
25
+ **arguments,
26
+ name_loc: node.name_loc,
27
+ value: node.value,
28
+ operator_loc: node.operator_loc
29
+ ),
30
+ operator_loc: node.operator_loc
31
+ )
32
+ end
33
+ end
34
+
35
+ class DesugarOrWriteDefinedNode # :nodoc:
36
+ include DSL
37
+
38
+ attr_reader :node, :default_source, :read_class, :write_class, :arguments
39
+
40
+ def initialize(node, default_source, read_class, write_class, **arguments)
41
+ @node = node
42
+ @default_source = default_source
43
+ @read_class = read_class
44
+ @write_class = write_class
45
+ @arguments = arguments
46
+ end
47
+
48
+ # Desugar `x ||= y` to `defined?(x) ? x : x = y`
49
+ def compile
50
+ if_node(
51
+ location: node.location,
52
+ if_keyword_loc: node.operator_loc,
53
+ predicate: defined_node(
54
+ location: node.name_loc,
55
+ value: public_send(read_class, location: node.name_loc, **arguments),
56
+ keyword_loc: node.operator_loc
57
+ ),
58
+ then_keyword_loc: node.operator_loc,
59
+ statements: statements_node(
60
+ location: node.location,
61
+ body: [public_send(read_class, location: node.name_loc, **arguments)]
62
+ ),
63
+ subsequent: else_node(
64
+ location: node.location,
65
+ else_keyword_loc: node.operator_loc,
66
+ statements: statements_node(
67
+ location: node.location,
68
+ body: [
69
+ public_send(
70
+ write_class,
71
+ location: node.location,
72
+ **arguments,
73
+ name_loc: node.name_loc,
74
+ value: node.value,
75
+ operator_loc: node.operator_loc
76
+ )
77
+ ]
78
+ ),
79
+ end_keyword_loc: node.operator_loc
80
+ ),
81
+ end_keyword_loc: node.operator_loc
82
+ )
83
+ end
84
+ end
85
+
86
+ class DesugarOperatorWriteNode # :nodoc:
87
+ include DSL
88
+
89
+ attr_reader :node, :default_source, :read_class, :write_class, :arguments
90
+
91
+ def initialize(node, default_source, read_class, write_class, **arguments)
92
+ @node = node
93
+ @default_source = default_source
94
+ @read_class = read_class
95
+ @write_class = write_class
96
+ @arguments = arguments
97
+ end
98
+
99
+ # Desugar `x += y` to `x = x + y`
100
+ def compile
101
+ binary_operator_loc = node.binary_operator_loc.chop
102
+
103
+ public_send(
104
+ write_class,
105
+ location: node.location,
106
+ **arguments,
107
+ name_loc: node.name_loc,
108
+ value: call_node(
109
+ location: node.location,
110
+ receiver: public_send(
111
+ read_class,
112
+ location: node.name_loc,
113
+ **arguments
114
+ ),
115
+ name: binary_operator_loc.slice.to_sym,
116
+ message_loc: binary_operator_loc,
117
+ arguments: arguments_node(
118
+ location: node.value.location,
119
+ arguments: [node.value]
120
+ )
121
+ ),
122
+ operator_loc: node.binary_operator_loc.copy(
123
+ start_offset: node.binary_operator_loc.end_offset - 1,
124
+ length: 1
125
+ )
126
+ )
127
+ end
128
+ end
129
+
130
+ class DesugarOrWriteNode # :nodoc:
131
+ include DSL
132
+
133
+ attr_reader :node, :default_source, :read_class, :write_class, :arguments
134
+
135
+ def initialize(node, default_source, read_class, write_class, **arguments)
136
+ @node = node
137
+ @default_source = default_source
138
+ @read_class = read_class
139
+ @write_class = write_class
140
+ @arguments = arguments
141
+ end
142
+
143
+ # Desugar `x ||= y` to `x || x = y`
144
+ def compile
145
+ or_node(
146
+ location: node.location,
147
+ left: public_send(read_class, location: node.name_loc, **arguments),
148
+ right: public_send(
149
+ write_class,
150
+ location: node.location,
151
+ **arguments,
152
+ name_loc: node.name_loc,
153
+ value: node.value,
154
+ operator_loc: node.operator_loc
155
+ ),
156
+ operator_loc: node.operator_loc
157
+ )
158
+ end
159
+ end
160
+
161
+ private_constant :DesugarAndWriteNode, :DesugarOrWriteNode, :DesugarOrWriteDefinedNode, :DesugarOperatorWriteNode
162
+
163
+ class ClassVariableAndWriteNode
164
+ def desugar # :nodoc:
165
+ DesugarAndWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
166
+ end
167
+ end
168
+
169
+ class ClassVariableOrWriteNode
170
+ def desugar # :nodoc:
171
+ DesugarOrWriteDefinedNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
172
+ end
173
+ end
174
+
175
+ class ClassVariableOperatorWriteNode
176
+ def desugar # :nodoc:
177
+ DesugarOperatorWriteNode.new(self, source, :class_variable_read_node, :class_variable_write_node, name: name).compile
178
+ end
179
+ end
180
+
181
+ class ConstantAndWriteNode
182
+ def desugar # :nodoc:
183
+ DesugarAndWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
184
+ end
185
+ end
186
+
187
+ class ConstantOrWriteNode
188
+ def desugar # :nodoc:
189
+ DesugarOrWriteDefinedNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
190
+ end
191
+ end
192
+
193
+ class ConstantOperatorWriteNode
194
+ def desugar # :nodoc:
195
+ DesugarOperatorWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile
196
+ end
197
+ end
198
+
199
+ class GlobalVariableAndWriteNode
200
+ def desugar # :nodoc:
201
+ DesugarAndWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
202
+ end
203
+ end
204
+
205
+ class GlobalVariableOrWriteNode
206
+ def desugar # :nodoc:
207
+ DesugarOrWriteDefinedNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
208
+ end
209
+ end
210
+
211
+ class GlobalVariableOperatorWriteNode
212
+ def desugar # :nodoc:
213
+ DesugarOperatorWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile
214
+ end
215
+ end
216
+
217
+ class InstanceVariableAndWriteNode
218
+ def desugar # :nodoc:
219
+ DesugarAndWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
220
+ end
221
+ end
222
+
223
+ class InstanceVariableOrWriteNode
224
+ def desugar # :nodoc:
225
+ DesugarOrWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
226
+ end
227
+ end
228
+
229
+ class InstanceVariableOperatorWriteNode
230
+ def desugar # :nodoc:
231
+ DesugarOperatorWriteNode.new(self, source, :instance_variable_read_node, :instance_variable_write_node, name: name).compile
232
+ end
233
+ end
234
+
235
+ class LocalVariableAndWriteNode
236
+ def desugar # :nodoc:
237
+ DesugarAndWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
238
+ end
239
+ end
240
+
241
+ class LocalVariableOrWriteNode
242
+ def desugar # :nodoc:
243
+ DesugarOrWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
244
+ end
245
+ end
246
+
247
+ class LocalVariableOperatorWriteNode
248
+ def desugar # :nodoc:
249
+ DesugarOperatorWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile
250
+ end
251
+ end
252
+
4
253
  # DesugarCompiler is a compiler that desugars Ruby code into a more primitive
5
254
  # form. This is useful for consumers that want to deal with fewer node types.
6
255
  class DesugarCompiler < MutationCompiler
@@ -10,7 +259,7 @@ module Prism
10
259
  #
11
260
  # @@foo && @@foo = bar
12
261
  def visit_class_variable_and_write_node(node)
13
- desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
262
+ node.desugar
14
263
  end
15
264
 
16
265
  # @@foo ||= bar
@@ -19,7 +268,7 @@ module Prism
19
268
  #
20
269
  # defined?(@@foo) ? @@foo : @@foo = bar
21
270
  def visit_class_variable_or_write_node(node)
22
- desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
271
+ node.desugar
23
272
  end
24
273
 
25
274
  # @@foo += bar
@@ -28,7 +277,7 @@ module Prism
28
277
  #
29
278
  # @@foo = @@foo + bar
30
279
  def visit_class_variable_operator_write_node(node)
31
- desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
280
+ node.desugar
32
281
  end
33
282
 
34
283
  # Foo &&= bar
@@ -37,7 +286,7 @@ module Prism
37
286
  #
38
287
  # Foo && Foo = bar
39
288
  def visit_constant_and_write_node(node)
40
- desugar_and_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
289
+ node.desugar
41
290
  end
42
291
 
43
292
  # Foo ||= bar
@@ -46,7 +295,7 @@ module Prism
46
295
  #
47
296
  # defined?(Foo) ? Foo : Foo = bar
48
297
  def visit_constant_or_write_node(node)
49
- desugar_or_write_defined_node(node, ConstantReadNode, ConstantWriteNode, node.name)
298
+ node.desugar
50
299
  end
51
300
 
52
301
  # Foo += bar
@@ -55,7 +304,7 @@ module Prism
55
304
  #
56
305
  # Foo = Foo + bar
57
306
  def visit_constant_operator_write_node(node)
58
- desugar_operator_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
307
+ node.desugar
59
308
  end
60
309
 
61
310
  # $foo &&= bar
@@ -64,7 +313,7 @@ module Prism
64
313
  #
65
314
  # $foo && $foo = bar
66
315
  def visit_global_variable_and_write_node(node)
67
- desugar_and_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
316
+ node.desugar
68
317
  end
69
318
 
70
319
  # $foo ||= bar
@@ -73,7 +322,7 @@ module Prism
73
322
  #
74
323
  # defined?($foo) ? $foo : $foo = bar
75
324
  def visit_global_variable_or_write_node(node)
76
- desugar_or_write_defined_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
325
+ node.desugar
77
326
  end
78
327
 
79
328
  # $foo += bar
@@ -82,7 +331,7 @@ module Prism
82
331
  #
83
332
  # $foo = $foo + bar
84
333
  def visit_global_variable_operator_write_node(node)
85
- desugar_operator_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
334
+ node.desugar
86
335
  end
87
336
 
88
337
  # @foo &&= bar
@@ -91,7 +340,7 @@ module Prism
91
340
  #
92
341
  # @foo && @foo = bar
93
342
  def visit_instance_variable_and_write_node(node)
94
- desugar_and_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
343
+ node.desugar
95
344
  end
96
345
 
97
346
  # @foo ||= bar
@@ -100,7 +349,7 @@ module Prism
100
349
  #
101
350
  # @foo || @foo = bar
102
351
  def visit_instance_variable_or_write_node(node)
103
- desugar_or_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
352
+ node.desugar
104
353
  end
105
354
 
106
355
  # @foo += bar
@@ -109,7 +358,7 @@ module Prism
109
358
  #
110
359
  # @foo = @foo + bar
111
360
  def visit_instance_variable_operator_write_node(node)
112
- desugar_operator_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
361
+ node.desugar
113
362
  end
114
363
 
115
364
  # foo &&= bar
@@ -118,7 +367,7 @@ module Prism
118
367
  #
119
368
  # foo && foo = bar
120
369
  def visit_local_variable_and_write_node(node)
121
- desugar_and_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
370
+ node.desugar
122
371
  end
123
372
 
124
373
  # foo ||= bar
@@ -127,7 +376,7 @@ module Prism
127
376
  #
128
377
  # foo || foo = bar
129
378
  def visit_local_variable_or_write_node(node)
130
- desugar_or_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
379
+ node.desugar
131
380
  end
132
381
 
133
382
  # foo += bar
@@ -136,72 +385,7 @@ module Prism
136
385
  #
137
386
  # foo = foo + bar
138
387
  def visit_local_variable_operator_write_node(node)
139
- desugar_operator_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
140
- end
141
-
142
- private
143
-
144
- # Desugar `x &&= y` to `x && x = y`
145
- def desugar_and_write_node(node, read_class, write_class, *arguments)
146
- AndNode.new(
147
- read_class.new(*arguments, node.name_loc),
148
- write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
149
- node.operator_loc,
150
- node.location
151
- )
152
- end
153
-
154
- # Desugar `x += y` to `x = x + y`
155
- def desugar_operator_write_node(node, read_class, write_class, *arguments)
156
- write_class.new(
157
- *arguments,
158
- node.name_loc,
159
- CallNode.new(
160
- 0,
161
- read_class.new(*arguments, node.name_loc),
162
- nil,
163
- node.operator_loc.slice.chomp("="),
164
- node.operator_loc.copy(length: node.operator_loc.length - 1),
165
- nil,
166
- ArgumentsNode.new(0, [node.value], node.value.location),
167
- nil,
168
- nil,
169
- node.location
170
- ),
171
- node.operator_loc.copy(start_offset: node.operator_loc.end_offset - 1, length: 1),
172
- node.location
173
- )
174
- end
175
-
176
- # Desugar `x ||= y` to `x || x = y`
177
- def desugar_or_write_node(node, read_class, write_class, *arguments)
178
- OrNode.new(
179
- read_class.new(*arguments, node.name_loc),
180
- write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
181
- node.operator_loc,
182
- node.location
183
- )
184
- end
185
-
186
- # Desugar `x ||= y` to `defined?(x) ? x : x = y`
187
- def desugar_or_write_defined_node(node, read_class, write_class, *arguments)
188
- IfNode.new(
189
- node.operator_loc,
190
- DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
191
- node.operator_loc,
192
- StatementsNode.new([read_class.new(*arguments, node.name_loc)], node.location),
193
- ElseNode.new(
194
- node.operator_loc,
195
- StatementsNode.new(
196
- [write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location)],
197
- node.location
198
- ),
199
- node.operator_loc,
200
- node.location
201
- ),
202
- node.operator_loc,
203
- node.location
204
- )
388
+ node.desugar
205
389
  end
206
390
  end
207
391
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  =begin
3
4
  This file is generated by the templates/template.rb script and should not be
4
5
  modified manually. See templates/lib/prism/dispatcher.rb.erb
@@ -21,7 +22,8 @@ module Prism
21
22
  # end
22
23
  # end
23
24
  #
24
- # dispatcher = Dispatcher.new
25
+ # listener = OctalListener.new
26
+ # dispatcher = Prism::Dispatcher.new
25
27
  # dispatcher.register(listener, :on_integer_node_enter)
26
28
  #
27
29
  # Then, you can walk any number of trees and dispatch events to the listeners:
@@ -761,6 +763,22 @@ module Prism
761
763
  listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
762
764
  end
763
765
 
766
+ # Dispatch enter and leave events for ItLocalVariableReadNode nodes and continue
767
+ # walking the tree.
768
+ def visit_it_local_variable_read_node(node)
769
+ listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
770
+ super
771
+ listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
772
+ end
773
+
774
+ # Dispatch enter and leave events for ItParametersNode nodes and continue
775
+ # walking the tree.
776
+ def visit_it_parameters_node(node)
777
+ listeners[:on_it_parameters_node_enter]&.each { |listener| listener.on_it_parameters_node_enter(node) }
778
+ super
779
+ listeners[:on_it_parameters_node_leave]&.each { |listener| listener.on_it_parameters_node_leave(node) }
780
+ end
781
+
764
782
  # Dispatch enter and leave events for KeywordHashNode nodes and continue
765
783
  # walking the tree.
766
784
  def visit_keyword_hash_node(node)
@@ -1113,6 +1131,14 @@ module Prism
1113
1131
  listeners[:on_self_node_leave]&.each { |listener| listener.on_self_node_leave(node) }
1114
1132
  end
1115
1133
 
1134
+ # Dispatch enter and leave events for ShareableConstantNode nodes and continue
1135
+ # walking the tree.
1136
+ def visit_shareable_constant_node(node)
1137
+ listeners[:on_shareable_constant_node_enter]&.each { |listener| listener.on_shareable_constant_node_enter(node) }
1138
+ super
1139
+ listeners[:on_shareable_constant_node_leave]&.each { |listener| listener.on_shareable_constant_node_leave(node) }
1140
+ end
1141
+
1116
1142
  # Dispatch enter and leave events for SingletonClassNode nodes and continue
1117
1143
  # walking the tree.
1118
1144
  def visit_singleton_class_node(node)
@@ -1778,6 +1804,18 @@ module Prism
1778
1804
  listeners[:on_interpolated_x_string_node_leave]&.each { |listener| listener.on_interpolated_x_string_node_leave(node) }
1779
1805
  end
1780
1806
 
1807
+ # Dispatch enter and leave events for ItLocalVariableReadNode nodes.
1808
+ def visit_it_local_variable_read_node(node)
1809
+ listeners[:on_it_local_variable_read_node_enter]&.each { |listener| listener.on_it_local_variable_read_node_enter(node) }
1810
+ listeners[:on_it_local_variable_read_node_leave]&.each { |listener| listener.on_it_local_variable_read_node_leave(node) }
1811
+ end
1812
+
1813
+ # Dispatch enter and leave events for ItParametersNode nodes.
1814
+ def visit_it_parameters_node(node)
1815
+ listeners[:on_it_parameters_node_enter]&.each { |listener| listener.on_it_parameters_node_enter(node) }
1816
+ listeners[:on_it_parameters_node_leave]&.each { |listener| listener.on_it_parameters_node_leave(node) }
1817
+ end
1818
+
1781
1819
  # Dispatch enter and leave events for KeywordHashNode nodes.
1782
1820
  def visit_keyword_hash_node(node)
1783
1821
  listeners[:on_keyword_hash_node_enter]&.each { |listener| listener.on_keyword_hash_node_enter(node) }
@@ -2042,6 +2080,12 @@ module Prism
2042
2080
  listeners[:on_self_node_leave]&.each { |listener| listener.on_self_node_leave(node) }
2043
2081
  end
2044
2082
 
2083
+ # Dispatch enter and leave events for ShareableConstantNode nodes.
2084
+ def visit_shareable_constant_node(node)
2085
+ listeners[:on_shareable_constant_node_enter]&.each { |listener| listener.on_shareable_constant_node_enter(node) }
2086
+ listeners[:on_shareable_constant_node_leave]&.each { |listener| listener.on_shareable_constant_node_leave(node) }
2087
+ end
2088
+
2045
2089
  # Dispatch enter and leave events for SingletonClassNode nodes.
2046
2090
  def visit_singleton_class_node(node)
2047
2091
  listeners[:on_singleton_class_node_enter]&.each { |listener| listener.on_singleton_class_node_enter(node) }