Class: Rley::SPPF::NonTerminalNode
- Inherits:
-
CompositeNode
- Object
- SPPFNode
- CompositeNode
- Rley::SPPF::NonTerminalNode
- Defined in:
- lib/rley/sppf/non_terminal_node.rb
Overview
A node in a parse forest that matches exactly one non-terminal symbol
Instance Attribute Summary collapse
-
#refinement ⇒ Object
Indication on how the sub-nodes contribute to the 'success' of parent node.
-
#symbol ⇒ Object
readonly
Link to the non-terminal symbol.
Attributes inherited from CompositeNode
Attributes inherited from SPPFNode
Instance Method Summary collapse
- #add_subnode(aSubnode) ⇒ Object
-
#initialize(aNonTerminal, aRange) ⇒ NonTerminalNode
constructor
A new instance of NonTerminalNode.
-
#to_string(indentation) ⇒ Object
Emit a (formatted) string representation of the node.
Methods inherited from CompositeNode
Methods inherited from SPPFNode
Constructor Details
#initialize(aNonTerminal, aRange) ⇒ NonTerminalNode
Returns a new instance of NonTerminalNode.
15 16 17 18 19 |
# File 'lib/rley/sppf/non_terminal_node.rb', line 15 def initialize(aNonTerminal, aRange) super(aRange) @symbol = aNonTerminal @refinement = :and end |
Instance Attribute Details
#refinement ⇒ Object
Indication on how the sub-nodes contribute to the 'success' of parent node. Possible values: :and, :or
13 14 15 |
# File 'lib/rley/sppf/non_terminal_node.rb', line 13 def refinement @refinement end |
#symbol ⇒ Object (readonly)
Link to the non-terminal symbol
9 10 11 |
# File 'lib/rley/sppf/non_terminal_node.rb', line 9 def symbol @symbol end |
Instance Method Details
#add_subnode(aSubnode) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rley/sppf/non_terminal_node.rb', line 21 def add_subnode(aSubnode) if refinement == :or subnodes << aSubnode else super(aSubnode) end end |
#to_string(indentation) ⇒ Object
Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.
31 32 33 |
# File 'lib/rley/sppf/non_terminal_node.rb', line 31 def to_string(indentation) return "#{symbol.name}#{range.to_string(indentation)}" end |