create some block tests and the expression
This commit is contained in:
26
lib/ast/block_expression.rb
Normal file
26
lib/ast/block_expression.rb
Normal file
@ -0,0 +1,26 @@
|
||||
module Ast
|
||||
class BlockExpression < Expression
|
||||
attr_reader :call_exp, :args , :body_exp
|
||||
|
||||
def initialize call_exp, args , body_exp
|
||||
@call_exp = call_exp.to_sym
|
||||
@args = args
|
||||
@body_exp = body_exp
|
||||
end
|
||||
|
||||
def attributes
|
||||
[:call_exp, :args , :body_exp]
|
||||
end
|
||||
|
||||
def inspect
|
||||
self.class.call_exp + ".new(" + call_exp.inspect + ", ["+
|
||||
args.collect{|m| m.inspect }.join( ",") + "] ," + body_exp.inspect + ")"
|
||||
end
|
||||
def to_s
|
||||
"#{call_exp}(" + args.join(",") + ")"
|
||||
end
|
||||
def attributes
|
||||
[:call_exp , :args , :body_exp]
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user