Fix #138. Parser should now support opCall correctly

This commit is contained in:
Hackerpilot 2014-03-04 22:49:20 -08:00
parent f0e8e848ab
commit efdde7c988
2 changed files with 31 additions and 7 deletions

View File

@ -1359,8 +1359,9 @@ final class FunctionCallExpression : ExpressionNode
public: public:
override void accept(ASTVisitor visitor) const override void accept(ASTVisitor visitor) const
{ {
mixin (visitIfNotNull!(unaryExpression, arguments, templateArguments)); mixin (visitIfNotNull!(type, unaryExpression, templateArguments, arguments));
} }
/** */ Type type;
/** */ UnaryExpression unaryExpression; /** */ UnaryExpression unaryExpression;
/** */ TemplateArguments templateArguments; /** */ TemplateArguments templateArguments;
/** */ Arguments arguments; /** */ Arguments arguments;

View File

@ -2559,17 +2559,31 @@ body {} // six
* *
* $(GRAMMAR $(RULEDEF functionCallExpression): * $(GRAMMAR $(RULEDEF functionCallExpression):
* $(RULE unaryExpression) $(RULE templateArguments)? $(RULE arguments) * $(RULE unaryExpression) $(RULE templateArguments)? $(RULE arguments)
* | $(RULE type) $(RULE arguments)
* ;) * ;)
*/ */
FunctionCallExpression parseFunctionCallExpression(UnaryExpression unary = null) FunctionCallExpression parseFunctionCallExpression(UnaryExpression unary = null)
{ {
mixin(traceEnterAndExit!(__FUNCTION__)); mixin(traceEnterAndExit!(__FUNCTION__));
auto node = allocate!FunctionCallExpression; auto node = allocate!FunctionCallExpression;
switch (current.type)
{
case tok!"const":
case tok!"immutable":
case tok!"inout":
case tok!"shared":
case tok!"scope":
case tok!"pure":
case tok!"nothrow":
node.type = parseType();
break;
default:
node.unaryExpression = unary is null ? parseUnaryExpression() : unary; node.unaryExpression = unary is null ? parseUnaryExpression() : unary;
if (currentIs(tok!"!")) if (currentIs(tok!"!"))
node.templateArguments = parseTemplateArguments(); node.templateArguments = parseTemplateArguments();
}
node.arguments = parseArguments(); node.arguments = parseArguments();
return node; return node.arguments is null ? null : node;
} }
/** /**
@ -5855,6 +5869,16 @@ q{(int a, ...)
auto node = allocate!UnaryExpression; auto node = allocate!UnaryExpression;
switch (current.type) switch (current.type)
{ {
case tok!"const":
case tok!"immutable":
case tok!"inout":
case tok!"shared":
case tok!"scope":
case tok!"pure":
case tok!"nothrow":
warn("parsing function call expression");
node.functionCallExpression = parseFunctionCallExpression();
break;
case tok!"&": case tok!"&":
case tok!"!": case tok!"!":
case tok!"*": case tok!"*":
@ -5923,7 +5947,6 @@ q{(int a, ...)
goto case tok!"("; goto case tok!"(";
else else
break loop; break loop;
case tok!"(": case tok!"(":
auto newUnary = allocate!UnaryExpression(); auto newUnary = allocate!UnaryExpression();
newUnary.functionCallExpression = parseFunctionCallExpression(node); newUnary.functionCallExpression = parseFunctionCallExpression(node);