Sha256: 2343bce67ab39f335bb1cf97bd818b041235a6b53b7685de7ed67ed08e4cf2a7

Contents?: true

Size: 893 Bytes

Versions: 13

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

require_relative 'lox_compound_expr'

module Loxxy
  module Ast
    # This AST node represents a variable declaration
    class LoxVarStmt < LoxCompoundExpr
      # @return [String] variable name
      attr_reader :name

      # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
      # @param aName [String] name of the variable
      # @param aValue [Loxxy::Ast::LoxNode, NilClass] initial value for the variable
      def initialize(aPosition, aName, aValue)
        initial_value = aValue || Datatype::Nil.instance
        super(aPosition, [initial_value])
        @name = aName
      end

      # Part of the 'visitee' role in Visitor design pattern.
      # @param visitor [Ast::ASTVisitor] the visitor
      def accept(visitor)
        visitor.visit_var_stmt(self)
      end
    end # class
  end # module
end # module

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
loxxy-0.2.02 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.01 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.00 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.17 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.16 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.15 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.14 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.13 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.12 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.11 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.10 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.09 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.1.08 lib/loxxy/ast/lox_var_stmt.rb