if (null == first) {
if (null == match(Token.Kind.RPAREN)) {
addError("Expected ')' or identifier in function argument list", tokens.get(i - 1));
throw new LoopCompileException();
}
return new ArgDeclList().sourceLocation(lparenTokens);
}
List<Token> optionalType = match(Token.Kind.ASSIGN, Token.Kind.TYPE_IDENT);
ArgDeclList arguments = new ArgDeclList().sourceLocation(lparenTokens);
String firstTypeName = optionalType == null ? null : optionalType.get(1).value;
arguments.add(new ArgDeclList.Argument(first.get(0).value, firstTypeName));
while (match(Token.Kind.COMMA) != null) {
List<Token> nextArg = match(Token.Kind.IDENT);
if (null == nextArg) {
addError("Expected identifier after ',' in function arguments", tokens.get(i - 1));
throw new LoopCompileException();
}
optionalType = match(Token.Kind.ASSIGN, Token.Kind.TYPE_IDENT);
firstTypeName = optionalType == null ? null : optionalType.get(1).value;
arguments.add(new ArgDeclList.Argument(nextArg.get(0).value, firstTypeName));
}
if (match(Token.Kind.RPAREN) == null) {
addError("Expected ')' at end of function arguments", tokens.get(i - 1));
throw new LoopCompileException();