Class: Lexr::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/lexr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, type = nil) ⇒ Token

Returns a new instance of Token.



61
62
63
# File 'lib/lexr.rb', line 61

def initialize(value, type = nil)
	@value, @type = value, type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



59
60
61
# File 'lib/lexr.rb', line 59

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



59
60
61
# File 'lib/lexr.rb', line 59

def value
  @value
end

Class Method Details

.method_missing(sym, *args) ⇒ Object



65
66
67
# File 'lib/lexr.rb', line 65

def self.method_missing(sym, *args)
	self.new(args.first, sym)
end

Instance Method Details

#==(other) ⇒ Object



73
74
75
# File 'lib/lexr.rb', line 73

def ==(other)
	@type == other.type && @value == other.value
end

#to_sObject



69
70
71
# File 'lib/lexr.rb', line 69

def to_s
	"#{type}(#{value})"
end