diff --git a/lib/parser/crystal.rb b/lib/parser/crystal.rb index 60af3656..fc897067 100644 --- a/lib/parser/crystal.rb +++ b/lib/parser/crystal.rb @@ -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 diff --git a/test/parser/test_function_call.rb b/test/parser/test_function_call.rb index 14949dcc..a84e041b 100644 --- a/test/parser/test_function_call.rb +++ b/test/parser/test_function_call.rb @@ -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 diff --git a/test/parser/test_function_definition.rb b/test/parser/test_function_definition.rb index 1b57af5e..393d8b07 100644 --- a/test/parser/test_function_definition.rb +++ b/test/parser/test_function_definition.rb @@ -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