class Rley::SPPF::NonTerminalNode
A node in a parse forest that matches exactly one non-terminal symbol.
Attributes
Indication on how the sub-nodes contribute to the ‘success’ of parent node. Possible values: :and, :or
@return [Syntax::NonTerminal] Link to the non-terminal symbol
Public Class Methods
Source
# File lib/rley/sppf/non_terminal_node.rb, line 20 def initialize(aNonTerminal, aRange) super(aRange) @symbol = aNonTerminal @refinement = :and end
Constructor @param aNonTerminal [Syntax::NonTerminal] @param aRange [Lexical::TokenRange]
Calls superclass method
Rley::SPPF::CompositeNode::new
Public Instance Methods
Source
# File lib/rley/sppf/non_terminal_node.rb, line 45 def accept(aVisitor) aVisitor.visit_nonterminal(self) end
Part of the ‘visitee’ role in Visitor design pattern. @param aVisitor the visitor
Source
# File lib/rley/sppf/non_terminal_node.rb, line 28 def add_subnode(aSubnode) if refinement == :or subnodes << aSubnode else super(aSubnode) end end
Add a sub-node (child) to this one. @param aSubnode [SPPFNode]
Calls superclass method
Rley::SPPF::CompositeNode#add_subnode
Source
# File lib/rley/sppf/non_terminal_node.rb, line 39 def to_string(indentation) return "#{symbol.name}#{range.to_string(indentation)}" end
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes. @return [String] a text representation of the node.