public final AntlrPilarParser.extendClauseElement_return extendClauseElement()
      throws RecognitionException {
    AntlrPilarParser.extendClauseElement_return retval = new AntlrPilarParser.extendClauseElement_return();
    retval.start = input.LT(1);
    int extendClauseElement_StartIndex = input.index();
    Object root_0 = null;

    AntlrPilarParser.name_return name95 = null;

    AntlrPilarParser.typeTuple_return typeTuple96 = null;

    AntlrPilarParser.annotationList_return annotationList97 = null;

    RewriteRuleSubtreeStream stream_typeTuple = new RewriteRuleSubtreeStream(
        adaptor, "rule typeTuple");
    RewriteRuleSubtreeStream stream_name = new RewriteRuleSubtreeStream(
        adaptor, "rule name");
    RewriteRuleSubtreeStream stream_annotationList = new RewriteRuleSubtreeStream(
        adaptor, "rule annotationList");
    try {
      if (state.backtracking > 0 && alreadyParsedRule(input, 29)) {
        return retval;
      }
      // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:2: ( name ( typeTuple )? annotationList -> ^( EXTENDCLAUSE_ELEMENT name ^( OPTION ( typeTuple )? ) annotationList ) )
      // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:4: name ( typeTuple )? annotationList
      {
        pushFollow(FOLLOW_name_in_extendClauseElement2338);
        name95 = name();

        state._fsp--;
        if (state.failed) return retval;
        if (state.backtracking == 0) stream_name.add(name95.getTree());
        // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:9: ( typeTuple )?
        int alt24 = 2;
        int LA24_0 = input.LA(1);

        if ((LA24_0 == 167)) {
          alt24 = 1;
        }
        switch (alt24) {
          case 1:
          // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:0:0: typeTuple
          {
            pushFollow(FOLLOW_typeTuple_in_extendClauseElement2340);
            typeTuple96 = typeTuple();

            state._fsp--;
            if (state.failed) return retval;
            if (state.backtracking == 0)
              stream_typeTuple.add(typeTuple96.getTree());

          }
            break;

        }

        pushFollow(FOLLOW_annotationList_in_extendClauseElement2343);
        annotationList97 = annotationList();

        state._fsp--;
        if (state.failed) return retval;
        if (state.backtracking == 0)
          stream_annotationList.add(annotationList97.getTree());

        // AST REWRITE
        // elements: name, annotationList, typeTuple
        // token labels: 
        // rule labels: retval
        // token list labels: 
        // rule list labels: 
        // wildcard labels: 
        if (state.backtracking == 0) {
          retval.tree = root_0;
          RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(
              adaptor, "rule retval", retval != null ? retval.tree : null);

          root_0 = (Object) adaptor.nil();
          // 306:41: -> ^( EXTENDCLAUSE_ELEMENT name ^( OPTION ( typeTuple )? ) annotationList )
          {
            // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:44: ^( EXTENDCLAUSE_ELEMENT name ^( OPTION ( typeTuple )? ) annotationList )
            {
              Object root_1 = (Object) adaptor.nil();
              root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(
                  EXTENDCLAUSE_ELEMENT,
                  "EXTENDCLAUSE_ELEMENT"), root_1);

              adaptor.addChild(root_1, stream_name.nextTree());
              // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:72: ^( OPTION ( typeTuple )? )
              {
                Object root_2 = (Object) adaptor.nil();
                root_2 = (Object) adaptor.becomeRoot(
                    (Object) adaptor.create(OPTION, "OPTION"),
                    root_2);

                // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:306:81: ( typeTuple )?
                if (stream_typeTuple.hasNext()) {
                  adaptor.addChild(root_2, stream_typeTuple.nextTree());

                }
                stream_typeTuple.reset();

                adaptor.addChild(root_1, root_2);
              }
              adaptor.addChild(root_1, stream_annotationList.nextTree());

              adaptor.addChild(root_0, root_1);
            }

          }

          retval.tree = root_0;
        }
      }

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

      if (state.backtracking == 0) {

        retval.tree = (Object) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
      }
    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
      retval.tree = (Object) adaptor.errorNode(
          input,
          retval.start,
          input.LT(-1),
          re);

    } finally {
      if (state.backtracking > 0) {
        memoize(input, 29, extendClauseElement_StartIndex);
      }
    }
    return retval;
  }