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
-
#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.
12 13 14 15 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 12 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.
10 11 12 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 10 def range @range end |
#symbol ⇒ Object (readonly)
Link to the grammar symbol
7 8 9 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 7 def symbol @symbol end |
Instance Method Details
#to_s ⇒ Object
Emit a short string representation of the node. Mainly used for diagnosis/debugging purposes.
30 31 32 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 30 def to_s() return "#{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.
24 25 26 |
# File 'lib/rley/ptree/parse_tree_node.rb', line 24 def to_string(indentation) return "#{symbol.name}#{range.to_string(indentation)}" end |