src/share/classes/com/sun/tools/javac/parser/JavacParser.java

Print this page




2897             }
2898         }
2899         return annotationValue();
2900     }
2901 
2902     /* AnnotationValue          = ConditionalExpression
2903      *                          | Annotation
2904      *                          | "{" [ AnnotationValue { "," AnnotationValue } ] [","] "}"
2905      */
2906     JCExpression annotationValue() {
2907         int pos;
2908         switch (token.kind) {
2909         case MONKEYS_AT:
2910             pos = token.pos;
2911             nextToken();
2912             return annotation(pos, Tag.ANNOTATION);
2913         case LBRACE:
2914             pos = token.pos;
2915             accept(LBRACE);
2916             ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>();
2917             if (token.kind != RBRACE) {


2918                 buf.append(annotationValue());
2919                 while (token.kind == COMMA) {
2920                     nextToken();
2921                     if (token.kind == RBRACE) break;
2922                     buf.append(annotationValue());
2923                 }
2924             }
2925             accept(RBRACE);
2926             return toP(F.at(pos).NewArray(null, List.<JCExpression>nil(), buf.toList()));
2927         default:
2928             mode = EXPR;
2929             return term1();
2930         }
2931     }
2932 
2933     /** VariableDeclarators = VariableDeclarator { "," VariableDeclarator }
2934      */
2935     public <T extends ListBuffer<? super JCVariableDecl>> T variableDeclarators(JCModifiers mods,
2936                                                                          JCExpression type,
2937                                                                          T vdefs)




2897             }
2898         }
2899         return annotationValue();
2900     }
2901 
2902     /* AnnotationValue          = ConditionalExpression
2903      *                          | Annotation
2904      *                          | "{" [ AnnotationValue { "," AnnotationValue } ] [","] "}"
2905      */
2906     JCExpression annotationValue() {
2907         int pos;
2908         switch (token.kind) {
2909         case MONKEYS_AT:
2910             pos = token.pos;
2911             nextToken();
2912             return annotation(pos, Tag.ANNOTATION);
2913         case LBRACE:
2914             pos = token.pos;
2915             accept(LBRACE);
2916             ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>();
2917             if (token.kind == COMMA) {
2918                 nextToken();
2919             } else if (token.kind != RBRACE) {
2920                 buf.append(annotationValue());
2921                 while (token.kind == COMMA) {
2922                     nextToken();
2923                     if (token.kind == RBRACE) break;
2924                     buf.append(annotationValue());
2925                 }
2926             }
2927             accept(RBRACE);
2928             return toP(F.at(pos).NewArray(null, List.<JCExpression>nil(), buf.toList()));
2929         default:
2930             mode = EXPR;
2931             return term1();
2932         }
2933     }
2934 
2935     /** VariableDeclarators = VariableDeclarator { "," VariableDeclarator }
2936      */
2937     public <T extends ListBuffer<? super JCVariableDecl>> T variableDeclarators(JCModifiers mods,
2938                                                                          JCExpression type,
2939                                                                          T vdefs)