示例#1
0
void initDir() {
  FunctionEntry<pFun> funs[] = {
    "end",dirEND,
    "code",dirCODE,
    "module",dirMODULE,
    "endmodule",dirENDMODULE,
    "page",dirPAGE,
    "defpage",dirDEFPAGE,
    "##",dirMAPALIGN,
    "mapalign",dirMAPALIGN,
    "map",dirMAP,
    "endmap",dirENDMAP,
    "align",dirALIGN,
    "phase",dirPHASE,
    "dephase",dirDEPHASE,
    "incbin",/*dirINCBIN,*/ dirINCBINDOT,
    "output",dirOUTPUT,
    "update",dirUPDATE,
    "incdir",dirINCDIR,
    "assert",dirASSERT,
    "org",dirORG,
    "size",dirSIZE,
    "error",dirERROR,

    "z80",dirZ80,
#ifdef METARM
    "thumb",dirTHUMB,
    "arm",dirARM,
#endif

    "incbin.",dirINCBINDOT,
  };
  dirfuntab.init(funs, sizeof funs/sizeof funs[0]);
}
void initpreprocessor() {
    FunctionEntry<pFun> group1if[] = {
        "ifdef",preIFDEF,
        "ifndef",preIFNDEF,
        "else",preELSE,
        "endif",preENDIF,

        "elseifdef",preELSEIFDEF,
        "elseifndef",preELSEIFNDEF,
    };

    FunctionEntry<pFun> group2if[] = {
        "if",preIF,
        "ifidn",preIFIDN,
        "ifidni",preIFIDNI,
        "ifdif",preIFDIF,
        "ifdifi",preIFDIFI,
        "ifb",preIFB,
        "ifid",preIFID,
        "ifstr",preIFSTR,
        "ifnum",preIFNUM,
        "ifnb",preIFNB,
        "ifnid",preIFNID,
        "ifnstr",preIFNSTR,
        "ifnnum",preIFNNUM,
        "ifexists",preIFEXISTS,
        "ifnexists",preIFNEXISTS,
        "ifin",preIFIN,
        "ifini",preIFINI,

        "elseif",preELSEIF,
        "elseifidn",preELSEIFIDN,
        "elseifidni",preELSEIFIDNI,
        "elseifdif",preELSEIFDIF,
        "elseifdifi",preELSEIFDIFI,
        "elseifb",preELSEIFB,
        "elseifid",preELSEIFID,
        "elseifstr",preELSEIFSTR,
        "elseifnum",preELSEIFNUM,
        "elseifnb",preELSEIFNB,
        "elseifnid",preELSEIFNID,
        "elseifnstr",preELSEIFNSTR,
        "elseifnnum",preELSEIFNNUM,
        "elseifexists",preELSEIFEXISTS,
        "elseifnexists",preELSEIFNEXISTS,
        "elseifin",preELSEIFIN,
        "elseifini",preELSEIFINI,
    };

    FunctionEntry<pFun> group1[] = {
        "define",preDEFINE,
        "idefine",preIDEFINE,
        "xdefine",preXDEFINE,
        "xidefine",preXIDEFINE,
        "undef",preUNDEF,
        "assign",preASSIGN,

        "tostr",preTOSTR,
        "strlen",preSTRLEN,
        "substr",preSUBSTR,
    };

    FunctionEntry<pFun> group2[] = {
        "include",preINCLUDE,

        "macro",preMACRODOT,
        "imacro",preIMACRODOT,
        "rotate",preROTATE,
        "while",preWHILEDOT,
        "repeat",preREPEATDOT,
        "break",preBREAK,
        "continue",preCONTINUE,
        "exitmacro",preEXITMACRO,
        "xexitmacro",preXEXITMACRO,
        "struct",preSTRUCT,

        "macro.",preMACRODOT,
        "imacro.",preIMACRODOT,
        "while.",preWHILEDOT,
        "repeat.",preREPEATDOT,

        "endmacro",preENDMACRO,
        "endwhile",preENDWHILE,
        "endrepeat",preENDREPEAT,
        "endstruct",preENDSTRUCT,

        "endm",preENDMACRO,
        "ends",preENDSTRUCT,
    };

    group1iftab.init(group1if, sizeof group1if/sizeof group1if[0]);
    group2iftab.init(group2if, sizeof group2if/sizeof group2if[0]);
    group1tab.init(group1if, sizeof group1if/sizeof group1if[0]);
    group1tab.init(group1, sizeof group1/sizeof group1[0]);
    group2tab.init(group2if, sizeof group2if/sizeof group2if[0]);
    group2tab.init(group2, sizeof group2/sizeof group2[0]);

    macronl.push_back("macro");
    macronl.push_back("imacro");
    macronl.push_back("macro.");
    macronl.push_back("imacro.");
    macroel.push_back("endmacro");
    macroel.push_back("endm");
    whilenl.push_back("while");
    whilenl.push_back("while.");
    whileel.push_back("endwhile");
    repeatnl.push_back("repeat");
    repeatnl.push_back("repeat.");
    repeatel.push_back("endrepeat");
    structureel.push_back("endstruct");
    structureel.push_back("ends");
}