Sha256: 2c78cbfb0f6ee6490c5cc763c25908b4bb00225cbe9c3e0d8ad512aee632f246

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require_relative 'lox_compound_expr'

module Loxxy
  module Ast
    class LoxForStmt < LoxCompoundExpr
      # @return [LoxNode] test expression
      attr_reader :test_expr

      # @return [LoxNode] update expression
      attr_reader :update_expr

      # @return [LoxNode] body statement
      attr_accessor :body_stmt

      # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
      # @param initialization [Loxxy::Ast::LoxNode]
      # @param testExpr [Loxxy::Ast::LoxNode]
      # @param updateExpr [Loxxy::Ast::LoxNode]
      def initialize(aPosition, initialization, testExpr, updateExpr)
        child = initialization ? [initialization] : []
        super(aPosition, child)
        @test_expr = testExpr
        @update_expr = updateExpr
      end

      # Accessor to the condition expression
      # @return [LoxNode]
      def condition
        subnodes[0]
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loxxy-0.2.04 lib/loxxy/ast/lox_for_stmt.rb
loxxy-0.2.03 lib/loxxy/ast/lox_for_stmt.rb