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

📄 fortrancodestate.cpp

📁 语法检查程序
💻 CPP
字号:
/***************************************************************************/
/* 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   */
/***************************************************************************/

#include "CodeState.h"

const CodeState* FortranCodeState()
{
    // states
    enum {
        cNormal,
        cString,        // in double quotes
        cCharString,    // in single quotes
        cLineComment,
        cStatesNum
    };
    static CodeState states[cStatesNum];
    static bool initialized = false;

    if (initialized)
        return &states[0];

#ifndef NDEBUG
    states[cNormal].itsName = "Normal";
    states[cString].itsName = "String";
    states[cCharString].itsName = "CharString";
    states[cLineComment].itsName = "LineComment";
#endif // NDEBUG

    CodeEffect e;
    e.markPosition = true; // in all cases

    // end string
    e.next = &states[cNormal];
    e.action = CodeParser::Context::EndString;
    states[cString]['"'] = e;
    states[cCharString]['\''] = e;

    // end comment
    e.action = CodeParser::Context::EndLineComment;
    states[cLineComment]['\n'] = e;

    // begin string
    e.action = CodeParser::Context::BegString;
    e.next = &states[cString];
    states[cNormal]['"'] = e;
    e.next = &states[cCharString];
    states[cNormal]['\''] = e;

    // begin line comment
    e.action = CodeParser::Context::BegLineComment;
    e.next = &states[cLineComment];
    states[cNormal]['!'] = e;

    initialized = true;

    return &states[0];
}


#ifdef TEST_FORTRAN_CODE_STATE

#include "TestContext.h"

char str[] = ""; // TODO!

int main()
{
    TestContext t(str);
    CodeParser cp(FortranCodeState(), &t);
    cp.Process(str, sizeof(str));

    return 0;
}

#endif // TEST_FORTRAN_CODE_STATE

⌨️ 快捷键说明

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