Class: RBS::Parser::Token

Inherits:
Object
  • Object
show all
Defined in:
sig/parser.rbs,
lib/rbs/parser/token.rb

Overview

Represents a token per result of Parser.lex.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, location:) ⇒ Token

Returns a new instance of Token.

Parameters:

  • type: (Symbol)
  • location: (Location[untyped, untyped])


9
10
11
12
# File 'lib/rbs/parser/token.rb', line 9

def initialize(type:, location:)
  @type = type
  @location = location
end

Instance Attribute Details

#locationLocation[untyped, untyped] (readonly)

Returns the value of attribute location.

Returns:



7
8
9
# File 'lib/rbs/parser/token.rb', line 7

def location
  @location
end

#typeSymbol (readonly)

Returns the value of attribute type.

Returns:

  • (Symbol)


6
7
8
# File 'lib/rbs/parser/token.rb', line 6

def type
  @type
end

Instance Method Details

#comment?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rbs/parser/token.rb', line 18

def comment?
  @type == :tCOMMENT || @type == :tLINECOMMENT
end

#valueString

Returns:

  • (String)


14
15
16
# File 'lib/rbs/parser/token.rb', line 14

def value
  @location.source
end