Sha256: 48675bccca75f7a88412ccb9ef0af573841c55167731966b6e82c4aca4457705

Contents?: true

Size: 782 Bytes

Versions: 17

Compression:

Stored size: 782 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

      define_accept # Add `accept` method as found in Visitor design pattern
    end # class
  end # module
end # module

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
loxxy-0.4.08 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.07 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.06 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.05 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.04 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.03 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.02 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.01 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.4.00 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.3.03 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.3.02 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.3.01 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.3.00 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.06 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.05 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.04 lib/loxxy/ast/lox_var_stmt.rb
loxxy-0.2.03 lib/loxxy/ast/lox_var_stmt.rb