class Vertigo::Token

Attributes

kind[RW]
pos[RW]
val[RW]

Public Class Methods

create(kind,str) click to toggle source
# File lib/vertigo/token.rb, line 47
def self.create kind,str
  Token.new [kind,str,[0,0]]
end
new(tab) click to toggle source
# File lib/vertigo/token.rb, line 5
def initialize tab
  @kind,@val,@pos=*tab
end

Public Instance Methods

accept(visitor,args=nil) click to toggle source
# File lib/vertigo/token.rb, line 43
def accept visitor,args=nil
  visitor.visitToken(self)
end
clone() click to toggle source
# File lib/vertigo/token.rb, line 59
def clone
  Token.new([@kind,@val,@pos])
end
is_a?(kind) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/vertigo/token.rb, line 63
def line
  pos.first
end
not_a?(kind) click to toggle source
# File lib/vertigo/token.rb, line 23
def not_a? kind
  result=self.is_a? kind
  !result
end
str() click to toggle source

def inspect

"(#{@kind.to_s.ljust(15,' ')},'#{@val}',#{@pos})"

end

# File lib/vertigo/token.rb, line 55
def str
  val
end