b.add(parserLine, POP);
break;
}
+ case LP: {
+ int n = parseArgs(b);
+ b.add(parserLine,CALLMETHOD,new Integer(n));
+ break;
+ }
default: {
pushBackToken();
b.add(parserLine, GET);
switch (tok) {
case LP: { // invocation (not grouping)
- int i = 0;
- while(peekToken() != RP) {
- i++;
- if (peekToken() != COMMA) {
- startExpr(b, -1);
- if (peekToken() == RP) break;
- }
- consume(COMMA);
- }
- consume(RP);
- b.add(parserLine, CALL, new Integer(i));
+ int n = parseArgs(b);
+ b.add(parserLine, CALL, new Integer(n));
break;
}
case BITOR: case BITXOR: case BITAND: case SHEQ: case SHNE: case LSH:
continueExpr(b, minPrecedence); // try to continue the expression
}
+ // parse a set of comma separated function arguments, assume LP has already been consumed
+ private int parseArgs(CompiledFunctionImpl b) throws IOException {
+ int i = 0;
+ while(peekToken() != RP) {
+ i++;
+ if (peekToken() != COMMA) {
+ startExpr(b, -1);
+ if (peekToken() == RP) break;
+ }
+ consume(COMMA);
+ }
+ consume(RP);
+ return i;
+ }
+
/** Parse a block of statements which must be surrounded by LC..RC. */
void parseBlock(CompiledFunctionImpl b) throws IOException { parseBlock(b, null); }
void parseBlock(CompiledFunctionImpl b, String label) throws IOException {