private CallExpression FinishCallExpr(Expression target, params Arg[] args) {
bool hasArgsTuple = false;
bool hasKeywordDict = false;
int keywordCount = 0;
int extraArgs = 0;
foreach (Arg arg in args) {
if (arg.Name == null) {
if (hasArgsTuple || hasKeywordDict || keywordCount > 0) {
ReportSyntaxError(IronPython.Resources.NonKeywordAfterKeywordArg);
}
} else if (arg.Name == "*") {
if (hasArgsTuple || hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.OneListArgOnly);
}
hasArgsTuple = true; extraArgs++;
} else if (arg.Name == "**") {
if (hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.OneKeywordArgOnly);
}
hasKeywordDict = true; extraArgs++;
} else {
if (hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.KeywordOutOfSequence);
}
keywordCount++;
}
}
return new CallExpression(target, args);
}