Class: Rley::SPPF::AlternativeNode
- Inherits:
-
CompositeNode
- Object
- SPPFNode
- CompositeNode
- Rley::SPPF::AlternativeNode
- Defined in:
- lib/rley/sppf/alternative_node.rb
Overview
A node in a parse forest that is a child of a parent node with :or refinement
Instance Attribute Summary collapse
-
#label ⇒ String
readonly
GFG vertex label.
-
#symbol ⇒ Syntax::NonTerminal
readonly
Link to lhs symbol.
Attributes inherited from CompositeNode
Attributes inherited from SPPFNode
Instance Method Summary collapse
-
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
-
#initialize(aVertex, aRange) ⇒ AlternativeNode
constructor
A new instance of AlternativeNode.
-
#to_string(indentation) ⇒ String
Emit a (formatted) string representation of the node.
Methods inherited from CompositeNode
#add_edge_signatures, #add_subnode, #inspect, #key, #signature_exist?
Methods inherited from SPPFNode
Constructor Details
#initialize(aVertex, aRange) ⇒ AlternativeNode
Returns a new instance of AlternativeNode.
21 22 23 24 25 |
# File 'lib/rley/sppf/alternative_node.rb', line 21 def initialize(aVertex, aRange) super(aRange) @label = aVertex.label @symbol = aVertex.dotted_item.lhs end |
Instance Attribute Details
#label ⇒ String (readonly)
Returns GFG vertex label.
11 12 13 |
# File 'lib/rley/sppf/alternative_node.rb', line 11 def label @label end |
#symbol ⇒ Syntax::NonTerminal (readonly)
Returns Link to lhs symbol.
14 15 16 |
# File 'lib/rley/sppf/alternative_node.rb', line 14 def symbol @symbol end |
Instance Method Details
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
36 37 38 |
# File 'lib/rley/sppf/alternative_node.rb', line 36 def accept(aVisitor) aVisitor.visit_alternative(self) end |
#to_string(indentation) ⇒ String
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.
30 31 32 |
# File 'lib/rley/sppf/alternative_node.rb', line 30 def to_string(indentation) "Alt(#{label})#{range.to_string(indentation)}" end |