Class: Rley::SPPF::TokenNode
- Defined in:
- lib/rley/sppf/token_node.rb
Overview
A node in a parse forest that matches exactly one token from the input
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes inherited from SPPFNode
Instance Method Summary collapse
-
#initialize(aToken, aPosition) ⇒ TokenNode
constructor
aPosition is the position of the token in the input stream.
- #key ⇒ Object
-
#to_string(indentation) ⇒ Object
Emit a (formatted) string representation of the node.
Methods inherited from SPPFNode
Constructor Details
#initialize(aToken, aPosition) ⇒ TokenNode
aPosition is the position of the token in the input stream.
11 12 13 14 15 |
# File 'lib/rley/sppf/token_node.rb', line 11 def initialize(aToken, aPosition) range = { low: aPosition, high: aPosition + 1 } super(range) @token = aToken end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/rley/sppf/token_node.rb', line 8 def token @token end |
Instance Method Details
#key ⇒ Object
23 24 25 |
# File 'lib/rley/sppf/token_node.rb', line 23 def key() @key ||= to_string(0) end |
#to_string(indentation) ⇒ Object
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.
19 20 21 |
# File 'lib/rley/sppf/token_node.rb', line 19 def to_string(indentation) return "#{token.terminal.name}#{range.to_string(indentation)}" end |