コード例 #1
0
  // $ANTLR start "argument"
  // AnnotationParser.g:102:1: argument : ( literal_argument | named_argument | json );
  public final AnnotationParser.argument_return argument() throws RecognitionException {
    AnnotationParser.argument_return retval = new AnnotationParser.argument_return();
    retval.start = input.LT(1);

    AnnotationCommonTree root_0 = null;

    AnnotationParser.literal_argument_return literal_argument13 = null;

    AnnotationParser.named_argument_return named_argument14 = null;

    AnnotationParser.json_return json15 = null;

    try {
      // AnnotationParser.g:103:1: ( literal_argument | named_argument | json )
      int alt5 = 3;
      switch (input.LA(1)) {
        case STRING_LITERAL:
          {
            alt5 = 1;
          }
          break;
        case STRING:
          {
            alt5 = 2;
          }
          break;
        case JSON_START:
          {
            alt5 = 3;
          }
          break;
        default:
          NoViableAltException nvae = new NoViableAltException("", 5, 0, input);

          throw nvae;
      }

      switch (alt5) {
        case 1:
          // AnnotationParser.g:103:3: literal_argument
          {
            root_0 = (AnnotationCommonTree) adaptor.nil();

            pushFollow(FOLLOW_literal_argument_in_argument260);
            literal_argument13 = literal_argument();

            state._fsp--;

            adaptor.addChild(root_0, literal_argument13.getTree());
          }
          break;
        case 2:
          // AnnotationParser.g:103:22: named_argument
          {
            root_0 = (AnnotationCommonTree) adaptor.nil();

            pushFollow(FOLLOW_named_argument_in_argument264);
            named_argument14 = named_argument();

            state._fsp--;

            adaptor.addChild(root_0, named_argument14.getTree());
          }
          break;
        case 3:
          // AnnotationParser.g:103:39: json
          {
            root_0 = (AnnotationCommonTree) adaptor.nil();

            pushFollow(FOLLOW_json_in_argument268);
            json15 = json();

            state._fsp--;

            adaptor.addChild(root_0, json15.getTree());
          }
          break;
      }
      retval.stop = input.LT(-1);

      retval.tree = (AnnotationCommonTree) adaptor.rulePostProcessing(root_0);
      adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (AnnotationCommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);

    } finally {
    }
    return retval;
  }
コード例 #2
0
  // $ANTLR start "arguments"
  // AnnotationParser.g:97:1: arguments : argument ( COMMA arguments )? -> argument ( arguments )? ;
  public final AnnotationParser.arguments_return arguments() throws RecognitionException {
    AnnotationParser.arguments_return retval = new AnnotationParser.arguments_return();
    retval.start = input.LT(1);

    AnnotationCommonTree root_0 = null;

    CommonToken COMMA11 = null;
    AnnotationParser.argument_return argument10 = null;

    AnnotationParser.arguments_return arguments12 = null;

    AnnotationCommonTree COMMA11_tree = null;
    RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor, "token COMMA");
    RewriteRuleSubtreeStream stream_argument =
        new RewriteRuleSubtreeStream(adaptor, "rule argument");
    RewriteRuleSubtreeStream stream_arguments =
        new RewriteRuleSubtreeStream(adaptor, "rule arguments");
    try {
      // AnnotationParser.g:98:3: ( argument ( COMMA arguments )? -> argument ( arguments )? )
      // AnnotationParser.g:98:5: argument ( COMMA arguments )?
      {
        pushFollow(FOLLOW_argument_in_arguments230);
        argument10 = argument();

        state._fsp--;

        stream_argument.add(argument10.getTree());
        // AnnotationParser.g:98:15: ( COMMA arguments )?
        int alt4 = 2;
        int LA4_0 = input.LA(1);

        if ((LA4_0 == COMMA)) {
          alt4 = 1;
        }
        switch (alt4) {
          case 1:
            // AnnotationParser.g:98:16: COMMA arguments
            {
              COMMA11 = (CommonToken) match(input, COMMA, FOLLOW_COMMA_in_arguments234);
              stream_COMMA.add(COMMA11);

              pushFollow(FOLLOW_arguments_in_arguments236);
              arguments12 = arguments();

              state._fsp--;

              stream_arguments.add(arguments12.getTree());
            }
            break;
        }

        // AST REWRITE
        // elements: arguments, argument
        // token labels:
        // rule labels: retval
        // token list labels:
        // rule list labels:
        // wildcard labels:
        retval.tree = root_0;
        RewriteRuleSubtreeStream stream_retval =
            new RewriteRuleSubtreeStream(
                adaptor, "rule retval", retval != null ? retval.tree : null);

        root_0 = (AnnotationCommonTree) adaptor.nil();
        // 99:5: -> argument ( arguments )?
        {
          adaptor.addChild(root_0, stream_argument.nextTree());
          // AnnotationParser.g:99:17: ( arguments )?
          if (stream_arguments.hasNext()) {
            adaptor.addChild(root_0, stream_arguments.nextTree());
          }
          stream_arguments.reset();
        }

        retval.tree = root_0;
      }

      retval.stop = input.LT(-1);

      retval.tree = (AnnotationCommonTree) adaptor.rulePostProcessing(root_0);
      adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (AnnotationCommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);

    } finally {
    }
    return retval;
  }