prism 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -1
- data/README.md +2 -1
- data/config.yml +188 -55
- data/docs/building.md +9 -2
- data/docs/configuration.md +10 -9
- data/docs/encoding.md +24 -56
- data/docs/local_variable_depth.md +229 -0
- data/docs/ruby_api.md +2 -0
- data/docs/serialization.md +18 -13
- data/ext/prism/api_node.c +337 -195
- data/ext/prism/extconf.rb +13 -7
- data/ext/prism/extension.c +96 -32
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +340 -137
- data/include/prism/defines.h +17 -0
- data/include/prism/diagnostic.h +11 -5
- data/include/prism/encoding.h +248 -0
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +62 -42
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +9 -1
- data/include/prism/util/pm_memchr.h +2 -2
- data/include/prism/util/pm_strpbrk.h +3 -3
- data/include/prism/version.h +2 -2
- data/include/prism.h +13 -15
- data/lib/prism/compiler.rb +12 -0
- data/lib/prism/debug.rb +9 -4
- data/lib/prism/desugar_compiler.rb +3 -3
- data/lib/prism/dispatcher.rb +56 -0
- data/lib/prism/dot_visitor.rb +476 -198
- data/lib/prism/dsl.rb +66 -46
- data/lib/prism/ffi.rb +16 -3
- data/lib/prism/lex_compat.rb +19 -9
- data/lib/prism/mutation_compiler.rb +20 -0
- data/lib/prism/node.rb +1173 -450
- data/lib/prism/node_ext.rb +41 -16
- data/lib/prism/parse_result.rb +12 -15
- data/lib/prism/ripper_compat.rb +49 -34
- data/lib/prism/serialize.rb +242 -212
- data/lib/prism/visitor.rb +12 -0
- data/lib/prism.rb +20 -4
- data/prism.gemspec +4 -10
- data/rbi/prism.rbi +605 -230
- data/rbi/prism_static.rbi +3 -0
- data/sig/prism.rbs +379 -124
- data/sig/prism_static.rbs +1 -0
- data/src/diagnostic.c +228 -222
- data/src/encoding.c +5137 -0
- data/src/node.c +66 -0
- data/src/options.c +21 -2
- data/src/prettyprint.c +806 -406
- data/src/prism.c +1092 -700
- data/src/regexp.c +3 -3
- data/src/serialize.c +227 -157
- data/src/util/pm_buffer.c +10 -1
- data/src/util/pm_memchr.c +1 -1
- data/src/util/pm_strpbrk.c +4 -4
- metadata +5 -11
- data/include/prism/enc/pm_encoding.h +0 -227
- data/src/enc/pm_big5.c +0 -116
- data/src/enc/pm_cp51932.c +0 -57
- data/src/enc/pm_euc_jp.c +0 -69
- data/src/enc/pm_gbk.c +0 -65
- data/src/enc/pm_shift_jis.c +0 -57
- data/src/enc/pm_tables.c +0 -2073
- data/src/enc/pm_unicode.c +0 -2369
- data/src/enc/pm_windows_31j.c +0 -57
data/lib/prism/dsl.rb
CHANGED
@@ -63,13 +63,13 @@ module Prism
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Create a new ArgumentsNode node
|
66
|
-
def ArgumentsNode(
|
67
|
-
ArgumentsNode.new(
|
66
|
+
def ArgumentsNode(flags, arguments, location = Location())
|
67
|
+
ArgumentsNode.new(flags, arguments, location)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Create a new ArrayNode node
|
71
|
-
def ArrayNode(elements, opening_loc, closing_loc, location = Location())
|
72
|
-
ArrayNode.new(elements, opening_loc, closing_loc, location)
|
71
|
+
def ArrayNode(flags, elements, opening_loc, closing_loc, location = Location())
|
72
|
+
ArrayNode.new(flags, elements, opening_loc, closing_loc, location)
|
73
73
|
end
|
74
74
|
|
75
75
|
# Create a new ArrayPatternNode node
|
@@ -108,8 +108,8 @@ module Prism
|
|
108
108
|
end
|
109
109
|
|
110
110
|
# Create a new BlockNode node
|
111
|
-
def BlockNode(locals, parameters, body, opening_loc, closing_loc, location = Location())
|
112
|
-
BlockNode.new(locals, parameters, body, opening_loc, closing_loc, location)
|
111
|
+
def BlockNode(locals, locals_body_index, parameters, body, opening_loc, closing_loc, location = Location())
|
112
|
+
BlockNode.new(locals, locals_body_index, parameters, body, opening_loc, closing_loc, location)
|
113
113
|
end
|
114
114
|
|
115
115
|
# Create a new BlockParameterNode node
|
@@ -128,23 +128,28 @@ module Prism
|
|
128
128
|
end
|
129
129
|
|
130
130
|
# Create a new CallAndWriteNode node
|
131
|
-
def CallAndWriteNode(receiver, call_operator_loc, message_loc,
|
132
|
-
CallAndWriteNode.new(receiver, call_operator_loc, message_loc,
|
131
|
+
def CallAndWriteNode(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location = Location())
|
132
|
+
CallAndWriteNode.new(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
|
133
133
|
end
|
134
134
|
|
135
135
|
# Create a new CallNode node
|
136
|
-
def CallNode(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, block,
|
137
|
-
CallNode.new(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, block,
|
136
|
+
def CallNode(flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block, location = Location())
|
137
|
+
CallNode.new(flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block, location)
|
138
138
|
end
|
139
139
|
|
140
140
|
# Create a new CallOperatorWriteNode node
|
141
|
-
def CallOperatorWriteNode(receiver, call_operator_loc, message_loc,
|
142
|
-
CallOperatorWriteNode.new(receiver, call_operator_loc, message_loc,
|
141
|
+
def CallOperatorWriteNode(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator, operator_loc, value, location = Location())
|
142
|
+
CallOperatorWriteNode.new(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator, operator_loc, value, location)
|
143
143
|
end
|
144
144
|
|
145
145
|
# Create a new CallOrWriteNode node
|
146
|
-
def CallOrWriteNode(receiver, call_operator_loc, message_loc,
|
147
|
-
CallOrWriteNode.new(receiver, call_operator_loc, message_loc,
|
146
|
+
def CallOrWriteNode(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location = Location())
|
147
|
+
CallOrWriteNode.new(flags, receiver, call_operator_loc, message_loc, read_name, write_name, operator_loc, value, location)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Create a new CallTargetNode node
|
151
|
+
def CallTargetNode(flags, receiver, call_operator_loc, name, message_loc, location = Location())
|
152
|
+
CallTargetNode.new(flags, receiver, call_operator_loc, name, message_loc, location)
|
148
153
|
end
|
149
154
|
|
150
155
|
# Create a new CapturePatternNode node
|
@@ -258,8 +263,8 @@ module Prism
|
|
258
263
|
end
|
259
264
|
|
260
265
|
# Create a new DefNode node
|
261
|
-
def DefNode(name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location = Location())
|
262
|
-
DefNode.new(name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
|
266
|
+
def DefNode(name, name_loc, receiver, parameters, body, locals, locals_body_index, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location = Location())
|
267
|
+
DefNode.new(name, name_loc, receiver, parameters, body, locals, locals_body_index, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
|
263
268
|
end
|
264
269
|
|
265
270
|
# Create a new DefinedNode node
|
@@ -298,8 +303,8 @@ module Prism
|
|
298
303
|
end
|
299
304
|
|
300
305
|
# Create a new FlipFlopNode node
|
301
|
-
def FlipFlopNode(left, right, operator_loc,
|
302
|
-
FlipFlopNode.new(left, right, operator_loc,
|
306
|
+
def FlipFlopNode(flags, left, right, operator_loc, location = Location())
|
307
|
+
FlipFlopNode.new(flags, left, right, operator_loc, location)
|
303
308
|
end
|
304
309
|
|
305
310
|
# Create a new FloatNode node
|
@@ -382,24 +387,34 @@ module Prism
|
|
382
387
|
ImplicitNode.new(value, location)
|
383
388
|
end
|
384
389
|
|
390
|
+
# Create a new ImplicitRestNode node
|
391
|
+
def ImplicitRestNode(location = Location())
|
392
|
+
ImplicitRestNode.new(location)
|
393
|
+
end
|
394
|
+
|
385
395
|
# Create a new InNode node
|
386
396
|
def InNode(pattern, statements, in_loc, then_loc, location = Location())
|
387
397
|
InNode.new(pattern, statements, in_loc, then_loc, location)
|
388
398
|
end
|
389
399
|
|
390
400
|
# Create a new IndexAndWriteNode node
|
391
|
-
def IndexAndWriteNode(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
392
|
-
IndexAndWriteNode.new(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
401
|
+
def IndexAndWriteNode(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location = Location())
|
402
|
+
IndexAndWriteNode.new(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
|
393
403
|
end
|
394
404
|
|
395
405
|
# Create a new IndexOperatorWriteNode node
|
396
|
-
def IndexOperatorWriteNode(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
397
|
-
IndexOperatorWriteNode.new(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
406
|
+
def IndexOperatorWriteNode(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator, operator_loc, value, location = Location())
|
407
|
+
IndexOperatorWriteNode.new(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator, operator_loc, value, location)
|
398
408
|
end
|
399
409
|
|
400
410
|
# Create a new IndexOrWriteNode node
|
401
|
-
def IndexOrWriteNode(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
402
|
-
IndexOrWriteNode.new(receiver, call_operator_loc, opening_loc, arguments, closing_loc, block,
|
411
|
+
def IndexOrWriteNode(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location = Location())
|
412
|
+
IndexOrWriteNode.new(flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, operator_loc, value, location)
|
413
|
+
end
|
414
|
+
|
415
|
+
# Create a new IndexTargetNode node
|
416
|
+
def IndexTargetNode(flags, receiver, opening_loc, arguments, closing_loc, block, location = Location())
|
417
|
+
IndexTargetNode.new(flags, receiver, opening_loc, arguments, closing_loc, block, location)
|
403
418
|
end
|
404
419
|
|
405
420
|
# Create a new InstanceVariableAndWriteNode node
|
@@ -438,13 +453,13 @@ module Prism
|
|
438
453
|
end
|
439
454
|
|
440
455
|
# Create a new InterpolatedMatchLastLineNode node
|
441
|
-
def InterpolatedMatchLastLineNode(opening_loc, parts, closing_loc,
|
442
|
-
InterpolatedMatchLastLineNode.new(opening_loc, parts, closing_loc,
|
456
|
+
def InterpolatedMatchLastLineNode(flags, opening_loc, parts, closing_loc, location = Location())
|
457
|
+
InterpolatedMatchLastLineNode.new(flags, opening_loc, parts, closing_loc, location)
|
443
458
|
end
|
444
459
|
|
445
460
|
# Create a new InterpolatedRegularExpressionNode node
|
446
|
-
def InterpolatedRegularExpressionNode(opening_loc, parts, closing_loc,
|
447
|
-
InterpolatedRegularExpressionNode.new(opening_loc, parts, closing_loc,
|
461
|
+
def InterpolatedRegularExpressionNode(flags, opening_loc, parts, closing_loc, location = Location())
|
462
|
+
InterpolatedRegularExpressionNode.new(flags, opening_loc, parts, closing_loc, location)
|
448
463
|
end
|
449
464
|
|
450
465
|
# Create a new InterpolatedStringNode node
|
@@ -463,8 +478,8 @@ module Prism
|
|
463
478
|
end
|
464
479
|
|
465
480
|
# Create a new KeywordHashNode node
|
466
|
-
def KeywordHashNode(elements, location = Location())
|
467
|
-
KeywordHashNode.new(elements, location)
|
481
|
+
def KeywordHashNode(flags, elements, location = Location())
|
482
|
+
KeywordHashNode.new(flags, elements, location)
|
468
483
|
end
|
469
484
|
|
470
485
|
# Create a new KeywordRestParameterNode node
|
@@ -473,8 +488,8 @@ module Prism
|
|
473
488
|
end
|
474
489
|
|
475
490
|
# Create a new LambdaNode node
|
476
|
-
def LambdaNode(locals, operator_loc, opening_loc, closing_loc, parameters, body, location = Location())
|
477
|
-
LambdaNode.new(locals, operator_loc, opening_loc, closing_loc, parameters, body, location)
|
491
|
+
def LambdaNode(locals, locals_body_index, operator_loc, opening_loc, closing_loc, parameters, body, location = Location())
|
492
|
+
LambdaNode.new(locals, locals_body_index, operator_loc, opening_loc, closing_loc, parameters, body, location)
|
478
493
|
end
|
479
494
|
|
480
495
|
# Create a new LocalVariableAndWriteNode node
|
@@ -508,8 +523,8 @@ module Prism
|
|
508
523
|
end
|
509
524
|
|
510
525
|
# Create a new MatchLastLineNode node
|
511
|
-
def MatchLastLineNode(opening_loc, content_loc, closing_loc, unescaped,
|
512
|
-
MatchLastLineNode.new(opening_loc, content_loc, closing_loc, unescaped,
|
526
|
+
def MatchLastLineNode(flags, opening_loc, content_loc, closing_loc, unescaped, location = Location())
|
527
|
+
MatchLastLineNode.new(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
513
528
|
end
|
514
529
|
|
515
530
|
# Create a new MatchPredicateNode node
|
@@ -562,6 +577,11 @@ module Prism
|
|
562
577
|
NoKeywordsParameterNode.new(operator_loc, keyword_loc, location)
|
563
578
|
end
|
564
579
|
|
580
|
+
# Create a new NumberedParametersNode node
|
581
|
+
def NumberedParametersNode(maximum, location = Location())
|
582
|
+
NumberedParametersNode.new(maximum, location)
|
583
|
+
end
|
584
|
+
|
565
585
|
# Create a new NumberedReferenceReadNode node
|
566
586
|
def NumberedReferenceReadNode(number, location = Location())
|
567
587
|
NumberedReferenceReadNode.new(number, location)
|
@@ -618,8 +638,8 @@ module Prism
|
|
618
638
|
end
|
619
639
|
|
620
640
|
# Create a new RangeNode node
|
621
|
-
def RangeNode(left, right, operator_loc,
|
622
|
-
RangeNode.new(left, right, operator_loc,
|
641
|
+
def RangeNode(flags, left, right, operator_loc, location = Location())
|
642
|
+
RangeNode.new(flags, left, right, operator_loc, location)
|
623
643
|
end
|
624
644
|
|
625
645
|
# Create a new RationalNode node
|
@@ -633,8 +653,8 @@ module Prism
|
|
633
653
|
end
|
634
654
|
|
635
655
|
# Create a new RegularExpressionNode node
|
636
|
-
def RegularExpressionNode(opening_loc, content_loc, closing_loc, unescaped,
|
637
|
-
RegularExpressionNode.new(opening_loc, content_loc, closing_loc, unescaped,
|
656
|
+
def RegularExpressionNode(flags, opening_loc, content_loc, closing_loc, unescaped, location = Location())
|
657
|
+
RegularExpressionNode.new(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
638
658
|
end
|
639
659
|
|
640
660
|
# Create a new RequiredKeywordParameterNode node
|
@@ -718,8 +738,8 @@ module Prism
|
|
718
738
|
end
|
719
739
|
|
720
740
|
# Create a new SymbolNode node
|
721
|
-
def SymbolNode(opening_loc, value_loc, closing_loc, unescaped, location = Location())
|
722
|
-
SymbolNode.new(opening_loc, value_loc, closing_loc, unescaped, location)
|
741
|
+
def SymbolNode(flags, opening_loc, value_loc, closing_loc, unescaped, location = Location())
|
742
|
+
SymbolNode.new(flags, opening_loc, value_loc, closing_loc, unescaped, location)
|
723
743
|
end
|
724
744
|
|
725
745
|
# Create a new TrueNode node
|
@@ -738,8 +758,8 @@ module Prism
|
|
738
758
|
end
|
739
759
|
|
740
760
|
# Create a new UntilNode node
|
741
|
-
def UntilNode(keyword_loc, closing_loc, predicate, statements,
|
742
|
-
UntilNode.new(keyword_loc, closing_loc, predicate, statements,
|
761
|
+
def UntilNode(flags, keyword_loc, closing_loc, predicate, statements, location = Location())
|
762
|
+
UntilNode.new(flags, keyword_loc, closing_loc, predicate, statements, location)
|
743
763
|
end
|
744
764
|
|
745
765
|
# Create a new WhenNode node
|
@@ -748,13 +768,13 @@ module Prism
|
|
748
768
|
end
|
749
769
|
|
750
770
|
# Create a new WhileNode node
|
751
|
-
def WhileNode(keyword_loc, closing_loc, predicate, statements,
|
752
|
-
WhileNode.new(keyword_loc, closing_loc, predicate, statements,
|
771
|
+
def WhileNode(flags, keyword_loc, closing_loc, predicate, statements, location = Location())
|
772
|
+
WhileNode.new(flags, keyword_loc, closing_loc, predicate, statements, location)
|
753
773
|
end
|
754
774
|
|
755
775
|
# Create a new XStringNode node
|
756
|
-
def XStringNode(opening_loc, content_loc, closing_loc, unescaped, location = Location())
|
757
|
-
XStringNode.new(opening_loc, content_loc, closing_loc, unescaped, location)
|
776
|
+
def XStringNode(flags, opening_loc, content_loc, closing_loc, unescaped, location = Location())
|
777
|
+
XStringNode.new(flags, opening_loc, content_loc, closing_loc, unescaped, location)
|
758
778
|
end
|
759
779
|
|
760
780
|
# Create a new YieldNode node
|
data/lib/prism/ffi.rb
CHANGED
@@ -72,7 +72,8 @@ module Prism
|
|
72
72
|
"pm_serialize_parse",
|
73
73
|
"pm_serialize_parse_comments",
|
74
74
|
"pm_serialize_lex",
|
75
|
-
"pm_serialize_parse_lex"
|
75
|
+
"pm_serialize_parse_lex",
|
76
|
+
"pm_parse_success_p"
|
76
77
|
)
|
77
78
|
|
78
79
|
load_exported_functions_from(
|
@@ -254,10 +255,10 @@ module Prism
|
|
254
255
|
loader = Serialize::Loader.new(source, buffer.read)
|
255
256
|
|
256
257
|
tokens = loader.load_tokens
|
257
|
-
node, comments, magic_comments, errors, warnings = loader.load_nodes
|
258
|
+
node, comments, magic_comments, data_loc, errors, warnings = loader.load_nodes
|
258
259
|
tokens.each { |token,| token.value.force_encoding(loader.encoding) }
|
259
260
|
|
260
|
-
ParseResult.new([node, tokens], comments, magic_comments, errors, warnings, source)
|
261
|
+
ParseResult.new([node, tokens], comments, magic_comments, data_loc, errors, warnings, source)
|
261
262
|
end
|
262
263
|
end
|
263
264
|
|
@@ -268,6 +269,18 @@ module Prism
|
|
268
269
|
end
|
269
270
|
end
|
270
271
|
|
272
|
+
# Mirror the Prism.parse_success? API by using the serialization API.
|
273
|
+
def parse_success?(code, **options)
|
274
|
+
LibRubyParser.pm_parse_success_p(code, code.bytesize, dump_options(options))
|
275
|
+
end
|
276
|
+
|
277
|
+
# Mirror the Prism.parse_file_success? API by using the serialization API.
|
278
|
+
def parse_file_success?(filepath, **options)
|
279
|
+
LibRubyParser::PrismString.with(filepath) do |string|
|
280
|
+
parse_success?(string.read, **options, filepath: filepath)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
271
284
|
private
|
272
285
|
|
273
286
|
# Convert the given options into a serialized options string.
|
data/lib/prism/lex_compat.rb
CHANGED
@@ -610,6 +610,7 @@ module Prism
|
|
610
610
|
result = Prism.lex(source, **options)
|
611
611
|
result_value = result.value
|
612
612
|
previous_state = nil
|
613
|
+
last_heredoc_end = nil
|
613
614
|
|
614
615
|
# In previous versions of Ruby, Ripper wouldn't flush the bom before the
|
615
616
|
# first token, so we had to have a hack in place to account for that. This
|
@@ -664,6 +665,7 @@ module Prism
|
|
664
665
|
when :on_heredoc_end
|
665
666
|
# Heredoc end tokens can be emitted in an odd order, so we don't
|
666
667
|
# want to bother comparing the state on them.
|
668
|
+
last_heredoc_end = token.location.end_offset
|
667
669
|
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
|
668
670
|
when :on_ident
|
669
671
|
if lex_state == Ripper::EXPR_END
|
@@ -729,16 +731,24 @@ module Prism
|
|
729
731
|
# comment and there is still whitespace after the comment, then
|
730
732
|
# Ripper will append a on_nl token (even though there isn't
|
731
733
|
# necessarily a newline). We mirror that here.
|
732
|
-
|
733
|
-
|
734
|
+
if previous_token.type == :COMMENT
|
735
|
+
# If the comment is at the start of a heredoc: <<HEREDOC # comment
|
736
|
+
# then the comment's end_offset is up near the heredoc_beg.
|
737
|
+
# This is not the correct offset to use for figuring out if
|
738
|
+
# there is trailing whitespace after the last token.
|
739
|
+
# Use the greater offset of the two to determine the start of
|
740
|
+
# the trailing whitespace.
|
741
|
+
start_offset = [previous_token.location.end_offset, last_heredoc_end].compact.max
|
742
|
+
end_offset = token.location.start_offset
|
743
|
+
|
744
|
+
if start_offset < end_offset
|
745
|
+
if bom
|
746
|
+
start_offset += 3
|
747
|
+
end_offset += 3
|
748
|
+
end
|
734
749
|
|
735
|
-
|
736
|
-
if bom
|
737
|
-
start_offset += 3
|
738
|
-
end_offset += 3
|
750
|
+
tokens << Token.new([[lineno, 0], :on_nl, source.byteslice(start_offset...end_offset), lex_state])
|
739
751
|
end
|
740
|
-
|
741
|
-
tokens << Token.new([[lineno, 0], :on_nl, source.byteslice(start_offset...end_offset), lex_state])
|
742
752
|
end
|
743
753
|
|
744
754
|
Token.new([[lineno, column], event, value, lex_state])
|
@@ -831,7 +841,7 @@ module Prism
|
|
831
841
|
# We sort by location to compare against Ripper's output
|
832
842
|
tokens.sort_by!(&:location)
|
833
843
|
|
834
|
-
ParseResult.new(tokens, result.comments, result.magic_comments, result.errors, result.warnings, [])
|
844
|
+
ParseResult.new(tokens, result.comments, result.magic_comments, result.data_loc, result.errors, result.warnings, [])
|
835
845
|
end
|
836
846
|
end
|
837
847
|
|
@@ -115,6 +115,11 @@ module Prism
|
|
115
115
|
node.copy(receiver: visit(node.receiver), value: visit(node.value))
|
116
116
|
end
|
117
117
|
|
118
|
+
# Copy a CallTargetNode node
|
119
|
+
def visit_call_target_node(node)
|
120
|
+
node.copy(receiver: visit(node.receiver))
|
121
|
+
end
|
122
|
+
|
118
123
|
# Copy a CapturePatternNode node
|
119
124
|
def visit_capture_pattern_node(node)
|
120
125
|
node.copy(value: visit(node.value), target: visit(node.target))
|
@@ -350,6 +355,11 @@ module Prism
|
|
350
355
|
node.copy(value: visit(node.value))
|
351
356
|
end
|
352
357
|
|
358
|
+
# Copy a ImplicitRestNode node
|
359
|
+
def visit_implicit_rest_node(node)
|
360
|
+
node.copy
|
361
|
+
end
|
362
|
+
|
353
363
|
# Copy a InNode node
|
354
364
|
def visit_in_node(node)
|
355
365
|
node.copy(pattern: visit(node.pattern), statements: visit(node.statements))
|
@@ -370,6 +380,11 @@ module Prism
|
|
370
380
|
node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block), value: visit(node.value))
|
371
381
|
end
|
372
382
|
|
383
|
+
# Copy a IndexTargetNode node
|
384
|
+
def visit_index_target_node(node)
|
385
|
+
node.copy(receiver: visit(node.receiver), arguments: visit(node.arguments), block: visit(node.block))
|
386
|
+
end
|
387
|
+
|
373
388
|
# Copy a InstanceVariableAndWriteNode node
|
374
389
|
def visit_instance_variable_and_write_node(node)
|
375
390
|
node.copy(value: visit(node.value))
|
@@ -530,6 +545,11 @@ module Prism
|
|
530
545
|
node.copy
|
531
546
|
end
|
532
547
|
|
548
|
+
# Copy a NumberedParametersNode node
|
549
|
+
def visit_numbered_parameters_node(node)
|
550
|
+
node.copy
|
551
|
+
end
|
552
|
+
|
533
553
|
# Copy a NumberedReferenceReadNode node
|
534
554
|
def visit_numbered_reference_read_node(node)
|
535
555
|
node.copy
|