class Ruby::Prism::Token

This represents a token from the Ruby source.

Attributes

The type of token that this token is.

A byteslice of the source that this token represents.

Public Class Methods

Create a new token object with the given type, value, and location.

: (Source source, Symbol type, String value, Location | Integer location, Integer state) -> void

# File lib/ruby/prism/parse_result.rb, line 1114
def initialize(source, type, value, location, state)
  @source = source
  @type = type
  @value = value
  @location = location
  @state = state
end

Public Instance Methods

Returns true if the given other token is equal to this token.

: (untyped other) -> bool

# File lib/ruby/prism/parse_result.rb, line 1158
def ==(other)
  Token === other &&
    other.type == type &&
    other.value == value
end

Freeze this object and the objects it contains.

: () -> void

# File lib/ruby/prism/parse_result.rb, line 1175
def deep_freeze
  value.freeze
  location.freeze
  freeze
end

A Location object representing the location of this token in the source.

: () -> Location

# File lib/ruby/prism/parse_result.rb, line 1132
def location
  location = @location
  return location if location.is_a?(Location)
  @location = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end