start to add while loop
This commit is contained in:
@ -4,7 +4,10 @@ module Ast
|
||||
def initialize cond, if_true, if_false
|
||||
@cond, @if_true, @if_false = cond, if_true, if_false
|
||||
end
|
||||
|
||||
def inspect
|
||||
self.class.name + ".new(" + cond.inspect + ", "+
|
||||
if_true.inspect + "," + if_false.inspect + " )"
|
||||
end
|
||||
def attributes
|
||||
[:cond, :if_true, :if_false]
|
||||
end
|
||||
|
@ -37,5 +37,6 @@ end
|
||||
|
||||
require_relative "basic_expressions"
|
||||
require_relative "conditional_expression"
|
||||
require_relative "while_expression"
|
||||
require_relative "function_expression"
|
||||
require_relative "operator_expressions"
|
||||
require_relative "operator_expressions"
|
||||
|
16
lib/ast/while_expression.rb
Normal file
16
lib/ast/while_expression.rb
Normal file
@ -0,0 +1,16 @@
|
||||
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
|
||||
def attributes
|
||||
[:condition, :body]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
Reference in New Issue
Block a user