Class: Rley::SPPF::TokenNode
- Defined in:
- lib/rley/sppf/token_node.rb
Overview
A SPPF node that matches exactly one token from the input.
Instance Attribute Summary collapse
-
#token ⇒ Lexical::Token
readonly
The input token that is represented by this parse node.
Attributes inherited from SPPFNode
Instance Method Summary collapse
-
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
-
#initialize(aToken, aPosition) ⇒ TokenNode
constructor
Constructor.
-
#to_string(indentation) ⇒ String
Emit a (formatted) string representation of the node.
Methods inherited from LeafNode
Methods inherited from SPPFNode
Constructor Details
#initialize(aToken, aPosition) ⇒ TokenNode
Constructor
15 16 17 18 19 |
# File 'lib/rley/sppf/token_node.rb', line 15 def initialize(aToken, aPosition) range = { low: aPosition, high: aPosition + 1 } super(range) @token = aToken end |
Instance Attribute Details
#token ⇒ Lexical::Token (readonly)
The input token that is represented by this parse node.
10 11 12 |
# File 'lib/rley/sppf/token_node.rb', line 10 def token @token end |
Instance Method Details
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
31 32 33 |
# File 'lib/rley/sppf/token_node.rb', line 31 def accept(aVisitor) aVisitor.visit_terminal(self) end |
#to_string(indentation) ⇒ String
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.
25 26 27 |
# File 'lib/rley/sppf/token_node.rb', line 25 def to_string(indentation) return "#{token.terminal.name}#{range.to_string(indentation)}" end |