class Rley::SPPF::CompositeNode
Monkey-patching
Abstract class. The generalization for nodes that have children node(s).
Attributes
@return [Array<SPFFNode>] Sub-nodes (children).
@return [Array<SPFFNode>] Sub-nodes (children).
Public Class Methods
Source
# File lib/rley/sppf/composite_node.rb, line 17 def initialize(aRange) super(aRange) @subnodes = [] end
Constructor @param aRange [Lexical::TokenRange]
Calls superclass method
Public Instance Methods
Source
# File lib/rley/sppf/composite_node.rb, line 40 def accept(aVisitor) raise NotImplementedError end
Part of the ‘visitee’ role in Visitor design pattern. @param aVisitor the visitor
Source
# File lib/rley/parse_forest_visitor.rb, line 13 def add_edge_signatures(prime_enumerator) @signatures = subnodes.map { |_| prime_enumerator.next } end
Associate for each edge between this node and each subnode an unique prime number (called a signature).
Source
# File lib/rley/sppf/composite_node.rb, line 24 def add_subnode(aSubnode) subnodes.unshift(aSubnode) end
Add a sub-node (child) to this one. @param aSubnode [SPPFNode]
Source
# File lib/rley/sppf/composite_node.rb, line 29 def inspect key end
@return [String] a text representation of the node.
Source
# File lib/rley/sppf/composite_node.rb, line 34 def key @key ||= to_string(0) end
@return [String]
Source
# File lib/rley/parse_forest_visitor.rb, line 17 def signature_exist? !@signatures.nil? end