Class: Vertigo::Token
- Inherits:
-
Object
- Object
- Vertigo::Token
- Defined in:
- lib/vertigo/token.rb
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.
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor, args = nil) ⇒ Object
- #clone ⇒ Object
-
#initialize(tab) ⇒ Token
constructor
A new instance of Token.
- #is_a?(kind) ⇒ Boolean
- #is_not_a?(kind) ⇒ Boolean
- #line ⇒ Object
- #not_a?(kind) ⇒ Boolean
-
#str ⇒ Object
def inspect “(#’),‘#@val’,#@pos)” end.
Constructor Details
#initialize(tab) ⇒ Token
Returns a new instance of Token.
5 6 7 |
# File 'lib/vertigo/token.rb', line 5 def initialize tab @kind,@val,@pos=*tab end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
4 5 6 |
# File 'lib/vertigo/token.rb', line 4 def kind @kind end |
#pos ⇒ Object
Returns the value of attribute pos.
4 5 6 |
# File 'lib/vertigo/token.rb', line 4 def pos @pos end |
#val ⇒ Object
Returns the value of attribute val.
4 5 6 |
# File 'lib/vertigo/token.rb', line 4 def val @val end |
Class Method Details
Instance Method Details
#accept(visitor, args = nil) ⇒ Object
43 44 45 |
# File 'lib/vertigo/token.rb', line 43 def accept visitor,args=nil visitor.visitToken(self) end |
#clone ⇒ Object
59 60 61 |
# File 'lib/vertigo/token.rb', line 59 def clone Token.new([@kind,@val,@pos]) end |
#is_a?(kind) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vertigo/token.rb', line 9 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 |
#is_not_a?(kind) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vertigo/token.rb', line 28 def is_not_a? kind case kind when Symbol return @kind!=kind when Array ret=true for sym in kind ret=false if @kind==sym end return ret else raise "wrong type during lookahead" end end |
#line ⇒ Object
63 64 65 |
# File 'lib/vertigo/token.rb', line 63 def line pos.first end |
#not_a?(kind) ⇒ Boolean
23 24 25 26 |
# File 'lib/vertigo/token.rb', line 23 def not_a? kind result=self.is_a? kind !result end |
#str ⇒ Object
def inspect
"(#{@kind.to_s.ljust(15,' ')},'#{@val}',#{@pos})"
end
55 56 57 |
# File 'lib/vertigo/token.rb', line 55 def str val end |