Class: LibRubyParser::Token
- Inherits:
-
Object
- Object
- LibRubyParser::Token
- 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
-
#lex_state_after ⇒ Integer
Lex state after token was read.
-
#lex_state_before ⇒ Integer
Lex state before token was read.
-
#loc ⇒ Loc
Location of the token.
-
#token_name ⇒ String
String type of the token.
-
#token_type ⇒ Integer
Numeric representation of the token type, e.g.
-
#token_value ⇒ String
Value of the token, e.g +“42”+ for +42+.
Instance Method Summary collapse
-
#initialize(token_type:, token_name:, token_value:, loc:) ⇒ Token
constructor
A new instance of Token.
Constructor Details
#initialize(token_type:, token_name:, token_value:, loc:) ⇒ Token
Returns a new instance of Token.
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_after ⇒ Integer
Lex state after token was read
50 51 52 |
# File 'lib/lib-ruby-parser.rb', line 50 def lex_state_after @lex_state_after end |
#lex_state_before ⇒ Integer
Lex state before token was read
45 46 47 |
# File 'lib/lib-ruby-parser.rb', line 45 def lex_state_before @lex_state_before end |
#token_name ⇒ String
String type of the token
35 36 37 |
# File 'lib/lib-ruby-parser.rb', line 35 def token_name @token_name end |
#token_type ⇒ Integer
Numeric representation of the token type, e.g. +132+ (for example) for +tINTEGER+
30 31 32 |
# File 'lib/lib-ruby-parser.rb', line 30 def token_type @token_type end |
#token_value ⇒ String
Value of the token, e.g +“42”+ for +42+
40 41 42 |
# File 'lib/lib-ruby-parser.rb', line 40 def token_value @token_value end |