Class: Rley::PTree::ParseTreeNode
- Inherits:
-
Object
- Object
- Rley::PTree::ParseTreeNode
- Defined in:
- lib/rley/ptree/parse_tree_node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#range ⇒ Object
A range of indices for tokens corresponding to the node.
-
#symbol ⇒ Object
readonly
Link to the grammar symbol.
Instance Method Summary collapse
-
#done! ⇒ Object
Notify the builder that the construction is over.
-
#initialize(aSymbol, aRange) ⇒ ParseTreeNode
constructor
A new instance of ParseTreeNode.
-
#to_s ⇒ Object
Emit a short string representation of the node.
-
#to_string(indentation) ⇒ Object
Emit a (formatted) string representation of the node.
Constructor Details
#initialize(aSymbol, aRange) ⇒ ParseTreeNode
Returns a new instance of ParseTreeNode.
14 15 16 17 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 14 def initialize(aSymbol, aRange) @symbol = aSymbol @range = Lexical::TokenRange.new(aRange) end |
Instance Attribute Details
#range ⇒ Object
A range of indices for tokens corresponding to the node.
12 13 14 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 12 def range @range end |
#symbol ⇒ Object (readonly)
Link to the grammar symbol
9 10 11 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 9 def symbol @symbol end |
Instance Method Details
#done! ⇒ Object
Notify the builder that the construction is over
20 21 22 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 20 def done! # Do nothing end |
#to_s ⇒ Object
Emit a short string representation of the node. Mainly used for diagnosis/debugging purposes.
37 38 39 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 37 def to_s "#{symbol.name}#{range.to_string(0)}" 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/ptree/parse_tree_node.rb', line 31 def to_string(indentation) "#{symbol.name}#{range.to_string(indentation)}" end |