Class: LibRubyParser::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/lib-ruby-parser.rb

Overview

A token that is emitted by a lexer and consumed by a parser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_type:, token_name:, token_value:, loc:) ⇒ Token

Returns a new instance of Token.

Parameters:

  • token_type (Integer)
  • token_name (String)
  • token_value (String)
  • loc (Loc)


61
62
63
64
65
66
67
68
# File 'lib/lib-ruby-parser.rb', line 61

def initialize(token_type:, token_name:, token_value:, loc:)
  @token_type = token_type
  @token_name = token_name
  @token_value = token_value
  @lex_state_before = 0
  @lex_state_after = 0
  @loc = loc
end

Instance Attribute Details

#lex_state_afterInteger

Lex state after token was read

Returns:

  • (Integer)


50
51
52
# File 'lib/lib-ruby-parser.rb', line 50

def lex_state_after
  @lex_state_after
end

#lex_state_beforeInteger

Lex state before token was read

Returns:

  • (Integer)


45
46
47
# File 'lib/lib-ruby-parser.rb', line 45

def lex_state_before
  @lex_state_before
end

#locLoc

Location of the token

Returns:



55
56
57
# File 'lib/lib-ruby-parser.rb', line 55

def loc
  @loc
end

#token_nameString

String type of the token

Returns:

  • (String)


35
36
37
# File 'lib/lib-ruby-parser.rb', line 35

def token_name
  @token_name
end

#token_typeInteger

Numeric representation of the token type, e.g. +132+ (for example) for +tINTEGER+

Returns:

  • (Integer)


30
31
32
# File 'lib/lib-ruby-parser.rb', line 30

def token_type
  @token_type
end

#token_valueString

Value of the token, e.g +“42”+ for +42+

Returns:

  • (String)


40
41
42
# File 'lib/lib-ruby-parser.rb', line 40

def token_value
  @token_value
end