Class: Rley::RGN::SymbolNode
- Defined in:
- lib/rley/rgn/symbol_node.rb
Overview
A syntax node for a grammar symbol occurring in rhs of a rule. symbol nodes are leaf nodes of RRN parse trees.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Name of grammar symbol.
-
#position ⇒ Rley::Lexical::Position
readonly
Position of the entry in the input stream.
Attributes inherited from ASTNode
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
Abstract method (must be overriden in subclasses).
-
#initialize(aPosition, aName) ⇒ SymbolNode
constructor
A new instance of SymbolNode.
-
#to_text ⇒ String
Name of grammar symbol.
Methods inherited from ASTNode
Constructor Details
#initialize(aPosition, aName) ⇒ SymbolNode
Returns a new instance of SymbolNode.
18 19 20 21 22 |
# File 'lib/rley/rgn/symbol_node.rb', line 18 def initialize(aPosition, aName) super() @position = aPosition @name = aName end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns name of grammar symbol.
14 15 16 |
# File 'lib/rley/rgn/symbol_node.rb', line 14 def name @name end |
#position ⇒ Rley::Lexical::Position (readonly)
Returns Position of the entry in the input stream.
11 12 13 |
# File 'lib/rley/rgn/symbol_node.rb', line 11 def position @position end |
Instance Method Details
#accept(visitor) ⇒ Object
Abstract method (must be overriden in subclasses). Part of the 'visitee' role in Visitor design pattern.
32 33 34 |
# File 'lib/rley/rgn/symbol_node.rb', line 32 def accept(visitor) visitor.visit_symbol_node(self) end |
#to_text ⇒ String
Returns name of grammar symbol.
25 26 27 |
# File 'lib/rley/rgn/symbol_node.rb', line 25 def to_text annotation.empty? ? name : "#{name} #{annotation_to_text}" end |