Class: Lex::Token
Overview
Used to represent the tokens produced
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, &action) ⇒ Token
constructor
A new instance of Token.
-
#to_ary ⇒ Symbol, ...
Return this token as array of values.
-
#to_s ⇒ Object
(also: #inspect)
Return a string representation.
- #update_line(line, column) ⇒ Object
Constructor Details
#initialize(name, value, &action) ⇒ Token
Returns a new instance of Token.
16 17 18 19 20 21 |
# File 'lib/lex/token.rb', line 16 def initialize(name, value, &action) @name = name @value = value @action = action @source_line = SourceLine.new end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/lex/token.rb', line 12 def action @action end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/lex/token.rb', line 10 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/lex/token.rb', line 10 def value @value end |
Instance Method Details
#to_ary ⇒ Symbol, ...
Return this token as array of values
33 34 35 |
# File 'lib/lex/token.rb', line 33 def to_ary [name, value, line, column] end |
#to_s ⇒ Object Also known as: inspect
Return a string representation
42 43 44 |
# File 'lib/lex/token.rb', line 42 def to_s "Lex::Token(#{to_ary.join(',')})" end |
#update_line(line, column) ⇒ Object
23 24 25 26 |
# File 'lib/lex/token.rb', line 23 def update_line(line, column) @source_line.line = line @source_line.column = column end |