//
// File: CegoAdm.h
// This code was produced by the dragon parser generator
//
#include <lfcbase/Exception.h>
#include <lfcbase/Chain.h>
#include <lfcbase/ListT.h>
#define MAXTOKENVAL 100

class CegoAdm
{

public:

   CegoAdm();
   virtual ~CegoAdm();

   void parse();
   ListT<Chain>& getTokenList() { return _tokenList; }

protected:

   virtual char nextChar() = 0;
   virtual void backChar() = 0;
   virtual void statementAction() = 0;
   virtual void poolInfoAction() = 0;
   virtual void parameterInfoAction() = 0;
   virtual void tableSetInfoAction() = 0;
   virtual void poolEntryListAction() = 0;
   virtual void rawModeOn() = 0;
   virtual void rawModeOff() = 0;
   virtual void lockInfoAction() = 0;
   virtual void listTableSetAction() = 0;
   virtual void dataFileInfoAction() = 0;
   virtual void archLogInfoAction() = 0;
   virtual void logInfoAction() = 0;
   virtual void objInfoAction() = 0;
   virtual void buFileInfoAction() = 0;
   virtual void buStatInfoAction() = 0;
   virtual void buStatResetAction() = 0;
   virtual void threadInfoAction() = 0;
   virtual void lockStatAction() = 0;
   virtual void verifyLocksAction() = 0;
   virtual void dbThreadInfoAction() = 0;
   virtual void dbThreadQueryHistAction() = 0;
   virtual void dbQueryHistLastAction() = 0;
   virtual void dbQueryHistCostAction() = 0;
   virtual void admThreadInfoAction() = 0;
   virtual void transactionInfoAction() = 0;
   virtual void abortDbThreadAction() = 0;
   virtual void defineTableSetAction() = 0;
   virtual void createTableSetAction() = 0;
   virtual void startTableSetAction() = 0;
   virtual void stopTableSetAction() = 0;
   virtual void startRecoveryAction() = 0;
   virtual void stopRecoveryAction() = 0;
   virtual void dropTableSetAction() = 0;
   virtual void removeTableSetAction() = 0;
   virtual void addDataFileAction() = 0;
   virtual void verifyTableSetAction() = 0;
   virtual void correctTableSetAction() = 0;
   virtual void addUserAction() = 0;
   virtual void listUserAction() = 0;
   virtual void removeUserAction() = 0;
   virtual void changePwdAction() = 0;
   virtual void assignRoleAction() = 0;
   virtual void removeRoleAction() = 0;
   virtual void listRoleAction() = 0;
   virtual void showRoleAction() = 0;
   virtual void createRoleAction() = 0;
   virtual void dropRoleAction() = 0;
   virtual void setPermAction() = 0;
   virtual void setTableSetPerm() = 0;
   virtual void setFilterPerm() = 0;
   virtual void setRightPerm() = 0;
   virtual void removePermAction() = 0;
   virtual void traceOnAction() = 0;
   virtual void traceOffAction() = 0;
   virtual void enableArchLogAction() = 0;
   virtual void disableArchLogAction() = 0;
   virtual void addArchLogAction() = 0;
   virtual void removeArchLogAction() = 0;
   virtual void beginBackupAction() = 0;
   virtual void executeBackupAction() = 0;
   virtual void endBackupAction() = 0;
   virtual void listBackupAction() = 0;
   virtual void syncTableSetAction() = 0;
   virtual void restoreTableSetAction() = 0;
   virtual void recoverTableSetAction() = 0;
   virtual void setLogMngAction() = 0;
   virtual void setBackupMngAction() = 0;
   virtual void showLogMngAction() = 0;
   virtual void showBackupMngAction() = 0;
   virtual void setTSInitFileAction() = 0;
   virtual void setCheckpointAction() = 0;
   virtual void setTSSysSizeAction() = 0;
   virtual void setTSTmpSizeAction() = 0;
   virtual void setTSAppSizeAction() = 0;
   virtual void setTSRootPathAction() = 0;
   virtual void setTSLogNumAction() = 0;
   virtual void setTSLogSizeAction() = 0;
   virtual void setTSSortAreaSizeAction() = 0;
   virtual void setNumQueryLastAction() = 0;
   virtual void setNumQueryCostAction() = 0;
   virtual void enableAppendModeAction() = 0;
   virtual void disableAppendModeAction() = 0;
   virtual void setAutoCorrectAction() = 0;
   virtual void setAutoCorrectDirect() = 0;
   virtual void setAutoCorrectPost() = 0;
   virtual void setAutoCorrectOff() = 0;
   virtual void enableTableCacheAction() = 0;
   virtual void disableTableCacheAction() = 0;
   virtual void listTableCacheAction() = 0;
   virtual void showTableCacheAction() = 0;
   virtual void cleanTableCacheAction() = 0;
   virtual void setTableCacheParamAction() = 0;
   virtual void setTableCacheFilter() = 0;
   virtual void setTableCacheMaxSize() = 0;
   virtual void setTableCacheMaxEntry() = 0;
   virtual void setTableCacheHashRange() = 0;
   virtual void enableQueryCacheAction() = 0;
   virtual void disableQueryCacheAction() = 0;
   virtual void listQueryCacheAction() = 0;
   virtual void showQueryCacheAction() = 0;
   virtual void cleanQueryCacheAction() = 0;
   virtual void setQueryCacheParamAction() = 0;
   virtual void setQueryCacheMaxEntry() = 0;
   virtual void setQueryCacheMaxSize() = 0;
   virtual void setQueryCacheHashRange() = 0;
   virtual void setQueryCacheThreshold() = 0;
   virtual void exportTableAction() = 0;
   virtual void exportTableSetAction() = 0;
   virtual void exportTableSetStructureAction() = 0;
   virtual void importTableAction() = 0;
   virtual void importTableSetAction() = 0;
   virtual void importTableSetStructureAction() = 0;
   virtual void keepTicketAction() = 0;
   virtual void syncCmdAction() = 0;
   virtual void timeoutAction() = 0;
   virtual void msgAction() = 0;
   virtual void cleanupAction() = 0;
   virtual void forceloadAction() = 0;
   virtual void cpDumpAction() = 0;
   virtual void noInitAction() = 0;
   virtual void xmlModeAction() = 0;
   virtual void binModeAction() = 0;
   virtual void plainModeAction() = 0;
   virtual void storeSysSizeAttr() = 0;
   virtual void storeTmpSizeAttr() = 0;
   virtual void storeLogSizeAttr() = 0;
   virtual void storeLogNumAttr() = 0;
   virtual void storeAppSizeAttr() = 0;
   virtual void storeSortAreaAttr() = 0;
   virtual void storeTSRootAttr() = 0;
   virtual void storeBranchAttr() = 0;
   virtual void storePit() = 0;
   virtual void storeLsn() = 0;

   enum Token {
      IDENTIFIER,
      INTVAL,
      EQU,
      SEMICOLON,
      KSEP,
      XML,
      WITH,
      VERIFY,
      USER,
      TSROOT,
      TRANSACTION,
      TRACE,
      TO,
      TMPSIZE,
      THRESHOLD,
      THREADINFO,
      THREAD,
      TIMEOUT,
      TABLESET,
      TABLECACHE,
      TABLE,
      SYSSIZE,
      SYNC,
      SWITCH,
      STOP_TOK,
      START_TOK,
      SHOW,
      STRUCTURE,
      SORTAREASIZE,
      SIZE,
      SET,
      SESSION,
      ROLE,
      RIGHT,
      RESTORE,
      RESET,
      RECOVERY,
      RECOVER,
      REMOVE,
      RELOCATE,
      RAWMODE,
      QUIT,
      QUERYHIST,
      QUERYCACHE,
      POST,
      POOL,
      PLAIN,
      PIT,
      PERMISSION,
      PASSWD,
      PATH,
      PARAMETER,
      ON,
      OFF,
      OBJECT,
      NOINIT,
      NODE,
      MESSAGE,
      MEDIATOR,
      MAXSIZE,
      UINDEX,
      IDENTIFIED,
      LOGSIZE,
      LOGNUM,
      LOGMNG,
      LOGFILE,
      LOG,
      LOCKSTAT,
      LOCKS,
      LOCK,
      LSN,
      LIST,
      LAST,
      KEEP,
      INITFILE,
      IMPORT,
      HASHRANGE,
      GETDBINFO,
      GETNODELIST,
      GETTSLIST,
      GETDBSPEC,
      FROM,
      FORCELOAD,
      FOR,
      FILTER,
      FILE,
      EXPORT,
      MAXENTRY,
      END_TOKEN,
      ENABLE,
      DROP,
      DISABLE,
      DIRECT,
      DEFINE,
      DB,
      DATAFILE,
      CREATE,
      CPDUMP,
      COST,
      CORRECT,
      CONNECT,
      CLOSE,
      CLEANUP,
      CLEAN,
      CHECKPOINT,
      BY,
      TSTICKET,
      BUSTAT,
      BUFILE,
      BRANCHID,
      BINARY,
      BEGIN_TOKEN,
      BACKUPMNG,
      BACKUP,
      AUTOCORRECT,
      ASSIGN,
      ARCHLOG,
      APPSIZE,
      APPENDMODE,
      ADM,
      ADD,
      ABORT,
      STRINGVAL,
      ENDTOKEN
   };
   void setReserved(Token t);

private:

   enum Symbol { PROD, TOKEN, NONE };
   enum ScannerStateType { START, INTERMEDIATE, FINAL, ANY };
   enum Action { SHIFT, REDUCE, ACCEPT, NULLACTION };
   enum Production {
      Start,
      PermList,
      PermEntry,
      AutoCorrectMode,
      TableCacheParamList,
      TableCacheParam,
      QueryCacheParamList,
      QueryCacheParam,
      Statement,
      KeepTicketOpt,
      SyncCmdOption,
      TimeoutOpt,
      MsgOption,
      StartOptList,
      StartOpt,
      XPMode,
      AttrList,
      Attr,
      ListBuOption,
      RecoverPitOption
   };
   void loadScanner();
   void loadParser0();
   void loadParser1();
   void loadParser2();
   void loadParser3();
   void loadParser4();
   void loadParser5();
   void loadParser6();
   void loadParser7();
   void loadParser8();
   void loadParser9();
   void loadParser10();
   void loadParser11();
   void loadParser12();
   void loadParser13();
   void loadParser14();
   void loadParser15();

   class ScannerStateEntry {

   public:

      ScannerStateEntry();
      ScannerStateEntry(unsigned state, ScannerStateType type = INTERMEDIATE);
      ScannerStateEntry& operator = (const ScannerStateEntry& s);
      bool operator == (const ScannerStateEntry& s);

	   unsigned getState();
      ScannerStateType getType();

   private:

      unsigned _state;
      ScannerStateType _type;
   };

class ScannerTransEntry {

   public:

      ScannerTransEntry();
      ScannerTransEntry(unsigned state, char c);
      ScannerTransEntry(unsigned state, char c, unsigned fstate);
      ScannerTransEntry& operator = (const ScannerTransEntry& s);
      bool operator == (const ScannerTransEntry& s);

      unsigned getFState();

   private:

      unsigned  _state;
      char _c;
      unsigned _fstate;
   };

   class Scanner {

   public:

      Scanner();
      Scanner(Token t);

      Token getToken();
      void addState(ScannerStateEntry s);
      void addTransition(ScannerTransEntry t);
      bool checkPattern(const Chain& pattern);

   private:

      Token _token;
      ListT<ScannerStateEntry> _stateList;
      ListT<ScannerTransEntry> _transList;
   };

   ListT<Scanner> _scannerList;
   class StackEntry {

   public:

      StackEntry();
      StackEntry(Symbol prod, unsigned num, unsigned state, Chain tval = "");
      StackEntry& operator = (const StackEntry& a);

      unsigned getState();
      Symbol getSymbol();
      Chain& getTval();

   private:

      Symbol _symbol;
      unsigned _num;
      unsigned _state;
      Chain _tval;
   };

   class ActionEntry {

   public:

      ActionEntry();
      ActionEntry(Action action, unsigned num);
      bool operator == (const ActionEntry& a);
      ActionEntry& operator = (const ActionEntry& a);

      Action getAction();
      unsigned getNum();

   private:

      Action _action;
      unsigned _num;
   };

   ActionEntry _actionMap[417][124];
   unsigned _jumpMap[417][21];

   class ProdEntry {

   public:

      ProdEntry();
      ProdEntry(unsigned id);
      ProdEntry(unsigned id, Production prod, unsigned numSymbol);
      bool operator == (const ProdEntry& a);
      ProdEntry& operator = (const ProdEntry& a);

      unsigned getId();
      Production getProd();
      unsigned getNumSymbol();

   private:

      unsigned _id;
      Production _prod;
      unsigned _numSymbol;

   };

   ListT<ProdEntry> _prodInfo;

   bool isSepIgnore(char c);
   bool isSepSign(char c);
   bool shiftToken();

   bool getAction(unsigned state, Token token, Action& a, unsigned& num);
   bool getJump(unsigned state, Production prod, unsigned& fstate);

   Token _reservedToken;
   bool _isReserved;
   Token _token;
   char _tokenVal[MAXTOKENVAL];
   ListT<Chain> _tokenList;

};
