Class: Dendroid::Parsing::EmptyRuleNode
- Defined in:
- lib/dendroid/parsing/empty_rule_node.rb
Overview
A parse tree/forest node that is related to a production rule with an empty RHS (right-hand side).
Instance Attribute Summary collapse
-
#alt_index ⇒ Integer
readonly
Index of the rule alternative.
-
#rule ⇒ WeakRef<Dendroid::Syntax::Rule>
readonly
Grammar rule.
Attributes inherited from ParseNode
Instance Method Summary collapse
-
#accept(aVisitor) ⇒ Object
Part of the ‘visitee’ role in Visitor design pattern.
-
#initialize(anEItem, rank) ⇒ EmptyRuleNode
constructor
A new instance of EmptyRuleNode.
-
#to_s ⇒ String
Return a String representation of itself.
Constructor Details
#initialize(anEItem, rank) ⇒ EmptyRuleNode
Returns a new instance of EmptyRuleNode.
19 20 21 22 23 |
# File 'lib/dendroid/parsing/empty_rule_node.rb', line 19 def initialize(anEItem, rank) super(rank, rank) @rule = WeakRef.new(anEItem.dotted_item.rule) @alt_index = anEItem.dotted_item.alt_index end |
Instance Attribute Details
#alt_index ⇒ Integer (readonly)
Returns Index of the rule alternative.
15 16 17 |
# File 'lib/dendroid/parsing/empty_rule_node.rb', line 15 def alt_index @alt_index end |
#rule ⇒ WeakRef<Dendroid::Syntax::Rule> (readonly)
Returns Grammar rule.
12 13 14 |
# File 'lib/dendroid/parsing/empty_rule_node.rb', line 12 def rule @rule end |
Instance Method Details
#accept(aVisitor) ⇒ Object
Part of the ‘visitee’ role in Visitor design pattern.
33 34 35 |
# File 'lib/dendroid/parsing/empty_rule_node.rb', line 33 def accept(aVisitor) aVisitor.visit_empty_rule_node(self) end |
#to_s ⇒ String
Return a String representation of itself
27 28 29 |
# File 'lib/dendroid/parsing/empty_rule_node.rb', line 27 def to_s "_ #{range_to_s}" end |