class AST::ForLoop attr_reader :iterator, :iterable, :block def initialize(iterator, iterable, block) @iterator = iterator @iterable = iterable @block = block end def ==(other) other.is_a?(AST::ForLoop) && other.iterator == @iterator && other.iterable == @iterable && other.block == @block end def execute(env) @iterable.execute(env).each do |i| env.set(@iterator.name, i) @block.statements.each { |statement| statement.execute(env) } end end end