2009-12-17 22:54:24 -05:00
|
|
|
module CoffeeScript
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
# Instead of producing raw Ruby objects, the Lexer produces values of this
|
|
|
|
# class, wrapping native objects tagged with line number information.
|
|
|
|
class Value
|
|
|
|
attr_reader :line
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def initialize(value, line)
|
|
|
|
@value, @line = value, line
|
|
|
|
end
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def to_str
|
|
|
|
@value.to_s
|
|
|
|
end
|
|
|
|
alias_method :to_s, :to_str
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def inspect
|
|
|
|
@value.inspect
|
|
|
|
end
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def ==(other)
|
|
|
|
@value == other
|
|
|
|
end
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def [](index)
|
|
|
|
@value[index]
|
|
|
|
end
|
2009-12-17 09:37:42 -05:00
|
|
|
|
2009-12-17 22:54:24 -05:00
|
|
|
def eql?(other)
|
|
|
|
@value.eql?(other)
|
|
|
|
end
|
|
|
|
|
|
|
|
def hash
|
|
|
|
@value.hash
|
|
|
|
end
|
2009-12-17 09:37:42 -05:00
|
|
|
end
|
2009-12-17 22:54:24 -05:00
|
|
|
|
2009-12-17 09:37:42 -05:00
|
|
|
end
|