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
-
#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
Methods inherited from SPPFNode
Constructor Details
#initialize(aVertex, aRange) ⇒ AlternativeNode
Returns a new instance of AlternativeNode.
19 20 21 22 23 |
# File 'lib/rley/sppf/alternative_node.rb', line 19 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.
9 10 11 |
# File 'lib/rley/sppf/alternative_node.rb', line 9 def label @label end |
#symbol ⇒ Syntax::NonTerminal (readonly)
Returns Link to lhs symbol.
12 13 14 |
# File 'lib/rley/sppf/alternative_node.rb', line 12 def symbol @symbol end |
Instance Method Details
#to_string(indentation) ⇒ String
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.
28 29 30 |
# File 'lib/rley/sppf/alternative_node.rb', line 28 def to_string(indentation) return "Alt(#{label})#{range.to_string(indentation)}" end |