Class: Rhetor::Token
- Inherits:
-
Struct
- Object
- Struct
- Rhetor::Token
- Defined in:
- lib/rhetor/token.rb
Overview
Token class represents tokens matched from the input.
Instance Attribute Summary collapse
-
#length ⇒ Integer
readonly
the length of the matched substring.
-
#name ⇒ Symbol
readonly
the name of the matched rule.
-
#position ⇒ Integer
readonly
the position of the matched substring.
-
#value ⇒ Object
readonly
the value of the token.
Instance Method Summary collapse
- #to_s ⇒ Object (also: #inspect)
Instance Attribute Details
#length ⇒ Integer (readonly)
the length of the matched substring
9 10 11 |
# File 'lib/rhetor/token.rb', line 9 def length @length end |
#name ⇒ Symbol (readonly)
the name of the matched rule
9 10 11 |
# File 'lib/rhetor/token.rb', line 9 def name @name end |
#position ⇒ Integer (readonly)
the position of the matched substring
9 10 11 |
# File 'lib/rhetor/token.rb', line 9 def position @position end |
#value ⇒ Object (readonly)
the value of the token
9 10 11 |
# File 'lib/rhetor/token.rb', line 9 def value @value end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
10 11 12 |
# File 'lib/rhetor/token.rb', line 10 def to_s "(#{name}: #{value.inspect} [#{position},#{length}])" end |