diff --git a/lib/arm/arm_machine.rb b/lib/arm/arm_machine.rb index a1eb4247..6a0ab3e0 100644 --- a/lib/arm/arm_machine.rb +++ b/lib/arm/arm_machine.rb @@ -54,7 +54,7 @@ module Arm end def function_call into , call - raise "Not FunctionCall #{call.inspect}" unless call.is_a? Vm::FunctionCall + raise "Not CallSite #{call.inspect}" unless call.is_a? Vm::CallSite raise "Not linked #{call.inspect}" unless call.function into.add_code bl( :left => call.function ) call.function.return_type diff --git a/lib/ast/call_site_expression.rb b/lib/ast/call_site_expression.rb new file mode 100644 index 00000000..343bc7c8 --- /dev/null +++ b/lib/ast/call_site_expression.rb @@ -0,0 +1,31 @@ +module Ast + # assignment, like operators are really function calls + + class CallSiteExpression < Expression + attr_reader :name, :args + def initialize name, args + @name , @args = name.to_sym , args + end + def compile context , into + params = args.collect{ |a| a.compile(context, into) } + function = context.program.get_or_create_function(name) + raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil + call = Vm::CallSite.new( name , params , function) + call.load_args into + call.do_call into + call + end + + def inspect + self.class.name + ".new(" + name.inspect + ", ["+ + args.collect{|m| m.inspect }.join( ",") +"] )" + end + def to_s + "#{name}(" + args.join(",") + ")" + end + def attributes + [:name , :args] + end + end + +end \ No newline at end of file diff --git a/lib/ast/expression.rb b/lib/ast/expression.rb index 795bc79c..0465d622 100644 --- a/lib/ast/expression.rb +++ b/lib/ast/expression.rb @@ -38,3 +38,4 @@ require_relative "conditional_expression" require_relative "while_expression" require_relative "function_expression" require_relative "operator_expressions" +require_relative "call_site_expression" diff --git a/lib/ast/operator_expressions.rb b/lib/ast/operator_expressions.rb index 2688dc21..85c1041e 100644 --- a/lib/ast/operator_expressions.rb +++ b/lib/ast/operator_expressions.rb @@ -1,34 +1,5 @@ module Ast - - # assignment, like operators are really function calls - - class FuncallExpression < Expression - attr_reader :name, :args - def initialize name, args - @name , @args = name.to_sym , args - end - def compile context , into - params = args.collect{ |a| a.compile(context, into) } - function = context.program.get_or_create_function(name) - raise "Forward declaration not implemented (#{name}) #{inspect}" if function == nil - call = Vm::FunctionCall.new( name , params , function) - call.load_args into - call.do_call into - call - end - def inspect - self.class.name + ".new(" + name.inspect + ", ["+ - args.collect{|m| m.inspect }.join( ",") +"] )" - end - def to_s - "#{name}(" + args.join(",") + ")" - end - def attributes - [:name , :args] - end - end - class OperatorExpression < Expression attr_reader :operator, :left, :right diff --git a/lib/parser/function_call.rb b/lib/parser/call_site.rb similarity index 77% rename from lib/parser/function_call.rb rename to lib/parser/call_site.rb index 89795a5b..cd747eab 100644 --- a/lib/parser/function_call.rb +++ b/lib/parser/call_site.rb @@ -1,5 +1,5 @@ module Parser - module FunctionCall + module CallSite include Parslet rule(:argument_list) { @@ -9,7 +9,7 @@ module Parser space? >> right_parenthesis } - rule(:function_call) { name.as(:function_call) >> argument_list } + rule(:call_site) { name.as(:call_site) >> argument_list } end diff --git a/lib/parser/crystal.rb b/lib/parser/crystal.rb index 73b4dc6f..bb824202 100644 --- a/lib/parser/crystal.rb +++ b/lib/parser/crystal.rb @@ -4,7 +4,7 @@ require_relative "tokens" require_relative "keywords" require_relative "control" require_relative "expression" -require_relative "function_call" +require_relative "call_site" require_relative "function_definition" require_relative "operators" @@ -25,10 +25,10 @@ module Parser include Keywords include Control include Expression - include FunctionCall + include CallSite include FunctionDefinition include Operators - rule(:root){ (function_definition | expression | operator_expression | function_call).repeat } + rule(:root){ (function_definition | expression | operator_expression | call_site).repeat } end end diff --git a/lib/parser/expression.rb b/lib/parser/expression.rb index bbe4a54e..dafc4ed4 100644 --- a/lib/parser/expression.rb +++ b/lib/parser/expression.rb @@ -2,9 +2,9 @@ module Parser module Expression include Parslet - rule(:value_expression) { function_call | basic_type } + rule(:value_expression) { call_site | basic_type } - rule(:expression) { (while_do | conditional | operator_expression | function_call ) >> newline } + rule(:expression) { (while_do | conditional | operator_expression | call_site ) >> newline } def delimited_expressions( delimit ) ( (delimit.absent? >> expression).repeat(1)).as(:expressions) >> delimit diff --git a/lib/parser/transform.rb b/lib/parser/transform.rb index 9ecfc2b5..f0242e4a 100644 --- a/lib/parser/transform.rb +++ b/lib/parser/transform.rb @@ -19,9 +19,9 @@ module Parser rule(:argument => simple(:argument)) { argument } rule(:argument_list => sequence(:argument_list)) { argument_list } - rule( :function_call => simple(:function_call), + rule( :call_site => simple(:call_site), :argument_list => sequence(:argument_list)) do - Ast::FuncallExpression.new(function_call.name, argument_list) + Ast::CallSiteExpression.new(call_site.name, argument_list) end rule(:if => simple(:if), :conditional => simple(:conditional), diff --git a/lib/vm/function_call.rb b/lib/vm/call_site.rb similarity index 94% rename from lib/vm/function_call.rb rename to lib/vm/call_site.rb index e19502f9..ecf9d92f 100644 --- a/lib/vm/function_call.rb +++ b/lib/vm/call_site.rb @@ -2,7 +2,7 @@ module Vm # name and args , return - class FunctionCall < Value + class CallSite < Value def initialize(name , args , function ) @name = name diff --git a/lib/vm/program.rb b/lib/vm/program.rb index c9ec6bc9..592f2537 100644 --- a/lib/vm/program.rb +++ b/lib/vm/program.rb @@ -1,5 +1,5 @@ require_relative "function" -require_relative "function_call" +require_relative "call_site" require "arm/arm_machine" module Vm diff --git a/test/parser/test_all.rb b/test/parser/test_all.rb index 4cd0fdb4..39e8767c 100644 --- a/test/parser/test_all.rb +++ b/test/parser/test_all.rb @@ -3,7 +3,7 @@ require_relative "test_basic" #require_relative "test_compound" require_relative "test_arguments" require_relative "test_expressions" -require_relative "test_function_call" +require_relative "test_call_site" require_relative "test_conditional" require_relative "test_while" require_relative "test_operators" diff --git a/test/parser/test_function_call.rb b/test/parser/test_call_site.rb similarity index 55% rename from test/parser/test_function_call.rb rename to test/parser/test_call_site.rb index a84e041b..b8b7de57 100644 --- a/test/parser/test_function_call.rb +++ b/test/parser/test_call_site.rb @@ -1,34 +1,34 @@ require_relative "helper" -class TestFunctionCall < MiniTest::Test +class TestCallSite < MiniTest::Test # include the magic (setup and parse -> test method translation), see there include ParserHelper def test_single_argument @string_input = 'foo(42)' - @parse_output = {:function_call => {:name => 'foo'}, + @parse_output = {:call_site => {:name => 'foo'}, :argument_list => [{:argument => {:integer => '42'} }] } - @transform_output = Ast::FuncallExpression.new 'foo', [Ast::IntegerExpression.new(42)] - @parser = @parser.function_call + @transform_output = Ast::CallSiteExpression.new 'foo', [Ast::IntegerExpression.new(42)] + @parser = @parser.call_site end - def test_function_call_multi + def test_call_site_multi @string_input = 'baz(42, foo)' - @parse_output = {:function_call => {:name => 'baz' }, + @parse_output = {:call_site => {:name => 'baz' }, :argument_list => [{:argument => {:integer => '42'}}, {:argument => {:name => 'foo'}}]} - @transform_output = Ast::FuncallExpression.new 'baz', + @transform_output = Ast::CallSiteExpression.new 'baz', [Ast::IntegerExpression.new(42), Ast::NameExpression.new("foo") ] - @parser = @parser.function_call + @parser = @parser.call_site end - def test_function_call_string + def test_call_site_string @string_input = 'puts( "hello")' - @parse_output = {:function_call => {:name => 'puts' }, + @parse_output = {:call_site => {:name => 'puts' }, :argument_list => [{:argument => {:string=>[{:char=>"h"}, {:char=>"e"}, {:char=>"l"}, {:char=>"l"}, {:char=>"o"}]}}]} - @transform_output = Ast::FuncallExpression.new "puts", [Ast::StringExpression.new("hello")] - @parser = @parser.function_call + @transform_output = Ast::CallSiteExpression.new "puts", [Ast::StringExpression.new("hello")] + @parser = @parser.call_site end end \ No newline at end of file diff --git a/test/parser/test_compound.rb b/test/parser/test_compound.rb index 7bfee3d0..4604b61e 100644 --- a/test/parser/test_compound.rb +++ b/test/parser/test_compound.rb @@ -20,10 +20,10 @@ class TestCompound < MiniTest::Test def test_array_ops @string_input = '[ 3 + 4 , foo(22) ]' - @parse_output = {:array=>[{:array_element=>{:l=>{:integer=>"3"}, :o=>"+ ", :r=>{:integer=>"4"}}}, {:array_element=>{:function_call=>{:name=>"foo"}, :argument_list=>[{:argument=>{:integer=>"22"}}]}}]} + @parse_output = {:array=>[{:array_element=>{:l=>{:integer=>"3"}, :o=>"+ ", :r=>{:integer=>"4"}}}, {:array_element=>{:call_site=>{:name=>"foo"}, :argument_list=>[{:argument=>{:integer=>"22"}}]}}]} @transform_output = Ast::ArrayExpression.new( [Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(3),Ast::IntegerExpression.new(4)), - Ast::FuncallExpression.new("foo", [Ast::IntegerExpression.new(22)] )]) + Ast::CallSiteExpression.new("foo", [Ast::IntegerExpression.new(22)] )]) @parser = @parser.array end diff --git a/test/parser/test_expressions.rb b/test/parser/test_expressions.rb index 1688311e..0eee563d 100644 --- a/test/parser/test_expressions.rb +++ b/test/parser/test_expressions.rb @@ -12,10 +12,10 @@ else HERE @string_input.chop! @parse_output = {:expressions=>[{:name=>"dud"}, - {:function_call=>{:name=>"fuu"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}], + {:call_site=>{:name=>"fuu"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}], :else=>"else"} @transform_output ={:expressions=>[Ast::NameExpression.new("dud"), - Ast::FuncallExpression.new("fuu", [Ast::IntegerExpression.new(3)] )], :else=>"else"} + Ast::CallSiteExpression.new("fuu", [Ast::IntegerExpression.new(3)] )], :else=>"else"} @parser = @parser.expressions_else end @@ -27,10 +27,10 @@ end HERE @string_input.chop! @parse_output = {:expressions=>[{:name=>"name"}, - {:function_call=>{:name=>"call"}, :argument_list=>[{:argument=>{:integer=>"4"}}, {:argument=>{:integer=>"6"}}]}], + {:call_site=>{:name=>"call"}, :argument_list=>[{:argument=>{:integer=>"4"}}, {:argument=>{:integer=>"6"}}]}], :end=>"end"} @transform_output = {:expressions=>[Ast::NameExpression.new("name"), - Ast::FuncallExpression.new("call", [Ast::IntegerExpression.new(4),Ast::IntegerExpression.new(6)] )], + Ast::CallSiteExpression.new("call", [Ast::IntegerExpression.new(4),Ast::IntegerExpression.new(6)] )], :end=>"end"} @parser = @parser.expressions_end diff --git a/test/parser/test_function_definition.rb b/test/parser/test_function_definition.rb index 70b22dec..f5009ccf 100644 --- a/test/parser/test_function_definition.rb +++ b/test/parser/test_function_definition.rb @@ -102,8 +102,8 @@ def fibonaccit(n) end end HERE - @parse_output = {:function_name=>{:name=>"fibonaccit"}, :parmeter_list=>[{:parmeter=>{:name=>"n"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"0"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:integer=>"1"}}, {:while=>"while", :while_cond=>{:l=>{:name=>"n"}, :o=>"> ", :r=>{:integer=>"1"}}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:l=>{:name=>"a"}, :o=>"= ", :r=>{:name=>"b"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:l=>{:name=>"tmp"}, :o=>"+ ", :r=>{:name=>"b"}}}, {:function_call=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}, {:l=>{:name=>"n"}, :o=>"= ", :r=>{:l=>{:name=>"n"}, :o=>"- ", :r=>{:integer=>"1"}}}], :end=>"end"}}], :end=>"end"} - @transform_output = Ast::FunctionExpression.new(:fibonaccit, [Ast::NameExpression.new("n")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(0)),Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::IntegerExpression.new(1)),Ast::WhileExpression.new(Ast::OperatorExpression.new(">", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)), [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::NameExpression.new("b")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::OperatorExpression.new("+", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("b"))), Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] ), Ast::OperatorExpression.new("=", Ast::NameExpression.new("n"),Ast::OperatorExpression.new("-", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)))] )] ) + @parse_output = {:function_name=>{:name=>"fibonaccit"}, :parmeter_list=>[{:parmeter=>{:name=>"n"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"0"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:integer=>"1"}}, {:while=>"while", :while_cond=>{:l=>{:name=>"n"}, :o=>"> ", :r=>{:integer=>"1"}}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:l=>{:name=>"a"}, :o=>"= ", :r=>{:name=>"b"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:l=>{:name=>"tmp"}, :o=>"+ ", :r=>{:name=>"b"}}}, {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}, {:l=>{:name=>"n"}, :o=>"= ", :r=>{:l=>{:name=>"n"}, :o=>"- ", :r=>{:integer=>"1"}}}], :end=>"end"}}], :end=>"end"} + @transform_output = Ast::FunctionExpression.new(:fibonaccit, [Ast::NameExpression.new("n")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(0)),Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::IntegerExpression.new(1)),Ast::WhileExpression.new(Ast::OperatorExpression.new(">", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)), [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::NameExpression.new("b")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::OperatorExpression.new("+", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("b"))), Ast::CallSiteExpression.new("puts", [Ast::NameExpression.new("b")] ), Ast::OperatorExpression.new("=", Ast::NameExpression.new("n"),Ast::OperatorExpression.new("-", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)))] )] ) @parser = @parser.function_definition end end \ No newline at end of file diff --git a/test/parser/test_root.rb b/test/parser/test_root.rb index 332d9747..3f5624bc 100644 --- a/test/parser/test_root.rb +++ b/test/parser/test_root.rb @@ -15,11 +15,11 @@ HERE @parse_output = [{:function_name=>{:name=>"foo"}, :parmeter_list=>[{:parmeter=>{:name=>"x"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"5"}}], :end=>"end"}, - {:function_call=>{:name=>"foo"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}] + {:call_site=>{:name=>"foo"}, :argument_list=>[{:argument=>{:integer=>"3"}}]}] @transform_output = [Ast::FunctionExpression.new(:foo, [Ast::NameExpression.new("x")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(5))] ), - Ast::FuncallExpression.new("foo", [Ast::IntegerExpression.new(3)] )] + Ast::CallSiteExpression.new("foo", [Ast::IntegerExpression.new(3)] )] end @@ -39,8 +39,8 @@ end fibonaccit( 10 ) HERE - @parse_output = [{:function_name=>{:name=>"fibonaccit"}, :parmeter_list=>[{:parmeter=>{:name=>"n"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"0"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:integer=>"1"}}, {:while=>"while", :while_cond=>{:l=>{:name=>"n"}, :o=>"> ", :r=>{:integer=>"1"}}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:l=>{:name=>"a"}, :o=>"= ", :r=>{:name=>"b"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:l=>{:name=>"tmp"}, :o=>"+ ", :r=>{:name=>"b"}}}, {:function_call=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}, {:l=>{:name=>"n"}, :o=>"= ", :r=>{:l=>{:name=>"n"}, :o=>"- ", :r=>{:integer=>"1"}}}], :end=>"end"}}], :end=>"end"}, {:function_call=>{:name=>"fibonaccit"}, :argument_list=>[{:argument=>{:integer=>"10"}}]}] - @transform_output = [Ast::FunctionExpression.new(:fibonaccit, [Ast::NameExpression.new("n")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(0)),Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::IntegerExpression.new(1)),Ast::WhileExpression.new(Ast::OperatorExpression.new(">", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)), [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::NameExpression.new("b")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::OperatorExpression.new("+", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("b"))), Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] ), Ast::OperatorExpression.new("=", Ast::NameExpression.new("n"),Ast::OperatorExpression.new("-", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)))] )] ), Ast::FuncallExpression.new("fibonaccit", [Ast::IntegerExpression.new(10)] )] + @parse_output = [{:function_name=>{:name=>"fibonaccit"}, :parmeter_list=>[{:parmeter=>{:name=>"n"}}], :expressions=>[{:l=>{:name=>"a"}, :o=>"= ", :r=>{:integer=>"0"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:integer=>"1"}}, {:while=>"while", :while_cond=>{:l=>{:name=>"n"}, :o=>"> ", :r=>{:integer=>"1"}}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:l=>{:name=>"a"}, :o=>"= ", :r=>{:name=>"b"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:l=>{:name=>"tmp"}, :o=>"+ ", :r=>{:name=>"b"}}}, {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}, {:l=>{:name=>"n"}, :o=>"= ", :r=>{:l=>{:name=>"n"}, :o=>"- ", :r=>{:integer=>"1"}}}], :end=>"end"}}], :end=>"end"}, {:call_site=>{:name=>"fibonaccit"}, :argument_list=>[{:argument=>{:integer=>"10"}}]}] + @transform_output = [Ast::FunctionExpression.new(:fibonaccit, [Ast::NameExpression.new("n")] , [Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::IntegerExpression.new(0)),Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::IntegerExpression.new(1)),Ast::WhileExpression.new(Ast::OperatorExpression.new(">", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)), [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::NameExpression.new("b")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::OperatorExpression.new("+", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("b"))), Ast::CallSiteExpression.new("puts", [Ast::NameExpression.new("b")] ), Ast::OperatorExpression.new("=", Ast::NameExpression.new("n"),Ast::OperatorExpression.new("-", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)))] )] ), Ast::CallSiteExpression.new("fibonaccit", [Ast::IntegerExpression.new(10)] )] end end diff --git a/test/parser/test_while.rb b/test/parser/test_while.rb index f8b93e90..c2bb7087 100644 --- a/test/parser/test_while.rb +++ b/test/parser/test_while.rb @@ -16,11 +16,11 @@ HERE :while_cond=>{:integer=>"1"}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, - {:function_call=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}} + {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}} @transform_output = Ast::WhileExpression.new( Ast::IntegerExpression.new(1), [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), - Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] )] ) + Ast::CallSiteExpression.new("puts", [Ast::NameExpression.new("b")] )] ) @parser = @parser.while_do end @@ -41,7 +41,7 @@ HERE :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:l=>{:name=>"a"}, :o=>"= ", :r=>{:name=>"b"}}, {:l=>{:name=>"b"}, :o=>"= ", :r=>{:l=>{:name=>"tmp"}, :o=>"+ ", :r=>{:name=>"b"}}}, - {:function_call=>{:name=>"puts"}, + {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}, {:l=>{:name=>"n"}, :o=>"= ", :r=>{:l=>{:name=>"n"}, :o=>"- ", :r=>{:integer=>"1"}}}], :end=>"end"}} @@ -50,7 +50,7 @@ HERE [Ast::OperatorExpression.new("=", Ast::NameExpression.new("tmp"),Ast::NameExpression.new("a")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("a"),Ast::NameExpression.new("b")), Ast::OperatorExpression.new("=", Ast::NameExpression.new("b"),Ast::OperatorExpression.new("+", Ast::NameExpression.new("tmp"), - Ast::NameExpression.new("b"))), Ast::FuncallExpression.new("puts", [Ast::NameExpression.new("b")] ), + Ast::NameExpression.new("b"))), Ast::CallSiteExpression.new("puts", [Ast::NameExpression.new("b")] ), Ast::OperatorExpression.new("=", Ast::NameExpression.new("n"),Ast::OperatorExpression.new("-", Ast::NameExpression.new("n"),Ast::IntegerExpression.new(1)))] ) @parser = @parser.while_do end