Parser.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:3k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
- // Copyright 1996 by Jarle Aase. All rights reserved.
- // See the "War Software Series Licende Agreement" for details concerning
- // use and distribution.
- // ---
- // This source code, executables and programs containing source code or
- // binaries or proprietetary technology from the War Software Series are
- // NOT alloed used, viewed or tested by any governmental agencies in
- // any countries. This includes the government, departments, police,
- // military etc.
- // ---
- // This file is intended for use with Tab space = 2
- // Created and maintained in MSVC Developer Studio
- // ---
- // NAME : Parser.h
- // PURPOSE : Header for the command parser submodule
- // COMMENT : If I've had the time I would have written a Yacc
- // like generator, but my time schedule is too tight
- // so I guess I have to do it simple this time.
- //
- // PROGRAM :
- // DATE : Sept. 26 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- #ifndef __PARSERH
- #define __PARSERH
- ///////////////////////////////////////////////////////////////////////
- // STokenTab
- enum // What we want from lex
- {
- LEX_WANT_CMD,
- LEX_WANT_STRING,
- LEX_WANT_BOOL,
- LEX_WANT_INT,
- LEX_WANT_CHAR
- };
- #define LEX_PARSE_QUOTES 0x1000
- enum // General token ID's
- {
- // Must be syncronized with LEX_WANT_*
- TOK_STRING = LEX_WANT_STRING,
- TOK_BOOL, TOK_INT, TOK_CHAR,
- // Used internally
- TOK_INVALID,
- TOK_END_OF_TOKENS,
- // start of derived class enum ID
- TOK_START_TAB
- };
- typedef struct STokenTabDef
- {
- int TokenID; // Token that identifies this node
- LPCSTR Token;
- } STokenTab;
- ///////////////////////////////////////////////////////////////////////
- // SCommandTtree
- enum // General Command ID's
- {
- // Return values
- CMD_PARSE_ERROR,
- CMD_UNKNOWN_COMMAND,
- CMD_UNKNOWN_PARAMETER,
- CMD_MISSING_PARAMETER,
- CMD_NOT_IMPLEMENTED,
- CMD_BAD_LEVEL,
- // Used internally
- CMD_INVALID,
- // start of derived class enum ID
- CMD_START_TREE
- };
- // Flags
- #define CMDF_NOT_IMPLEMENTED 0x0001
- #define CMDF_PARAMETER 0x0002
- #define CMDF_NOPARAM 0x0004
- #define CMDF_PARSE_CMD_LINE 0x0008
- typedef struct SCommandTreeDef
- {
- int TokenID; // Token that identifies this node
- int CommandID; // Command ID to execute
- int AccessLevel; // Access level to process
- int Flags; // Misc flags
- struct SCommandTreeDef *NextLevel;
- int LexTokenDelim;
- int LexWhatWeWant;
- LPCSTR CommandSyntax;
- } SCommandTree;
- ///////////////////////////////////////////////////////////////////////
- // CCommandParser
- // Override to implement commands
- // Call base class to process basic commands like "QUIT" and "HELP"
- class CCmdArgs;
- class DLL_WAR_SOFTWARE_ CCommandParser
- {
- public:
- SCommandTree *m_Commands;
- STokenTab *m_Tokens;
- public:
- CCommandParser();
- virtual int ParseCmd(LPCSTR CmdLine, CCmdArgs& Args, int Level);
- public:
- virtual int yyParse(LPCSTR CmdLine, SCommandTree *CmdPtr, STokenTab *LexTab, CCmdArgs& Args);
- virtual int yyLex(LPCSTR *CmdLine, STokenTab *LexTab, int LexEOT, int Want, CCmdArgs& Args);
- };
- #endif __PARSERH