add a repeat to the root parser rule (need to test the root more)

This commit is contained in:
Torsten Ruger 2014-05-10 11:18:39 +03:00
parent b266bb84ba
commit 8f2a22d12f
3 changed files with 4 additions and 1 deletions

View File

@ -25,6 +25,6 @@ module Parser
include Conditional
include Expression
rule(:root){ function_definition | expression | assignment | function_call }
rule(:root){ (function_definition | expression | assignment | function_call).repeat }
end
end

View File

@ -9,6 +9,7 @@ class TestFunctionCall < MiniTest::Test
@parse_output = {:function_call => {:name => 'foo'},
:argument_list => [{:argument => {:integer => '42'} }] }
@transform_output = Ast::FuncallExpression.new 'foo', [Ast::IntegerExpression.new(42)]
@parser = @parser.function_call
end
def test_function_call_multi

View File

@ -16,6 +16,7 @@ HERE
@transform_output = Ast::FunctionExpression.new('foo',
[Ast::NameExpression.new('x')],
[Ast::IntegerExpression.new(5)])
@parser = @parser.function_definition
end
def test_function_assignment
@ -30,6 +31,7 @@ HERE
}
@transform_output = Ast::FunctionExpression.new( "foo", [Ast::NameExpression.new("x")],
[Ast::AssignmentExpression.new( "abba", Ast::IntegerExpression.new(5) ) ])
@parser = @parser.function_definition
end