Class: Baba::Token
- Inherits:
-
Object
- Object
- Baba::Token
- Defined in:
- lib/baba/token.rb
Instance Attribute Summary collapse
-
#lexeme ⇒ Object
readonly
Returns the value of attribute lexeme.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, lexeme, literal, line) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
Constructor Details
#initialize(type, lexeme, literal, line) ⇒ Token
Returns a new instance of Token.
5 6 7 8 9 10 |
# File 'lib/baba/token.rb', line 5 def initialize(type, lexeme, literal, line) @type = type @lexeme = lexeme @literal = literal @line = line end |
Instance Attribute Details
#lexeme ⇒ Object (readonly)
Returns the value of attribute lexeme.
3 4 5 |
# File 'lib/baba/token.rb', line 3 def lexeme @lexeme end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/baba/token.rb', line 3 def line @line end |
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
3 4 5 |
# File 'lib/baba/token.rb', line 3 def literal @literal end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/baba/token.rb', line 3 def type @type end |
Instance Method Details
#to_s ⇒ Object
12 13 14 |
# File 'lib/baba/token.rb', line 12 def to_s return "#{@type} #{@lexeme} #{@literal}" end |