add a repeat to the root parser rule (need to test the root more)
This commit is contained in:
parent
b266bb84ba
commit
8f2a22d12f
@ -25,6 +25,6 @@ module Parser
|
|||||||
include Conditional
|
include Conditional
|
||||||
include Expression
|
include Expression
|
||||||
|
|
||||||
rule(:root){ function_definition | expression | assignment | function_call }
|
rule(:root){ (function_definition | expression | assignment | function_call).repeat }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,7 @@ class TestFunctionCall < MiniTest::Test
|
|||||||
@parse_output = {:function_call => {:name => 'foo'},
|
@parse_output = {:function_call => {:name => 'foo'},
|
||||||
:argument_list => [{:argument => {:integer => '42'} }] }
|
:argument_list => [{:argument => {:integer => '42'} }] }
|
||||||
@transform_output = Ast::FuncallExpression.new 'foo', [Ast::IntegerExpression.new(42)]
|
@transform_output = Ast::FuncallExpression.new 'foo', [Ast::IntegerExpression.new(42)]
|
||||||
|
@parser = @parser.function_call
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_function_call_multi
|
def test_function_call_multi
|
||||||
|
@ -16,6 +16,7 @@ HERE
|
|||||||
@transform_output = Ast::FunctionExpression.new('foo',
|
@transform_output = Ast::FunctionExpression.new('foo',
|
||||||
[Ast::NameExpression.new('x')],
|
[Ast::NameExpression.new('x')],
|
||||||
[Ast::IntegerExpression.new(5)])
|
[Ast::IntegerExpression.new(5)])
|
||||||
|
@parser = @parser.function_definition
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_function_assignment
|
def test_function_assignment
|
||||||
@ -30,6 +31,7 @@ HERE
|
|||||||
}
|
}
|
||||||
@transform_output = Ast::FunctionExpression.new( "foo", [Ast::NameExpression.new("x")],
|
@transform_output = Ast::FunctionExpression.new( "foo", [Ast::NameExpression.new("x")],
|
||||||
[Ast::AssignmentExpression.new( "abba", Ast::IntegerExpression.new(5) ) ])
|
[Ast::AssignmentExpression.new( "abba", Ast::IntegerExpression.new(5) ) ])
|
||||||
|
@parser = @parser.function_definition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user