Class: Token
- Inherits:
-
Object
- Object
- Token
- Defined in:
- lib/crokus/token.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#val ⇒ Object
(also: #str)
Returns the value of attribute val.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor, arg = nil) ⇒ Object
-
#initialize(tab) ⇒ Token
constructor
A new instance of Token.
- #inspect ⇒ Object
- #is?(kind) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(tab) ⇒ Token
Returns a new instance of Token.
3 4 5 |
# File 'lib/crokus/token.rb', line 3 def initialize tab @kind,@val,@pos=*tab end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
2 3 4 |
# File 'lib/crokus/token.rb', line 2 def kind @kind end |
#pos ⇒ Object
Returns the value of attribute pos.
2 3 4 |
# File 'lib/crokus/token.rb', line 2 def pos @pos end |
#val ⇒ Object Also known as: str
Returns the value of attribute val.
2 3 4 |
# File 'lib/crokus/token.rb', line 2 def val @val end |
Class Method Details
Instance Method Details
#accept(visitor, arg = nil) ⇒ Object
21 22 23 |
# File 'lib/crokus/token.rb', line 21 def accept visitor,arg=nil visitor.visitToken(self,arg) end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/crokus/token.rb', line 33 def inspect "(#{kind},#{val},#{pos})" end |
#is?(kind) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/crokus/token.rb', line 7 def is? 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 |
#to_s ⇒ Object
29 30 31 |
# File 'lib/crokus/token.rb', line 29 def to_s val end |