fix and test function transform without braces
This commit is contained in:
parent
9a1dd3ba1d
commit
edd77bc218
@ -57,6 +57,11 @@ module Parser
|
||||
Ast::FunctionExpression.new(function_name.name, parameter_list, expressions)
|
||||
end
|
||||
|
||||
rule(:function_name => simple(:function_name),
|
||||
:expressions => sequence(:expressions) , :end => simple(:e)) do
|
||||
Ast::FunctionExpression.new(function_name.name, [], expressions)
|
||||
end
|
||||
|
||||
rule(:receiver=> simple(:receiver),
|
||||
:function_name => simple(:function_name),
|
||||
:parameter_list => sequence(:parameter_list),
|
||||
|
@ -15,6 +15,17 @@ HERE
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def test_function_no_braces
|
||||
@string_input = <<HERE
|
||||
def foo
|
||||
5
|
||||
end
|
||||
HERE
|
||||
@parse_output = {:expression_list=>[{:function_name=>{:name=>"foo"}, :expressions=>[{:integer=>"5"}], :end=>"end"}]}
|
||||
@transform_output = Ast::ExpressionList.new( [Ast::FunctionExpression.new(:foo, [] , [Ast::IntegerExpression.new(5)] ,nil )])
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def test_class_function
|
||||
@string_input = <<HERE
|
||||
def String.length(x)
|
||||
|
Loading…
Reference in New Issue
Block a user