prism 0.23.0 → 0.24.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 +16 -1
- data/docs/releasing.md +1 -1
- data/ext/prism/api_node.c +2232 -1787
- data/ext/prism/extension.h +1 -1
- data/include/prism/util/pm_newline_list.h +4 -3
- data/include/prism/version.h +2 -2
- data/lib/prism/desugar_compiler.rb +225 -80
- data/lib/prism/dsl.rb +302 -299
- data/lib/prism/ffi.rb +102 -76
- data/lib/prism/node.rb +3624 -2114
- data/lib/prism/parse_result.rb +12 -4
- data/lib/prism/serialize.rb +594 -298
- data/lib/prism/translation/parser/compiler.rb +1 -1
- data/lib/prism/translation/parser/rubocop.rb +11 -3
- data/lib/prism/translation/parser.rb +15 -3
- data/lib/prism/translation/parser33.rb +12 -0
- data/lib/prism/translation/parser34.rb +12 -0
- data/lib/prism/translation/ripper.rb +144 -25
- data/prism.gemspec +3 -1
- data/src/prettyprint.c +3 -3
- data/src/prism.c +48 -33
- data/src/util/pm_newline_list.c +6 -3
- metadata +4 -2
data/lib/prism/parse_result.rb
CHANGED
@@ -452,17 +452,19 @@ module Prism
|
|
452
452
|
|
453
453
|
# This represents a token from the Ruby source.
|
454
454
|
class Token
|
455
|
+
# The Source object that represents the source this token came from.
|
456
|
+
attr_reader :source
|
457
|
+
private :source
|
458
|
+
|
455
459
|
# The type of token that this token is.
|
456
460
|
attr_reader :type
|
457
461
|
|
458
462
|
# A byteslice of the source that this token represents.
|
459
463
|
attr_reader :value
|
460
464
|
|
461
|
-
# A Location object representing the location of this token in the source.
|
462
|
-
attr_reader :location
|
463
|
-
|
464
465
|
# Create a new token object with the given type, value, and location.
|
465
|
-
def initialize(type, value, location)
|
466
|
+
def initialize(source, type, value, location)
|
467
|
+
@source = source
|
466
468
|
@type = type
|
467
469
|
@value = value
|
468
470
|
@location = location
|
@@ -473,6 +475,12 @@ module Prism
|
|
473
475
|
{ type: type, value: value, location: location }
|
474
476
|
end
|
475
477
|
|
478
|
+
# A Location object representing the location of this token in the source.
|
479
|
+
def location
|
480
|
+
return @location if @location.is_a?(Location)
|
481
|
+
@location = Location.new(source, @location >> 32, @location & 0xFFFFFFFF)
|
482
|
+
end
|
483
|
+
|
476
484
|
# Implement the pretty print interface for Token.
|
477
485
|
def pretty_print(q)
|
478
486
|
q.group do
|