Class: Rley::RGN::ASTNode
- Inherits:
-
Object
- Object
- Rley::RGN::ASTNode
- Defined in:
- lib/rley/rgn/ast_node.rb
Overview
Abstract class. Instances of its subclasses represent nodes of an abstract syntax tree that is the product of the parse of an input text.
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#accept(_visitor) ⇒ Object
Abstract method (must be overriden in subclasses).
- #annotation_to_text ⇒ Object
-
#done! ⇒ Object
Notification that the parsing has successfully completed.
-
#initialize ⇒ ASTNode
constructor
A new instance of ASTNode.
Constructor Details
#initialize ⇒ ASTNode
Returns a new instance of ASTNode.
12 13 14 |
# File 'lib/rley/rgn/ast_node.rb', line 12 def initialize @annotation = {} end |
Instance Attribute Details
#annotation ⇒ Hash
10 11 12 |
# File 'lib/rley/rgn/ast_node.rb', line 10 def annotation @annotation end |
Instance Method Details
#accept(_visitor) ⇒ Object
Abstract method (must be overriden in subclasses). Part of the 'visitee' role in Visitor design pattern.
40 41 42 |
# File 'lib/rley/rgn/ast_node.rb', line 40 def accept(_visitor) raise NotImplementedError end |
#annotation_to_text ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/rley/rgn/ast_node.rb', line 22 def annotation_to_text map_arr = [] @annotation.each_pair do |key, val| literal = val.kind_of?(String) ? "'#{val}'" : val map_arr << "#{key}: #{literal}" end "{ #{map_arr.join(', ')} }" end |
#done! ⇒ Object
Notification that the parsing has successfully completed
33 34 35 |
# File 'lib/rley/rgn/ast_node.rb', line 33 def done! # Default: do nothing ... end |