rubyx/lib/ast/while_expression.rb

19 lines
428 B
Ruby
Raw Normal View History

2014-05-10 18:02:51 +02:00
module Ast
class WhileExpression < Expression
attr_reader :condition, :body
def initialize condition, body
@condition , @body = condition , body
end
def inspect
self.class.name + ".new(" + condition.inspect + ", " + body.inspect + " )"
end
2014-05-13 09:49:26 +02:00
def to_s
"while(#{condition}) do\n" + body.join("\n") + "\nend\n"
end
2014-05-10 18:02:51 +02:00
def attributes
[:condition, :body]
end
end
end