Class: Loxxy::Ast::LoxVarStmt
- Inherits:
-
LoxCompoundExpr
- Object
- LoxNode
- LoxCompoundExpr
- Loxxy::Ast::LoxVarStmt
- Defined in:
- lib/loxxy/ast/lox_var_stmt.rb
Overview
This AST node represents a variable declaration
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Variable name.
Attributes inherited from LoxCompoundExpr
Attributes inherited from LoxNode
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
-
#initialize(aPosition, aName, aValue) ⇒ LoxVarStmt
constructor
A new instance of LoxVarStmt.
Methods inherited from LoxNode
Constructor Details
#initialize(aPosition, aName, aValue) ⇒ LoxVarStmt
Returns a new instance of LoxVarStmt.
15 16 17 18 19 |
# File 'lib/loxxy/ast/lox_var_stmt.rb', line 15 def initialize(aPosition, aName, aValue) initial_value = aValue || Datatype::Nil.instance super(aPosition, [initial_value]) @name = aName end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns variable name.
10 11 12 |
# File 'lib/loxxy/ast/lox_var_stmt.rb', line 10 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
23 24 25 |
# File 'lib/loxxy/ast/lox_var_stmt.rb', line 23 def accept(visitor) visitor.visit_var_stmt(self) end |