Class: Loxxy::Ast::LoxVariableExpr

Inherits:
LoxNode
  • Object
show all
Defined in:
lib/loxxy/ast/lox_variable_expr.rb

Overview

This AST node represents a mention of a variable

Instance Attribute Summary collapse

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxNode

#done!

Constructor Details

#initialize(aPosition, aName) ⇒ LoxVariableExpr

Returns a new instance of LoxVariableExpr.

Parameters:

  • aPosition (Rley::Lexical::Position)

    Position of the entry in the input stream.

  • aName (String)

    name of the variable



14
15
16
17
# File 'lib/loxxy/ast/lox_variable_expr.rb', line 14

def initialize(aPosition, aName)
  super(aPosition)
  @name = aName
end

Instance Attribute Details

#nameString (readonly)

Returns variable name.

Returns:

  • (String)

    variable name



10
11
12
# File 'lib/loxxy/ast/lox_variable_expr.rb', line 10

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

Part of the 'visitee' role in Visitor design pattern.

Parameters:



21
22
23
# File 'lib/loxxy/ast/lox_variable_expr.rb', line 21

def accept(visitor)
  visitor.visit_variable_expr(self)
end