public static JCTree.JCExpression parseString(String guardedByString, Context context) { JavacParser parser = ParserFactory.instance(context) .newParser( guardedByString, /* keepDocComments= */ false, /* keepEndPos= */ true, /* keepLineMap= */ false); JCTree.JCExpression exp; try { exp = parser.parseExpression(); } catch (Throwable e) { throw new IllegalGuardedBy(e.getMessage()); } int len = (parser.getEndPos(exp) - exp.getStartPosition()); if (len != guardedByString.length()) { throw new IllegalGuardedBy("Didn't parse entire string."); } return exp; }
/** VariableInitializer = ArrayInitializer | Expression */ public JCExpression variableInitializer() { return token.kind == LBRACE ? arrayInitializer(token.pos, null) : parseExpression(); }
/** VariableInitializer = ArrayInitializer | Expression */ public JCExpression variableInitializer() { return token.kind == LBRACE ? arrayInitializer(token.pos, null) : parseExpression(); }
/** ForUpdate = StatementExpression MoreStatementExpressions */ List<JCExpressionStatement> forUpdate() { return moreStatementExpressions(token.pos, parseExpression(), new ListBuffer<JCExpressionStatement>()).toList(); }
/** ForUpdate = StatementExpression MoreStatementExpressions */ List<JCExpressionStatement> forUpdate() { return moreStatementExpressions(token.pos, parseExpression(), new ListBuffer<JCExpressionStatement>()).toList(); }
JCExpression lambdaExpression(List<JCVariableDecl> args, int pos) { JCTree expr = parseExpression(); return toP(F.at(pos).Lambda(args, expr)); }
JCExpression lambdaExpression(List<JCVariableDecl> args, int pos) { JCTree expr = parseExpression(); return toP(F.at(pos).Lambda(args, expr)); }
public static JCTree.JCExpression parseString(String guardedByString, Context context) { JavacParser parser = ParserFactory.instance(context) .newParser( guardedByString, /* keepDocComments= */ false, /* keepEndPos= */ true, /* keepLineMap= */ false); JCTree.JCExpression exp; try { exp = parser.parseExpression(); } catch (Throwable e) { throw new IllegalGuardedBy(e.getMessage()); } int len = (parser.getEndPos(exp) - exp.getStartPosition()); if (len != guardedByString.length()) { throw new IllegalGuardedBy("Didn't parse entire string."); } return exp; }
/** ParExpression = "(" Expression ")" */ JCExpression parExpression() { int pos = token.pos; accept(LPAREN); JCExpression t = parseExpression(); accept(RPAREN); return toP(F.at(pos).Parens(t)); }
/** ParExpression = "(" Expression ")" */ JCExpression parExpression() { int pos = token.pos; accept(LPAREN); JCExpression t = parseExpression(); accept(RPAREN); return toP(F.at(pos).Parens(t)); }
/** Arguments = "(" [Expression { COMMA Expression }] ")" */ List<JCExpression> arguments() { ListBuffer<JCExpression> args = new ListBuffer<>(); if (token.kind == LPAREN) { nextToken(); if (token.kind != RPAREN) { args.append(parseExpression()); while (token.kind == COMMA) { nextToken(); args.append(parseExpression()); } } accept(RPAREN); } else { syntaxError(token.pos, "expected", LPAREN); } return args.toList(); }
/** Arguments = "(" [Expression { COMMA Expression }] ")" */ List<JCExpression> arguments() { ListBuffer<JCExpression> args = new ListBuffer<>(); if (token.kind == LPAREN) { nextToken(); if (token.kind != RPAREN) { args.append(parseExpression()); while (token.kind == COMMA) { nextToken(); args.append(parseExpression()); } } accept(RPAREN); } else { syntaxError(token.pos, "expected", LPAREN); } return args.toList(); }
/** MoreStatementExpressions = { COMMA StatementExpression } */ <T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos, JCExpression first, T stats) { // This Exec is a "StatementExpression"; it subsumes no terminating token stats.append(toP(F.at(pos).Exec(checkExprStat(first)))); while (token.kind == COMMA) { nextToken(); pos = token.pos; JCExpression t = parseExpression(); // This Exec is a "StatementExpression"; it subsumes no terminating token stats.append(toP(F.at(pos).Exec(checkExprStat(t)))); } return stats; }
/** MoreStatementExpressions = { COMMA StatementExpression } */ <T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos, JCExpression first, T stats) { // This Exec is a "StatementExpression"; it subsumes no terminating token stats.append(toP(F.at(pos).Exec(checkExprStat(first)))); while (token.kind == COMMA) { nextToken(); pos = token.pos; JCExpression t = parseExpression(); // This Exec is a "StatementExpression"; it subsumes no terminating token stats.append(toP(F.at(pos).Exec(checkExprStat(t)))); } return stats; }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }
protected JCCase switchBlockStatementGroup() { int pos = token.pos; List<JCStatement> stats; JCCase c; switch (token.kind) { case CASE: nextToken(); JCExpression pat = parseExpression(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(pat, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; case DEFAULT: nextToken(); accept(COLON); stats = blockStatements(); c = F.at(pos).Case(null, stats); if (stats.isEmpty()) storeEnd(c, S.prevToken().endPos); return c; } throw new AssertionError("should not reach here"); }
dimAnnotations.append(annos); dims.append(parseExpression()); accept(RBRACKET); while (token.kind == LBRACKET } else { dimAnnotations.append(maybeDimAnnos); dims.append(parseExpression()); accept(RBRACKET);
dimAnnotations.append(annos); dims.append(parseExpression()); accept(RBRACKET); while (token.kind == LBRACKET } else { dimAnnotations.append(maybeDimAnnos); dims.append(parseExpression()); accept(RBRACKET);
JCVariableDecl var = (JCVariableDecl)inits.head; accept(COLON); JCExpression expr = parseExpression(); accept(RPAREN); JCStatement body = parseStatementAsBlock(); } else { accept(SEMI); JCExpression cond = token.kind == SEMI ? null : parseExpression(); accept(SEMI); List<JCExpressionStatement> steps = token.kind == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate(); JCExpression result = token.kind == SEMI ? null : parseExpression(); JCReturn t = to(F.at(pos).Return(result)); accept(SEMI); JCExpression exc = parseExpression(); JCThrow t = to(F.at(pos).Throw(exc)); accept(SEMI); if (allowAsserts && token.kind == ASSERT) { nextToken(); JCExpression assertion = parseExpression(); JCExpression message = null; if (token.kind == COLON) { nextToken(); message = parseExpression(); default:
JCVariableDecl var = (JCVariableDecl)inits.head; accept(COLON); JCExpression expr = parseExpression(); accept(RPAREN); JCStatement body = parseStatementAsBlock(); } else { accept(SEMI); JCExpression cond = token.kind == SEMI ? null : parseExpression(); accept(SEMI); List<JCExpressionStatement> steps = token.kind == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate(); JCExpression result = token.kind == SEMI ? null : parseExpression(); JCReturn t = to(F.at(pos).Return(result)); accept(SEMI); JCExpression exc = parseExpression(); JCThrow t = to(F.at(pos).Throw(exc)); accept(SEMI); if (allowAsserts && token.kind == ASSERT) { nextToken(); JCExpression assertion = parseExpression(); JCExpression message = null; if (token.kind == COLON) { nextToken(); message = parseExpression(); default: