class Rley::SPPF::TokenNode
A SPPF
node that matches exactly one token from the input.
Attributes
@return [Lexical::Token] The input token that is represented by this parse node.
Public Class Methods
Source
# File lib/rley/sppf/token_node.rb, line 17 def initialize(aToken, aPosition) range = { low: aPosition, high: aPosition + 1 } super(range) @token = aToken end
Constructor @param aToken [Lexical::Token] input token represented by this node. @param aPosition [Integer] index of the token in the input stream.
Calls superclass method
Public Instance Methods
Source
# File lib/rley/sppf/token_node.rb, line 33 def accept(aVisitor) aVisitor.visit_terminal(self) end
Part of the ‘visitee’ role in Visitor design pattern. @param aVisitor the visitor
Source
# File lib/rley/sppf/token_node.rb, line 27 def to_string(indentation) "#{token.terminal.name}#{range.to_string(indentation)}" end
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes. @param indentation [Integer] @return [String]