Class: Token
- Inherits:
-
Object
- Object
- Token
- Defined in:
- lib/lexer.rb
Overview
require ‘benchmark’
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
-
#initialize(tab) ⇒ Token
constructor
A new instance of Token.
- #is_a?(kind) ⇒ Boolean
Constructor Details
#initialize(tab) ⇒ Token
Returns a new instance of Token.
7 8 9 |
# File 'lib/lexer.rb', line 7 def initialize tab @kind,@val,@pos=*tab end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/lexer.rb', line 6 def kind @kind end |
#pos ⇒ Object
Returns the value of attribute pos.
6 7 8 |
# File 'lib/lexer.rb', line 6 def pos @pos end |
#val ⇒ Object
Returns the value of attribute val.
6 7 8 |
# File 'lib/lexer.rb', line 6 def val @val end |
Instance Method Details
#is_a?(kind) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lexer.rb', line 11 def is_a? kind case kind when Symbol return @kind==kind when Array for sym in kind return true if @kind==sym end return false else raise "wrong type during lookahead" end end |