//
// 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 listNodeAction() = 0;
   virtual void dbSessionInfoAction() = 0;
   virtual void buFileInfoAction() = 0;
   virtual void buStatInfoAction() = 0;
   virtual void buStatResetAction() = 0;
   virtual void threadInfoAction() = 0;
   virtual void lockStatAction() = 0;
   virtual void dbThreadInfoAction() = 0;
   virtual void dbThreadLastQueryAction() = 0;
   virtual void admThreadInfoAction() = 0;
   virtual void logThreadInfoAction() = 0;
   virtual void copyInfoAction() = 0;
   virtual void transactionInfoAction() = 0;
   virtual void abortDbThreadAction() = 0;
   virtual void retrieveTableSetAction() = 0;
   virtual void defineTableSetAction() = 0;
   virtual void createTableSetAction() = 0;
   virtual void startTableSetAction() = 0;
   virtual void stopTableSetAction() = 0;
   virtual void copyTableSetAction() = 0;
   virtual void switchTableSetAction() = 0;
   virtual void switchSecondaryAction() = 0;
   virtual void switchMediatorAction() = 0;
   virtual void relocateSecondaryAction() = 0;
   virtual void relocateMediatorAction() = 0;
   virtual void dropTableSetAction() = 0;
   virtual void removeTableSetAction() = 0;
   virtual void resetTableSetAction() = 0;
   virtual void addDataFileAction() = 0;
   virtual void checkTableSetAction() = 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 setTSLogUserAction() = 0;
   virtual void enableAutoCorrectAction() = 0;
   virtual void disableAutoCorrectAction() = 0;
   virtual void enableTableCacheAction() = 0;
   virtual void disableTableCacheAction() = 0;
   virtual void enableQueryCacheAction() = 0;
   virtual void disableQueryCacheAction() = 0;
   virtual void listQueryCacheAction() = 0;
   virtual void cleanQueryCacheAction() = 0;
   virtual void setQueryCacheEntryAction() = 0;
   virtual void setQueryCacheSizeAction() = 0;
   virtual void listTableCacheAction() = 0;
   virtual void cleanTableCacheAction() = 0;
   virtual void setTableCacheEntryAction() = 0;
   virtual void setTableCacheSizeAction() = 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 xmlModeAction() = 0;
   virtual void binModeAction() = 0;
   virtual void plainModeAction() = 0;
   virtual void storePrimaryAttr() = 0;
   virtual void storeSecondaryAttr() = 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 storePit() = 0;
   virtual void getDbSpecAction() = 0;
   virtual void getDbInfoAction() = 0;
   virtual void setTableSetNodeAction() = 0;
   virtual void copyFileAction() = 0;
   virtual void dumpTable() = 0;
   virtual void dumpUIndex() = 0;

   enum Token {
      IDENTIFIER,
      INTVAL,
      EQU,
      SEMICOLON,
      KSEP,
      XML,
      WITH,
      VERIFY,
      USER,
      TSROOT,
      TRANSACTION,
      TRACE,
      TO,
      TMPSIZE,
      THREADINFO,
      THREAD,
      TIMEOUT,
      TABLESET,
      TABLECACHE,
      TABLE,
      SYSSIZE,
      SYNC,
      SWITCH,
      STOP_TOK,
      START_TOK,
      SHOW,
      STRUCTURE,
      SORTAREASIZE,
      SIZE,
      SETTSNODEINFO,
      SET,
      SESSION,
      SECONDARY,
      ROLE,
      RIGHT,
      RETRIEVE,
      RESTORE,
      RESET,
      RECOVER,
      REMOVE,
      RELOCATE,
      RAWMODE,
      QUIT,
      QUERYCACHE,
      PRIMARY,
      POOL,
      PLAIN,
      PERMISSION,
      PASSWD,
      PATH,
      PARAMETER,
      ON,
      OFF,
      OBJECT,
      NODE,
      MESSAGE,
      MEDIATOR,
      UINDEX,
      IDENTIFIED,
      LOGUSER,
      LOGSIZE,
      LOGNUM,
      LOGMNG,
      LOGFILE,
      LOG,
      LOCKSTAT,
      LOCK,
      LIST,
      KEEP,
      INITFILE,
      IMPORT,
      GETDBINFO,
      GETNODELIST,
      GETTSLIST,
      GETDBSPEC,
      FROM,
      FORCELOAD,
      FOR,
      FILTER,
      FILE,
      EXPORT,
      ENTRY,
      END_TOKEN,
      ENABLE,
      DUMP,
      DROP,
      DISABLE,
      DEFINE,
      DB,
      DATAFILE,
      CREATE,
      CPDUMP,
      CORRECT,
      COPY,
      CONNECT,
      CLOSE,
      CLEANUP,
      CLEAN,
      CHECKPOINT,
      CHECK,
      BY,
      TSTICKET,
      BUSTAT,
      BUFILE,
      BINARY,
      BEGIN_TOKEN,
      BACKUPMNG,
      BACKUP,
      AUTOCORRECT,
      ASSIGN,
      ARCHLOG,
      APPSIZE,
      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,
      KeepTicketOpt,
      SyncCmdOption,
      TimeoutOpt,
      MsgOption,
      StartOptList,
      StartOpt,
      XPMode,
      AttrList,
      Attr,
      PitOption,
      Statement
   };
   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(int state, ScannerStateType type = INTERMEDIATE);
      ScannerStateEntry& operator = (const ScannerStateEntry& s);
      bool operator == (const ScannerStateEntry& s);

	   int getState();
      ScannerStateType getType();

   private:

      int _state;
      ScannerStateType _type;
   };

class ScannerTransEntry {

   public:

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

      int getFState();

   private:

      int  _state;
      char _c;
      int _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, int num, int state, Chain tval = "");
      StackEntry& operator = (const StackEntry& a);

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

   private:

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

   class ActionEntry {

   public:

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

      Action getAction();
      int getNum();

   private:

      Action _action;
      int _num;
   };

   ActionEntry _actionMap[422][117];
   int _jumpMap[422][15];

   class ProdEntry {

   public:

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

      int getId();
      Production getProd();
      int getNumSymbol();

   private:

      int _id;
      Production _prod;
      int _numSymbol;

   };

   ListT<ProdEntry> _prodInfo;

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

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

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

};
