/** * MemberReferenceSuffix = "::" [TypeArguments] Ident * | "::" [TypeArguments] "new" */ JCExpression memberReferenceSuffix(JCExpression t) { int pos1 = token.pos; accept(COLCOL); return memberReferenceSuffix(pos1, t); }
/** * MemberReferenceSuffix = "::" [TypeArguments] Ident * | "::" [TypeArguments] "new" */ JCExpression memberReferenceSuffix(JCExpression t) { int pos1 = token.pos; accept(COLCOL); return memberReferenceSuffix(pos1, t); }
JCExpression lambdaExpressionOrStatementRest(List<JCVariableDecl> args, int pos) { checkLambda(); accept(ARROW); return token.kind == LBRACE ? lambdaStatement(args, pos, pos) : lambdaExpression(args, pos); }
JCExpression lambdaExpressionOrStatementRest(List<JCVariableDecl> args, int pos) { checkLambda(); accept(ARROW); return token.kind == LBRACE ? lambdaStatement(args, pos, pos) : lambdaExpression(args, pos); }
/** Block = "{" BlockStatements "}" */ JCBlock block(int pos, long flags) { accept(LBRACE); List<JCStatement> stats = blockStatements(); JCBlock t = F.at(pos).Block(flags, stats); while (token.kind == CASE || token.kind == DEFAULT) { syntaxError("orphaned", token.kind); switchBlockStatementGroups(); } // the Block node has a field "endpos" for first char of last token, which is // usually but not necessarily the last char of the last token. t.endpos = token.pos; accept(RBRACE); return toP(t); }
/** AnnotationFieldValues = "(" [ AnnotationFieldValue { "," AnnotationFieldValue } ] ")" */ List<JCExpression> annotationFieldValues() { accept(LPAREN); ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>(); if (token.kind != RPAREN) { buf.append(annotationFieldValue()); while (token.kind == COMMA) { nextToken(); buf.append(annotationFieldValue()); } } accept(RPAREN); return buf.toList(); }
/** Block = "{" BlockStatements "}" */ JCBlock block(int pos, long flags) { accept(LBRACE); List<JCStatement> stats = blockStatements(); JCBlock t = F.at(pos).Block(flags, stats); while (token.kind == CASE || token.kind == DEFAULT) { syntaxError("orphaned", token.kind); switchBlockStatementGroups(); } // the Block node has a field "endpos" for first char of last token, which is // usually but not necessarily the last char of the last token. t.endpos = token.pos; accept(RBRACE); return toP(t); }
/** AnnotationFieldValues = "(" [ AnnotationFieldValue { "," AnnotationFieldValue } ] ")" */ List<JCExpression> annotationFieldValues() { accept(LPAREN); ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>(); if (token.kind != RPAREN) { buf.append(annotationFieldValue()); while (token.kind == COMMA) { nextToken(); buf.append(annotationFieldValue()); } } accept(RPAREN); return buf.toList(); }
List<JCVariableDecl> implicitParameters(boolean hasParens) { if (hasParens) { accept(LPAREN); } ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>(); if (token.kind != RPAREN && token.kind != ARROW) { params.append(implicitParameter()); while (token.kind == COMMA) { nextToken(); params.append(implicitParameter()); } } if (hasParens) { accept(RPAREN); } return params.toList(); }
/** CatchClause = CATCH "(" FormalParameter ")" Block * TODO: the "FormalParameter" is not correct, it uses the special "catchTypes" rule below. */ protected JCCatch catchClause() { int pos = token.pos; accept(CATCH); accept(LPAREN); JCModifiers mods = optFinal(Flags.PARAMETER); List<JCExpression> catchTypes = catchTypes(); JCExpression paramType = catchTypes.size() > 1 ? toP(F.at(catchTypes.head.getStartPosition()).TypeUnion(catchTypes)) : catchTypes.head; JCVariableDecl formal = variableDeclaratorId(mods, paramType); accept(RPAREN); JCBlock body = block(); return F.at(pos).Catch(formal, body); }
List<JCVariableDecl> implicitParameters(boolean hasParens) { if (hasParens) { accept(LPAREN); } ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>(); if (token.kind != RPAREN && token.kind != ARROW) { params.append(implicitParameter()); while (token.kind == COMMA) { nextToken(); params.append(implicitParameter()); } } if (hasParens) { accept(RPAREN); } return params.toList(); }
/** CatchClause = CATCH "(" FormalParameter ")" Block * TODO: the "FormalParameter" is not correct, it uses the special "catchTypes" rule below. */ protected JCCatch catchClause() { int pos = token.pos; accept(CATCH); accept(LPAREN); JCModifiers mods = optFinal(Flags.PARAMETER); List<JCExpression> catchTypes = catchTypes(); JCExpression paramType = catchTypes.size() > 1 ? toP(F.at(catchTypes.head.getStartPosition()).TypeUnion(catchTypes)) : catchTypes.head; JCVariableDecl formal = variableDeclaratorId(mods, paramType); accept(RPAREN); JCBlock body = block(); return F.at(pos).Catch(formal, body); }
/** Expression1Rest = ["?" Expression ":" Expression1] */ JCExpression term1Rest(JCExpression t) { if (token.kind == QUES) { int pos = token.pos; nextToken(); JCExpression t1 = term(); accept(COLON); JCExpression t2 = term1(); return F.at(pos).Conditional(t, t1, t2); } else { return t; } }
/** Expression1Rest = ["?" Expression ":" Expression1] */ JCExpression term1Rest(JCExpression t) { if (token.kind == QUES) { int pos = token.pos; nextToken(); JCExpression t1 = term(); accept(COLON); JCExpression t2 = term1(); return F.at(pos).Conditional(t, t1, t2); } else { return t; } }
private JCExpression bracketsOptCont(JCExpression t, int pos, List<JCAnnotation> annotations) { accept(RBRACKET); t = bracketsOpt(t); t = toP(F.at(pos).TypeArray(t)); if (annotations.nonEmpty()) { t = toP(F.at(pos).AnnotatedType(annotations, t)); } return t; }
private JCExpression bracketsOptCont(JCExpression t, int pos, List<JCAnnotation> annotations) { accept(RBRACKET); t = bracketsOpt(t); t = toP(F.at(pos).TypeArray(t)); if (annotations.nonEmpty()) { t = toP(F.at(pos).AnnotatedType(annotations, t)); } return t; }
/** AnnotationFieldValue = AnnotationValue * | Identifier "=" AnnotationValue */ JCExpression annotationFieldValue() { if (LAX_IDENTIFIER.accepts(token.kind)) { mode = EXPR; JCExpression t1 = term1(); if (t1.hasTag(IDENT) && token.kind == EQ) { int pos = token.pos; accept(EQ); JCExpression v = annotationValue(); return toP(F.at(pos).Assign(t1, v)); } else { return t1; } } return annotationValue(); }
/** 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(); }