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

📄 pptok.c

📁 nasm早期的源代码,比较简单是学习汇编和编译原理的好例子
💻 C
字号:
/* Automatically generated from ./pptok.dat by ./pptok.pl */
/* Do not edit */

#include "compiler.h"
#include <inttypes.h>
#include <ctype.h>
#include "nasmlib.h"
#include "hashtbl.h"
#include "preproc.h"

const char * const pp_directives[93] = {
    "%elif",
    "%elifn",
    "%elifctx",
    "%elifnctx",
    "%elifdef",
    "%elifndef",
    "%elifid",
    "%elifnid",
    "%elifidn",
    "%elifnidn",
    "%elifidni",
    "%elifnidni",
    "%elifmacro",
    "%elifnmacro",
    "%elifnum",
    "%elifnnum",
    "%elifstr",
    "%elifnstr",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%if",
    "%ifn",
    "%ifctx",
    "%ifnctx",
    "%ifdef",
    "%ifndef",
    "%ifid",
    "%ifnid",
    "%ifidn",
    "%ifnidn",
    "%ifidni",
    "%ifnidni",
    "%ifmacro",
    "%ifnmacro",
    "%ifnum",
    "%ifnnum",
    "%ifstr",
    "%ifnstr",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%arg",
    "%assign",
    "%clear",
    "%define",
    "%else",
    "%endif",
    "%endm",
    "%endmacro",
    "%endrep",
    "%error",
    "%exitrep",
    "%iassign",
    "%idefine",
    "%imacro",
    "%include",
    "%ixdefine",
    "%line",
    "%local",
    "%macro",
    "%pop",
    "%push",
    "%rep",
    "%repl",
    "%rotate",
    "%stacksize",
    "%strlen",
    "%substr",
    "%undef",
    "%xdefine",
};
enum preproc_token pp_token_hash(const char *token)
{
#define UNUSED 16383
    static const int16_t hash1[64] = {
        0,
        0,
        0,
        0,
        22,
        0,
        0,
        22,
        UNUSED,
        UNUSED,
        UNUSED,
        77,
        58,
        0,
        69,
        UNUSED,
        UNUSED,
        UNUSED,
        UNUSED,
        0,
        141,
        UNUSED,
        48,
        26,
        -86,
        UNUSED,
        5,
        79,
        -32,
        43,
        34,
        -26,
        13,
        UNUSED,
        135,
        -149,
        UNUSED,
        UNUSED,
        83,
        16,
        UNUSED,
        -33,
        -36,
        35,
        -6,
        18,
        80,
        6,
        UNUSED,
        21,
        UNUSED,
        UNUSED,
        66,
        UNUSED,
        UNUSED,
        -1,
        150,
        UNUSED,
        UNUSED,
        -3,
        77,
        UNUSED,
        43,
        33,
    };
    static const int16_t hash2[64] = {
        UNUSED,
        0,
        UNUSED,
        64,
        0,
        UNUSED,
        156,
        60,
        UNUSED,
        0,
        UNUSED,
        UNUSED,
        53,
        UNUSED,
        91,
        0,
        78,
        17,
        -133,
        UNUSED,
        91,
        -31,
        UNUSED,
        0,
        3,
        UNUSED,
        -38,
        0,
        0,
        UNUSED,
        10,
        -36,
        UNUSED,
        -47,
        -69,
        UNUSED,
        UNUSED,
        UNUSED,
        4,
        UNUSED,
        15,
        UNUSED,
        UNUSED,
        71,
        41,
        155,
        UNUSED,
        UNUSED,
        UNUSED,
        UNUSED,
        64,
        -60,
        80,
        33,
        12,
        22,
        UNUSED,
        UNUSED,
        UNUSED,
        188,
        -2,
        124,
        UNUSED,
        UNUSED,
    };
    uint32_t k1, k2;
    uint64_t crc;
    uint16_t ix;

    crc = crc64i(UINT64_C(0xfcbb1f890c51d7c9), token);
    k1 = (uint32_t)crc;
    k2 = (uint32_t)(crc >> 32);

    ix = hash1[k1 & 0x3f] + hash2[k2 & 0x3f];
    if (ix >= 93)
        return PP_INVALID;

    if (!pp_directives[ix] || nasm_stricmp(pp_directives[ix], token))
        return PP_INVALID;

    return ix;
}

⌨️ 快捷键说明

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