Class: Kaguya::AST::Node
- Inherits:
-
Object
- Object
- Kaguya::AST::Node
- Defined in:
- lib/kaguya/ast/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #accept(compiler) ⇒ Array
-
#initialize(type:, parent:) ⇒ Node
constructor
A new instance of Node.
- #to_s ⇒ String
Constructor Details
#initialize(type:, parent:) ⇒ Node
Returns a new instance of Node.
12 13 14 15 16 17 18 |
# File 'lib/kaguya/ast/node.rb', line 12 def initialize(type:, parent:) @type = type @parent = parent @children = [] @parent.children << self if @parent end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
7 8 9 |
# File 'lib/kaguya/ast/node.rb', line 7 def children @children end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/kaguya/ast/node.rb', line 6 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/kaguya/ast/node.rb', line 8 def type @type end |
Instance Method Details
#accept(compiler) ⇒ Array
22 23 24 |
# File 'lib/kaguya/ast/node.rb', line 22 def accept(compiler) compiler.visit(self) end |
#to_s ⇒ String
27 28 29 |
# File 'lib/kaguya/ast/node.rb', line 27 def to_s @type.to_s end |