prism 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/Makefile +5 -5
  4. data/README.md +2 -2
  5. data/config.yml +26 -13
  6. data/docs/build_system.md +6 -6
  7. data/docs/building.md +1 -1
  8. data/docs/configuration.md +1 -0
  9. data/docs/encoding.md +68 -32
  10. data/docs/heredocs.md +1 -1
  11. data/docs/javascript.md +29 -1
  12. data/docs/ruby_api.md +14 -0
  13. data/ext/prism/api_node.c +74 -45
  14. data/ext/prism/extconf.rb +91 -127
  15. data/ext/prism/extension.c +1 -1
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +148 -133
  18. data/include/prism/diagnostic.h +27 -1
  19. data/include/prism/enc/pm_encoding.h +42 -1
  20. data/include/prism/parser.h +6 -0
  21. data/include/prism/version.h +3 -3
  22. data/lib/prism/compiler.rb +3 -3
  23. data/lib/prism/debug.rb +4 -0
  24. data/lib/prism/desugar_compiler.rb +1 -0
  25. data/lib/prism/dispatcher.rb +14 -14
  26. data/lib/prism/dot_visitor.rb +4334 -0
  27. data/lib/prism/dsl.rb +11 -11
  28. data/lib/prism/ffi.rb +3 -3
  29. data/lib/prism/mutation_compiler.rb +6 -6
  30. data/lib/prism/node.rb +182 -113
  31. data/lib/prism/node_ext.rb +61 -3
  32. data/lib/prism/parse_result.rb +46 -12
  33. data/lib/prism/serialize.rb +125 -131
  34. data/lib/prism/visitor.rb +3 -3
  35. data/lib/prism.rb +1 -0
  36. data/prism.gemspec +5 -1
  37. data/rbi/prism.rbi +83 -54
  38. data/sig/prism.rbs +47 -32
  39. data/src/diagnostic.c +61 -3
  40. data/src/enc/pm_big5.c +63 -0
  41. data/src/enc/pm_cp51932.c +57 -0
  42. data/src/enc/pm_euc_jp.c +10 -0
  43. data/src/enc/pm_gbk.c +5 -2
  44. data/src/enc/pm_tables.c +1478 -148
  45. data/src/node.c +33 -21
  46. data/src/prettyprint.c +1027 -925
  47. data/src/prism.c +925 -374
  48. data/src/regexp.c +12 -12
  49. data/src/serialize.c +36 -9
  50. metadata +6 -2
@@ -25,40 +25,50 @@ module Prism
25
25
 
26
26
  # Perform a byteslice on the source code using the given byte offset and
27
27
  # byte length.
28
- def slice(offset, length)
29
- source.byteslice(offset, length)
28
+ def slice(byte_offset, length)
29
+ source.byteslice(byte_offset, length)
30
30
  end
31
31
 
32
32
  # Binary search through the offsets to find the line number for the given
33
33
  # byte offset.
34
- def line(value)
35
- start_line + find_line(value)
34
+ def line(byte_offset)
35
+ start_line + find_line(byte_offset)
36
36
  end
37
37
 
38
38
  # Return the byte offset of the start of the line corresponding to the given
39
39
  # byte offset.
40
- def line_offset(value)
41
- offsets[find_line(value)]
40
+ def line_start(byte_offset)
41
+ offsets[find_line(byte_offset)]
42
42
  end
43
43
 
44
44
  # Return the column number for the given byte offset.
45
- def column(value)
46
- value - offsets[find_line(value)]
45
+ def column(byte_offset)
46
+ byte_offset - line_start(byte_offset)
47
+ end
48
+
49
+ # Return the character offset for the given byte offset.
50
+ def character_offset(byte_offset)
51
+ source.byteslice(0, byte_offset).length
52
+ end
53
+
54
+ # Return the column number in characters for the given byte offset.
55
+ def character_column(byte_offset)
56
+ character_offset(byte_offset) - character_offset(line_start(byte_offset))
47
57
  end
48
58
 
49
59
  private
50
60
 
51
61
  # Binary search through the offsets to find the line number for the given
52
62
  # byte offset.
53
- def find_line(value)
63
+ def find_line(byte_offset)
54
64
  left = 0
55
65
  right = offsets.length - 1
56
66
 
57
67
  while left <= right
58
68
  mid = left + (right - left) / 2
59
- return mid if offsets[mid] == value
69
+ return mid if offsets[mid] == byte_offset
60
70
 
61
- if offsets[mid] < value
71
+ if offsets[mid] < byte_offset
62
72
  left = mid + 1
63
73
  else
64
74
  right = mid - 1
@@ -121,11 +131,23 @@ module Prism
121
131
  source.slice(start_offset, length)
122
132
  end
123
133
 
134
+ # The character offset from the beginning of the source where this location
135
+ # starts.
136
+ def start_character_offset
137
+ source.character_offset(start_offset)
138
+ end
139
+
124
140
  # The byte offset from the beginning of the source where this location ends.
125
141
  def end_offset
126
142
  start_offset + length
127
143
  end
128
144
 
145
+ # The character offset from the beginning of the source where this location
146
+ # ends.
147
+ def end_character_offset
148
+ source.character_offset(end_offset)
149
+ end
150
+
129
151
  # The line number where this location starts.
130
152
  def start_line
131
153
  source.line(start_offset)
@@ -133,7 +155,7 @@ module Prism
133
155
 
134
156
  # The content of the line where this location starts before this location.
135
157
  def start_line_slice
136
- offset = source.line_offset(start_offset)
158
+ offset = source.line_start(start_offset)
137
159
  source.slice(offset, start_offset - offset)
138
160
  end
139
161
 
@@ -148,12 +170,24 @@ module Prism
148
170
  source.column(start_offset)
149
171
  end
150
172
 
173
+ # The column number in characters where this location ends from the start of
174
+ # the line.
175
+ def start_character_column
176
+ source.character_column(start_offset)
177
+ end
178
+
151
179
  # The column number in bytes where this location ends from the start of the
152
180
  # line.
153
181
  def end_column
154
182
  source.column(end_offset)
155
183
  end
156
184
 
185
+ # The column number in characters where this location ends from the start of
186
+ # the line.
187
+ def end_character_column
188
+ source.character_column(end_offset)
189
+ end
190
+
157
191
  # Implement the hash pattern matching interface for Location.
158
192
  def deconstruct_keys(keys)
159
193
  { start_offset: start_offset, end_offset: end_offset }
@@ -27,11 +27,11 @@ module Prism
27
27
 
28
28
  # The minor version of prism that we are expecting to find in the serialized
29
29
  # strings.
30
- MINOR_VERSION = 17
30
+ MINOR_VERSION = 18
31
31
 
32
32
  # The patch version of prism that we are expecting to find in the serialized
33
33
  # strings.
34
- PATCH_VERSION = 1
34
+ PATCH_VERSION = 0
35
35
 
36
36
  # Deserialize the AST represented by the given string into a parse result.
37
37
  def self.load(input, serialized)
@@ -80,12 +80,9 @@ module Prism
80
80
  end
81
81
 
82
82
  def load_encoding
83
- Encoding.find(io.read(load_varint))
84
- end
85
-
86
- def load_force_encoding
87
- @encoding = load_encoding
83
+ @encoding = Encoding.find(io.read(load_varint))
88
84
  @input = input.force_encoding(@encoding).freeze
85
+ @encoding
89
86
  end
90
87
 
91
88
  def load_start_line
@@ -128,10 +125,7 @@ module Prism
128
125
  encoding = load_encoding
129
126
  load_start_line
130
127
  comments, magic_comments, errors, warnings = load_metadata
131
-
132
- if encoding != @encoding
133
- tokens.each { |token,| token.value.force_encoding(encoding) }
134
- end
128
+ tokens.each { |token,| token.value.force_encoding(encoding) }
135
129
 
136
130
  raise "Expected to consume all bytes while deserializing" unless @io.eof?
137
131
  Prism::ParseResult.new(tokens, comments, magic_comments, errors, warnings, @source)
@@ -139,7 +133,7 @@ module Prism
139
133
 
140
134
  def load_nodes
141
135
  load_header
142
- load_force_encoding
136
+ load_encoding
143
137
  load_start_line
144
138
 
145
139
  comments, magic_comments, errors, warnings = load_metadata
@@ -289,228 +283,228 @@ module Prism
289
283
  when 22 then
290
284
  CapturePatternNode.new(load_node, load_node, load_location, location)
291
285
  when 23 then
292
- CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
286
+ CaseMatchNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
293
287
  when 24 then
294
- 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)
288
+ CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
295
289
  when 25 then
296
- ClassVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
290
+ 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)
297
291
  when 26 then
298
- ClassVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
292
+ ClassVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
299
293
  when 27 then
300
- ClassVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
294
+ ClassVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
301
295
  when 28 then
302
- ClassVariableReadNode.new(load_required_constant, location)
296
+ ClassVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
303
297
  when 29 then
304
- ClassVariableTargetNode.new(load_required_constant, location)
298
+ ClassVariableReadNode.new(load_required_constant, location)
305
299
  when 30 then
306
- ClassVariableWriteNode.new(load_required_constant, load_location, load_node, load_optional_location, location)
300
+ ClassVariableTargetNode.new(load_required_constant, location)
307
301
  when 31 then
308
- ConstantAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
302
+ ClassVariableWriteNode.new(load_required_constant, load_location, load_node, load_optional_location, location)
309
303
  when 32 then
310
- ConstantOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
304
+ ConstantAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
311
305
  when 33 then
312
- ConstantOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
306
+ ConstantOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
313
307
  when 34 then
314
- ConstantPathAndWriteNode.new(load_node, load_location, load_node, location)
308
+ ConstantOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
315
309
  when 35 then
316
- ConstantPathNode.new(load_optional_node, load_node, load_location, location)
310
+ ConstantPathAndWriteNode.new(load_node, load_location, load_node, location)
317
311
  when 36 then
318
- ConstantPathOperatorWriteNode.new(load_node, load_location, load_node, load_required_constant, location)
312
+ ConstantPathNode.new(load_optional_node, load_node, load_location, location)
319
313
  when 37 then
320
- ConstantPathOrWriteNode.new(load_node, load_location, load_node, location)
314
+ ConstantPathOperatorWriteNode.new(load_node, load_location, load_node, load_required_constant, location)
321
315
  when 38 then
322
- ConstantPathTargetNode.new(load_optional_node, load_node, load_location, location)
316
+ ConstantPathOrWriteNode.new(load_node, load_location, load_node, location)
323
317
  when 39 then
324
- ConstantPathWriteNode.new(load_node, load_location, load_node, location)
318
+ ConstantPathTargetNode.new(load_optional_node, load_node, load_location, location)
325
319
  when 40 then
326
- ConstantReadNode.new(load_required_constant, location)
320
+ ConstantPathWriteNode.new(load_node, load_location, load_node, location)
327
321
  when 41 then
328
- ConstantTargetNode.new(load_required_constant, location)
322
+ ConstantReadNode.new(load_required_constant, location)
329
323
  when 42 then
330
- ConstantWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
324
+ ConstantTargetNode.new(load_required_constant, location)
331
325
  when 43 then
326
+ ConstantWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
327
+ when 44 then
332
328
  load_serialized_length
333
329
  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)
334
- when 44 then
335
- DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
336
330
  when 45 then
337
- ElseNode.new(load_location, load_optional_node, load_optional_location, location)
331
+ DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
338
332
  when 46 then
339
- EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
333
+ ElseNode.new(load_location, load_optional_node, load_optional_location, location)
340
334
  when 47 then
341
- EmbeddedVariableNode.new(load_location, load_node, location)
335
+ EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
342
336
  when 48 then
343
- EnsureNode.new(load_location, load_optional_node, load_location, location)
337
+ EmbeddedVariableNode.new(load_location, load_node, location)
344
338
  when 49 then
345
- FalseNode.new(location)
339
+ EnsureNode.new(load_location, load_optional_node, load_location, location)
346
340
  when 50 then
347
- FindPatternNode.new(load_optional_node, load_node, Array.new(load_varint) { load_node }, load_node, load_optional_location, load_optional_location, location)
341
+ FalseNode.new(location)
348
342
  when 51 then
349
- FlipFlopNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
343
+ FindPatternNode.new(load_optional_node, load_node, Array.new(load_varint) { load_node }, load_node, load_optional_location, load_optional_location, location)
350
344
  when 52 then
351
- FloatNode.new(location)
345
+ FlipFlopNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
352
346
  when 53 then
353
- ForNode.new(load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
347
+ FloatNode.new(location)
354
348
  when 54 then
355
- ForwardingArgumentsNode.new(location)
349
+ ForNode.new(load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
356
350
  when 55 then
357
- ForwardingParameterNode.new(location)
351
+ ForwardingArgumentsNode.new(location)
358
352
  when 56 then
359
- ForwardingSuperNode.new(load_optional_node, location)
353
+ ForwardingParameterNode.new(location)
360
354
  when 57 then
361
- GlobalVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
355
+ ForwardingSuperNode.new(load_optional_node, location)
362
356
  when 58 then
363
- GlobalVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
357
+ GlobalVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
364
358
  when 59 then
365
- GlobalVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
359
+ GlobalVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
366
360
  when 60 then
367
- GlobalVariableReadNode.new(load_required_constant, location)
361
+ GlobalVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
368
362
  when 61 then
369
- GlobalVariableTargetNode.new(load_required_constant, location)
363
+ GlobalVariableReadNode.new(load_required_constant, location)
370
364
  when 62 then
371
- GlobalVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
365
+ GlobalVariableTargetNode.new(load_required_constant, location)
372
366
  when 63 then
373
- HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
367
+ GlobalVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
374
368
  when 64 then
375
- HashPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_location, load_optional_location, location)
369
+ HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
376
370
  when 65 then
377
- IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
371
+ HashPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_location, load_optional_location, location)
378
372
  when 66 then
379
- ImaginaryNode.new(load_node, location)
373
+ IfNode.new(load_optional_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
380
374
  when 67 then
381
- ImplicitNode.new(load_node, location)
375
+ ImaginaryNode.new(load_node, location)
382
376
  when 68 then
383
- InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
377
+ ImplicitNode.new(load_node, location)
384
378
  when 69 then
385
- IndexAndWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_location, load_node, location)
379
+ InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
386
380
  when 70 then
387
- IndexOperatorWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_required_constant, load_location, load_node, location)
381
+ IndexAndWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_location, load_node, location)
388
382
  when 71 then
389
- IndexOrWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_location, load_node, location)
383
+ IndexOperatorWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_required_constant, load_location, load_node, location)
390
384
  when 72 then
391
- InstanceVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
385
+ IndexOrWriteNode.new(load_optional_node, load_optional_location, load_location, load_optional_node, load_location, load_optional_node, load_varint, load_location, load_node, location)
392
386
  when 73 then
393
- InstanceVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
387
+ InstanceVariableAndWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
394
388
  when 74 then
395
- InstanceVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
389
+ InstanceVariableOperatorWriteNode.new(load_required_constant, load_location, load_location, load_node, load_required_constant, location)
396
390
  when 75 then
397
- InstanceVariableReadNode.new(load_required_constant, location)
391
+ InstanceVariableOrWriteNode.new(load_required_constant, load_location, load_location, load_node, location)
398
392
  when 76 then
399
- InstanceVariableTargetNode.new(load_required_constant, location)
393
+ InstanceVariableReadNode.new(load_required_constant, location)
400
394
  when 77 then
401
- InstanceVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
395
+ InstanceVariableTargetNode.new(load_required_constant, location)
402
396
  when 78 then
403
- IntegerNode.new(load_varint, location)
397
+ InstanceVariableWriteNode.new(load_required_constant, load_location, load_node, load_location, location)
404
398
  when 79 then
405
- InterpolatedMatchLastLineNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
399
+ IntegerNode.new(load_varint, location)
406
400
  when 80 then
407
- InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
401
+ InterpolatedMatchLastLineNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
408
402
  when 81 then
409
- InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
403
+ InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
410
404
  when 82 then
411
- InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
405
+ InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
412
406
  when 83 then
413
- InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
407
+ InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
414
408
  when 84 then
415
- KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
409
+ InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
416
410
  when 85 then
417
- KeywordRestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
411
+ KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
418
412
  when 86 then
419
- LambdaNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_location, load_optional_node, load_optional_node, location)
413
+ KeywordRestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
420
414
  when 87 then
421
- LocalVariableAndWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
415
+ LambdaNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_location, load_optional_node, load_optional_node, location)
422
416
  when 88 then
423
- LocalVariableOperatorWriteNode.new(load_location, load_location, load_node, load_required_constant, load_required_constant, load_varint, location)
417
+ LocalVariableAndWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
424
418
  when 89 then
425
- LocalVariableOrWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
419
+ LocalVariableOperatorWriteNode.new(load_location, load_location, load_node, load_required_constant, load_required_constant, load_varint, location)
426
420
  when 90 then
427
- LocalVariableReadNode.new(load_required_constant, load_varint, location)
421
+ LocalVariableOrWriteNode.new(load_location, load_location, load_node, load_required_constant, load_varint, location)
428
422
  when 91 then
429
- LocalVariableTargetNode.new(load_required_constant, load_varint, location)
423
+ LocalVariableReadNode.new(load_required_constant, load_varint, location)
430
424
  when 92 then
431
- LocalVariableWriteNode.new(load_required_constant, load_varint, load_location, load_node, load_location, location)
425
+ LocalVariableTargetNode.new(load_required_constant, load_varint, location)
432
426
  when 93 then
433
- MatchLastLineNode.new(load_location, load_location, load_location, load_string, load_varint, location)
427
+ LocalVariableWriteNode.new(load_required_constant, load_varint, load_location, load_node, load_location, location)
434
428
  when 94 then
435
- MatchPredicateNode.new(load_node, load_node, load_location, location)
429
+ MatchLastLineNode.new(load_location, load_location, load_location, load_string, load_varint, location)
436
430
  when 95 then
437
- MatchRequiredNode.new(load_node, load_node, load_location, location)
431
+ MatchPredicateNode.new(load_node, load_node, load_location, location)
438
432
  when 96 then
439
- MatchWriteNode.new(load_node, Array.new(load_varint) { load_required_constant }, location)
433
+ MatchRequiredNode.new(load_node, load_node, load_location, location)
440
434
  when 97 then
441
- MissingNode.new(location)
435
+ MatchWriteNode.new(load_node, Array.new(load_varint) { load_node }, location)
442
436
  when 98 then
443
- ModuleNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_node, load_optional_node, load_location, load_required_constant, location)
437
+ MissingNode.new(location)
444
438
  when 99 then
445
- MultiTargetNode.new(Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
439
+ ModuleNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_node, load_optional_node, load_location, load_required_constant, location)
446
440
  when 100 then
447
- MultiWriteNode.new(Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, load_location, load_node, location)
441
+ MultiTargetNode.new(Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
448
442
  when 101 then
449
- NextNode.new(load_optional_node, load_location, location)
443
+ MultiWriteNode.new(Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, load_location, load_node, location)
450
444
  when 102 then
451
- NilNode.new(location)
445
+ NextNode.new(load_optional_node, load_location, location)
452
446
  when 103 then
453
- NoKeywordsParameterNode.new(load_location, load_location, location)
447
+ NilNode.new(location)
454
448
  when 104 then
455
- NumberedReferenceReadNode.new(load_varint, location)
449
+ NoKeywordsParameterNode.new(load_location, load_location, location)
456
450
  when 105 then
457
- OptionalKeywordParameterNode.new(load_required_constant, load_location, load_node, location)
451
+ NumberedReferenceReadNode.new(load_varint, location)
458
452
  when 106 then
459
- OptionalParameterNode.new(load_required_constant, load_location, load_location, load_node, location)
453
+ OptionalKeywordParameterNode.new(load_required_constant, load_location, load_node, location)
460
454
  when 107 then
461
- OrNode.new(load_node, load_node, load_location, location)
455
+ OptionalParameterNode.new(load_required_constant, load_location, load_location, load_node, location)
462
456
  when 108 then
463
- 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)
457
+ OrNode.new(load_node, load_node, load_location, location)
464
458
  when 109 then
465
- ParenthesesNode.new(load_optional_node, load_location, load_location, location)
459
+ 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)
466
460
  when 110 then
467
- PinnedExpressionNode.new(load_node, load_location, load_location, load_location, location)
461
+ ParenthesesNode.new(load_optional_node, load_location, load_location, location)
468
462
  when 111 then
469
- PinnedVariableNode.new(load_node, load_location, location)
463
+ PinnedExpressionNode.new(load_node, load_location, load_location, load_location, location)
470
464
  when 112 then
471
- PostExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
465
+ PinnedVariableNode.new(load_node, load_location, location)
472
466
  when 113 then
473
- PreExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
467
+ PostExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
474
468
  when 114 then
475
- ProgramNode.new(Array.new(load_varint) { load_required_constant }, load_node, location)
469
+ PreExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
476
470
  when 115 then
477
- RangeNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
471
+ ProgramNode.new(Array.new(load_varint) { load_required_constant }, load_node, location)
478
472
  when 116 then
479
- RationalNode.new(load_node, location)
473
+ RangeNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
480
474
  when 117 then
481
- RedoNode.new(location)
475
+ RationalNode.new(load_node, location)
482
476
  when 118 then
483
- RegularExpressionNode.new(load_location, load_location, load_location, load_string, load_varint, location)
477
+ RedoNode.new(location)
484
478
  when 119 then
485
- RequiredKeywordParameterNode.new(load_required_constant, load_location, location)
479
+ RegularExpressionNode.new(load_location, load_location, load_location, load_string, load_varint, location)
486
480
  when 120 then
487
- RequiredParameterNode.new(load_required_constant, location)
481
+ RequiredKeywordParameterNode.new(load_required_constant, load_location, location)
488
482
  when 121 then
489
- RescueModifierNode.new(load_node, load_location, load_node, location)
483
+ RequiredParameterNode.new(load_required_constant, location)
490
484
  when 122 then
491
- RescueNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
485
+ RescueModifierNode.new(load_node, load_location, load_node, location)
492
486
  when 123 then
493
- RestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
487
+ RescueNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
494
488
  when 124 then
495
- RetryNode.new(location)
489
+ RestParameterNode.new(load_optional_constant, load_optional_location, load_location, location)
496
490
  when 125 then
497
- ReturnNode.new(load_location, load_optional_node, location)
491
+ RetryNode.new(location)
498
492
  when 126 then
499
- SelfNode.new(location)
493
+ ReturnNode.new(load_location, load_optional_node, location)
500
494
  when 127 then
501
- SingletonClassNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
495
+ SelfNode.new(location)
502
496
  when 128 then
503
- SourceEncodingNode.new(location)
497
+ SingletonClassNode.new(Array.new(load_varint) { load_required_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
504
498
  when 129 then
505
- SourceFileNode.new(load_string, location)
499
+ SourceEncodingNode.new(location)
506
500
  when 130 then
507
- SourceLineNode.new(location)
501
+ SourceFileNode.new(load_string, location)
508
502
  when 131 then
509
- SplatNode.new(load_location, load_optional_node, location)
503
+ SourceLineNode.new(location)
510
504
  when 132 then
511
- StatementsNode.new(Array.new(load_varint) { load_node }, location)
505
+ SplatNode.new(load_location, load_optional_node, location)
512
506
  when 133 then
513
- StringConcatNode.new(load_node, load_node, location)
507
+ StatementsNode.new(Array.new(load_varint) { load_node }, location)
514
508
  when 134 then
515
509
  StringNode.new(load_varint, load_optional_location, load_location, load_optional_location, load_string, location)
516
510
  when 135 then
@@ -522,7 +516,7 @@ module Prism
522
516
  when 138 then
523
517
  UndefNode.new(Array.new(load_varint) { load_node }, load_location, location)
524
518
  when 139 then
525
- UnlessNode.new(load_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
519
+ UnlessNode.new(load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
526
520
  when 140 then
527
521
  UntilNode.new(load_location, load_optional_location, load_node, load_optional_node, load_varint, location)
528
522
  when 141 then
@@ -632,6 +626,10 @@ module Prism
632
626
  location = load_location
633
627
  CapturePatternNode.new(load_node, load_node, load_location, location)
634
628
  },
629
+ -> {
630
+ location = load_location
631
+ CaseMatchNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
632
+ },
635
633
  -> {
636
634
  location = load_location
637
635
  CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
@@ -803,7 +801,7 @@ module Prism
803
801
  },
804
802
  -> {
805
803
  location = load_location
806
- IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
804
+ IfNode.new(load_optional_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
807
805
  },
808
806
  -> {
809
807
  location = load_location
@@ -927,7 +925,7 @@ module Prism
927
925
  },
928
926
  -> {
929
927
  location = load_location
930
- MatchWriteNode.new(load_node, Array.new(load_varint) { load_required_constant }, location)
928
+ MatchWriteNode.new(load_node, Array.new(load_varint) { load_node }, location)
931
929
  },
932
930
  -> {
933
931
  location = load_location
@@ -1073,10 +1071,6 @@ module Prism
1073
1071
  location = load_location
1074
1072
  StatementsNode.new(Array.new(load_varint) { load_node }, location)
1075
1073
  },
1076
- -> {
1077
- location = load_location
1078
- StringConcatNode.new(load_node, load_node, location)
1079
- },
1080
1074
  -> {
1081
1075
  location = load_location
1082
1076
  StringNode.new(load_varint, load_optional_location, load_location, load_optional_location, load_string, location)
@@ -1099,7 +1093,7 @@ module Prism
1099
1093
  },
1100
1094
  -> {
1101
1095
  location = load_location
1102
- UnlessNode.new(load_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
1096
+ UnlessNode.new(load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
1103
1097
  },
1104
1098
  -> {
1105
1099
  location = load_location
data/lib/prism/visitor.rb CHANGED
@@ -114,6 +114,9 @@ module Prism
114
114
  # Visit a CapturePatternNode node
115
115
  alias visit_capture_pattern_node visit_child_nodes
116
116
 
117
+ # Visit a CaseMatchNode node
118
+ alias visit_case_match_node visit_child_nodes
119
+
117
120
  # Visit a CaseNode node
118
121
  alias visit_case_node visit_child_nodes
119
122
 
@@ -444,9 +447,6 @@ module Prism
444
447
  # Visit a StatementsNode node
445
448
  alias visit_statements_node visit_child_nodes
446
449
 
447
- # Visit a StringConcatNode node
448
- alias visit_string_concat_node visit_child_nodes
449
-
450
450
  # Visit a StringNode node
451
451
  alias visit_string_node visit_child_nodes
452
452
 
data/lib/prism.rb CHANGED
@@ -16,6 +16,7 @@ module Prism
16
16
  autoload :Debug, "prism/debug"
17
17
  autoload :DesugarCompiler, "prism/desugar_compiler"
18
18
  autoload :Dispatcher, "prism/dispatcher"
19
+ autoload :DotVisitor, "prism/dot_visitor"
19
20
  autoload :DSL, "prism/dsl"
20
21
  autoload :LexCompat, "prism/lex_compat"
21
22
  autoload :LexRipper, "prism/lex_compat"
data/prism.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prism"
5
- spec.version = "0.17.1"
5
+ spec.version = "0.18.0"
6
6
  spec.authors = ["Shopify"]
7
7
  spec.email = ["ruby@shopify.com"]
8
8
 
@@ -67,6 +67,7 @@ Gem::Specification.new do |spec|
67
67
  "lib/prism/debug.rb",
68
68
  "lib/prism/desugar_compiler.rb",
69
69
  "lib/prism/dispatcher.rb",
70
+ "lib/prism/dot_visitor.rb",
70
71
  "lib/prism/dsl.rb",
71
72
  "lib/prism/ffi.rb",
72
73
  "lib/prism/lex_compat.rb",
@@ -84,6 +85,7 @@ Gem::Specification.new do |spec|
84
85
  "lib/prism/visitor.rb",
85
86
  "src/diagnostic.c",
86
87
  "src/enc/pm_big5.c",
88
+ "src/enc/pm_cp51932.c",
87
89
  "src/enc/pm_euc_jp.c",
88
90
  "src/enc/pm_gbk.c",
89
91
  "src/enc/pm_shift_jis.c",
@@ -118,4 +120,6 @@ Gem::Specification.new do |spec|
118
120
 
119
121
  spec.extensions = ["ext/prism/extconf.rb"]
120
122
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
123
+ spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
124
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
121
125
  end