public final AntlrPilarParser.actionExtension_return actionExtension()
      throws RecognitionException {
    AntlrPilarParser.actionExtension_return retval = new AntlrPilarParser.actionExtension_return();
    retval.start = input.LT(1);
    int actionExtension_StartIndex = input.index();
    Object root_0 = null;

    Token t = null;
    Token ID177 = null;
    Token char_literal178 = null;
    Token char_literal180 = null;
    Token char_literal182 = null;
    AntlrPilarParser.typeVarTuple_return typeVarTuple176 = null;

    AntlrPilarParser.extParamList_return extParamList179 = null;

    AntlrPilarParser.annotationList_return annotationList181 = null;

    Object t_tree = null;
    Object ID177_tree = null;
    Object char_literal178_tree = null;
    Object char_literal180_tree = null;
    Object char_literal182_tree = null;
    RewriteRuleTokenStream stream_170 = new RewriteRuleTokenStream(adaptor,
        "token 170");
    RewriteRuleTokenStream stream_175 = new RewriteRuleTokenStream(adaptor,
        "token 175");
    RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,
        "token ID");
    RewriteRuleTokenStream stream_169 = new RewriteRuleTokenStream(adaptor,
        "token 169");
    RewriteRuleTokenStream stream_190 = new RewriteRuleTokenStream(adaptor,
        "token 190");
    RewriteRuleSubtreeStream stream_annotationList = new RewriteRuleSubtreeStream(
        adaptor, "rule annotationList");
    RewriteRuleSubtreeStream stream_extParamList = new RewriteRuleSubtreeStream(
        adaptor, "rule extParamList");
    RewriteRuleSubtreeStream stream_typeVarTuple = new RewriteRuleSubtreeStream(
        adaptor, "rule typeVarTuple");
    try {
      if (state.backtracking > 0 && alreadyParsedRule(input, 48)) {
        return retval;
      }
      // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:411:2: (t= 'actiondef' ( typeVarTuple )? ID ( '(' extParamList ')' )? annotationList ';' -> ^( ACTION_EXT[$t] ^( OPTION ( typeVarTuple )? ) ID ^( OPTION ( extParamList )? ) annotationList ) )
      // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:411:4: t= 'actiondef' ( typeVarTuple )? ID ( '(' extParamList ')' )? annotationList ';'
      {
        t = (Token) match(input, 190, FOLLOW_190_in_actionExtension3433);
        if (state.failed) return retval;
        if (state.backtracking == 0) stream_190.add(t);

        // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:411:18: ( typeVarTuple )?
        int alt50 = 2;
        int LA50_0 = input.LA(1);

        if ((LA50_0 == 167)) {
          alt50 = 1;
        }
        switch (alt50) {
          case 1:
          // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:0:0: typeVarTuple
          {
            pushFollow(FOLLOW_typeVarTuple_in_actionExtension3435);
            typeVarTuple176 = typeVarTuple();

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

          }
            break;

        }

        ID177 = (Token) match(input, ID, FOLLOW_ID_in_actionExtension3438);
        if (state.failed) return retval;
        if (state.backtracking == 0) stream_ID.add(ID177);

        // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:412:4: ( '(' extParamList ')' )?
        int alt51 = 2;
        int LA51_0 = input.LA(1);

        if ((LA51_0 == 169)) {
          alt51 = 1;
        }
        switch (alt51) {
          case 1:
          // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:412:6: '(' extParamList ')'
          {
            char_literal178 = (Token) match(
                input,
                169,
                FOLLOW_169_in_actionExtension3445);
            if (state.failed) return retval;
            if (state.backtracking == 0) stream_169.add(char_literal178);

            pushFollow(FOLLOW_extParamList_in_actionExtension3447);
            extParamList179 = extParamList();

            state._fsp--;
            if (state.failed) return retval;
            if (state.backtracking == 0)
              stream_extParamList.add(extParamList179.getTree());
            char_literal180 = (Token) match(
                input,
                170,
                FOLLOW_170_in_actionExtension3449);
            if (state.failed) return retval;
            if (state.backtracking == 0) stream_170.add(char_literal180);

          }
            break;

        }

        pushFollow(FOLLOW_annotationList_in_actionExtension3457);
        annotationList181 = annotationList();

        state._fsp--;
        if (state.failed) return retval;
        if (state.backtracking == 0)
          stream_annotationList.add(annotationList181.getTree());
        char_literal182 = (Token) match(
            input,
            175,
            FOLLOW_175_in_actionExtension3459);
        if (state.failed) return retval;
        if (state.backtracking == 0) stream_175.add(char_literal182);

        // AST REWRITE
        // elements: typeVarTuple, extParamList, ID, annotationList
        // 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();
          // 413:41: -> ^( ACTION_EXT[$t] ^( OPTION ( typeVarTuple )? ) ID ^( OPTION ( extParamList )? ) annotationList )
          {
            // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:413:44: ^( ACTION_EXT[$t] ^( OPTION ( typeVarTuple )? ) ID ^( OPTION ( extParamList )? ) annotationList )
            {
              Object root_1 = (Object) adaptor.nil();
              root_1 = (Object) adaptor.becomeRoot(
                  (Object) adaptor.create(ACTION_EXT, t),
                  root_1);

              // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:413:61: ^( OPTION ( typeVarTuple )? )
              {
                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:413:70: ( typeVarTuple )?
                if (stream_typeVarTuple.hasNext()) {
                  adaptor.addChild(root_2, stream_typeVarTuple.nextTree());

                }
                stream_typeVarTuple.reset();

                adaptor.addChild(root_1, root_2);
              }
              adaptor.addChild(root_1, stream_ID.nextNode());
              // /Users/robby/Repositories/sireum-parser/sireum-parser/src/main/java/org/sireum/pilar/parser/AntlrPilar.g:413:88: ^( OPTION ( extParamList )? )
              {
                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:413:97: ( extParamList )?
                if (stream_extParamList.hasNext()) {
                  adaptor.addChild(root_2, stream_extParamList.nextTree());

                }
                stream_extParamList.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, 48, actionExtension_StartIndex);
      }
    }
    return retval;
  }