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
rule more_args
list:(comma basic_expression )1* {
capture(:basic_expression).value
(comma basic_expression )* {
captures(:basic_expression).collect{|u| u.value }
}
end
rule argument_list
(left_parenthesis basic_expression? more_args? right_parenthesis){
(left_parenthesis basic_expression? more_args right_parenthesis){
args = [ ]
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
}
end

View File

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