fix three args for call

This commit is contained in:
Torsten Ruger 2015-09-13 20:13:36 +03:00
parent 40f9ab78e5
commit 11a218449d
2 changed files with 15 additions and 5 deletions

View File

@ -2,16 +2,16 @@ grammar Expression
include Keywords include Keywords
rule more_args rule more_args
list:(comma basic_expression )1* { (comma basic_expression )* {
capture(:basic_expression).value captures(:basic_expression).collect{|u| u.value }
} }
end end
rule argument_list rule argument_list
(left_parenthesis basic_expression? more_args? right_parenthesis){ (left_parenthesis basic_expression? more_args right_parenthesis){
args = [ ] args = [ ]
args << capture(:basic_expression).value if capture(:basic_expression) args << capture(:basic_expression).value if capture(:basic_expression)
args << capture(:more_args).value if capture(:more_args) args += capture(:more_args).value if capture(:more_args)
args args
} }
end end

View File

@ -36,7 +36,7 @@ class TestCallSite < MiniTest::Test
check check
end end
def test_call_site_multi def test_call_site_2
@input = 'self.baz(42, foo)' @input = 'self.baz(42, foo)'
@output = Ast::CallSiteExpression.new :baz, @output = Ast::CallSiteExpression.new :baz,
[Ast::IntegerExpression.new(42), Ast::NameExpression.new("foo") ] , [Ast::IntegerExpression.new(42), Ast::NameExpression.new("foo") ] ,
@ -44,4 +44,14 @@ class TestCallSite < MiniTest::Test
check check
end end
def test_call_site_3
@input = 'self.baz(42, foo , bar)'
@output = Ast::CallSiteExpression.new :baz,
[Ast::IntegerExpression.new(42) ,
Ast::NameExpression.new("foo") ,
Ast::NameExpression.new("bar")] ,
Ast::NameExpression.new(:self)
check
end
end end