⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codeparser.h

📁 语法检查程序
💻 H
字号:
/***************************************************************************/
/* NOTE:                                                                   */
/* This document is copyright (c) by Oz Solomon and Yonat Sharon, and is   */
/* bound by the MIT open source license.                                   */ 
/* See License.txt or visit www.opensource.org/licenses/mit-license.html   */
/***************************************************************************/

#ifndef CODE_PARSER_H
#define CODE_PARSER_H

class CodeState; // defines how the parser responds to data of a specific language

class CodeParser {
public:
    typedef char Datum;
    static const Datum cDefaultDatum;
    typedef int Position;

    class Context // base class for users of the parser
    {
    public:
        virtual void BegString(Position pos) = 0;
        virtual void EndString(Position pos) = 0;
        virtual void BegChar(Position pos) = 0;
        virtual void EndChar(Position pos) = 0;
        virtual void BegLineComment(Position pos) = 0;
        virtual void EndLineComment(Position pos) = 0;
        virtual void BegBlockComment(Position pos) = 0;
        virtual void EndBlockComment(Position pos) = 0;
        virtual ~Context() {}
    };

    CodeParser(
        const CodeState* initialState, // from a state map of a specific language
        Context* c = 0);

    void Process(Datum d);
    void Process(const Datum* data, Position length);
    void ResetPosition(Position newPosition = 0);
    void ResetState(const CodeState* newState = 0);

#ifndef NDEBUG
    const char* CurrentState();
#endif // NDEBUG

private:
    const CodeState*    itsInitialState;
    const CodeState*    itsState;
    Context*            itsContext;
    Position            itsPosition;
    Position            itsMarkedPosition;
};

#endif // CODE_PARSER_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -