24 lines
488 B
Ruby
24 lines
488 B
Ruby
module Vool
|
|
class WhileStatement < Statement
|
|
attr_reader :condition , :statements
|
|
|
|
def initialize( condition , statements )
|
|
@condition = condition
|
|
@statements = statements
|
|
simplify_condition
|
|
end
|
|
|
|
def simplify_condition
|
|
return unless @condition.is_a?(ScopeStatement)
|
|
@condition = @condition.first if @condition.single?
|
|
end
|
|
|
|
def collect(arr)
|
|
@condition.collect(arr)
|
|
@statements.collect(arr)
|
|
super
|
|
end
|
|
|
|
end
|
|
end
|