/* Automatically generated from ./asm/pptok.dat by ./asm/pptok.pl */
/* Do not edit */

#include "compiler.h"
#include "nctype.h"
#include "nasmlib.h"
#include "hashtbl.h"
#include "preproc.h"

const char * const pp_directives[120] = {
    "%if",
    "%ifctx",
    "%ifdef",
    "%ifdefalias",
    "%ifdifi",
    "%ifempty",
    "%ifenv",
    "%ifid",
    "%ifidn",
    "%ifidni",
    "%ifmacro",
    "%ifnum",
    "%ifstr",
    "%iftoken",
    "%ifusable",
    "%ifusing",
    "%ifn",
    "%ifnctx",
    "%ifndef",
    "%ifndefalias",
    "%ifndifi",
    "%ifnempty",
    "%ifnenv",
    "%ifnid",
    "%ifnidn",
    "%ifnidni",
    "%ifnmacro",
    "%ifnnum",
    "%ifnstr",
    "%ifntoken",
    "%ifnusable",
    "%ifnusing",
    "%elif",
    "%elifctx",
    "%elifdef",
    "%elifdefalias",
    "%elifdifi",
    "%elifempty",
    "%elifenv",
    "%elifid",
    "%elifidn",
    "%elifidni",
    "%elifmacro",
    "%elifnum",
    "%elifstr",
    "%eliftoken",
    "%elifusable",
    "%elifusing",
    "%elifn",
    "%elifnctx",
    "%elifndef",
    "%elifndefalias",
    "%elifndifi",
    "%elifnempty",
    "%elifnenv",
    "%elifnid",
    "%elifnidn",
    "%elifnidni",
    "%elifnmacro",
    "%elifnnum",
    "%elifnstr",
    "%elifntoken",
    "%elifnusable",
    "%elifnusing",
    "%aliases",
    "%arg",
    "%clear",
    "%depend",
    "%else",
    "%endif",
    "%endm",
    "%endmacro",
    "%endrep",
    "%error",
    "%exitmacro",
    "%exitrep",
    "%fatal",
    "%include",
    "%line",
    "%local",
    "%null",
    "%pop",
    "%pragma",
    "%push",
    "%rep",
    "%repl",
    "%require",
    "%rotate",
    "%stacksize",
    "%undef",
    "%undefalias",
    "%use",
    "%warning",
    NULL,
    "%assign",
    "%iassign",
    "%defalias",
    "%idefalias",
    "%define",
    "%idefine",
    "%defstr",
    "%idefstr",
    "%deftok",
    "%ideftok",
    "%macro",
    "%imacro",
    "%pathsearch",
    "%ipathsearch",
    "%rmacro",
    "%irmacro",
    "%strcat",
    "%istrcat",
    "%strlen",
    "%istrlen",
    "%substr",
    "%isubstr",
    "%xdefine",
    "%ixdefine",
    "%unmacro",
    "%unimacro",
};
const uint8_t pp_directives_len[120] = {
    3,
    6,
    6,
    11,
    7,
    8,
    6,
    5,
    6,
    7,
    8,
    6,
    6,
    8,
    9,
    8,
    4,
    7,
    7,
    12,
    8,
    9,
    7,
    6,
    7,
    8,
    9,
    7,
    7,
    9,
    10,
    9,
    5,
    8,
    8,
    13,
    9,
    10,
    8,
    7,
    8,
    9,
    10,
    8,
    8,
    10,
    11,
    10,
    6,
    9,
    9,
    14,
    10,
    11,
    9,
    8,
    9,
    10,
    11,
    9,
    9,
    11,
    12,
    11,
    8,
    4,
    6,
    7,
    5,
    6,
    5,
    9,
    7,
    6,
    10,
    8,
    6,
    8,
    5,
    6,
    5,
    4,
    7,
    5,
    4,
    5,
    8,
    7,
    10,
    6,
    11,
    4,
    8,
    9,
    7,
    8,
    9,
    10,
    7,
    8,
    7,
    8,
    7,
    8,
    6,
    7,
    11,
    12,
    7,
    8,
    7,
    8,
    7,
    8,
    7,
    8,
    8,
    9,
    8,
    9,
};

#define INVALID_HASH_ENTRY (65535/3)


/* Primary preprocessor token hash */

enum preproc_token pp_token_hash(const char *token)
{
    static const int16_t hashdata[512] = {
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        107,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        74,
        0,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        67,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        65,
        -66,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        94,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        31,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        38,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        78,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        54,
        70,
        INVALID_HASH_ENTRY,
        12,
        21,
        0,
        0,
        3,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        80,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        49,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -77,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        56,
        INVALID_HASH_ENTRY,
        47,
        INVALID_HASH_ENTRY,
        37,
        0,
        INVALID_HASH_ENTRY,
        37,
        0,
        INVALID_HASH_ENTRY,
        -20,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        7,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        116,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -32,
        39,
        INVALID_HASH_ENTRY,
        72,
        INVALID_HASH_ENTRY,
        0,
        0,
        179,
        -72,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        26,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -40,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        25,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        98,
        0,
        71,
        INVALID_HASH_ENTRY,
        53,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        76,
        INVALID_HASH_ENTRY,
        63,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        20,
        INVALID_HASH_ENTRY,
        99,
        INVALID_HASH_ENTRY,
        14,
        0,
        -6,
        91,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        164,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        37,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        59,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        117,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        19,
        INVALID_HASH_ENTRY,
        16,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        105,
        INVALID_HASH_ENTRY,
        18,
        -47,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        104,
        8,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        109,
        INVALID_HASH_ENTRY,
        4,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        100,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -53,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        85,
        INVALID_HASH_ENTRY,
        87,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        32,
        0,
        60,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        29,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -12,
        104,
        63,
        INVALID_HASH_ENTRY,
        113,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        28,
        112,
        59,
        INVALID_HASH_ENTRY,
        -5,
        62,
        INVALID_HASH_ENTRY,
        50,
        24,
        44,
        INVALID_HASH_ENTRY,
        46,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        90,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        51,
        -14,
        83,
        58,
        INVALID_HASH_ENTRY,
        40,
        INVALID_HASH_ENTRY,
        97,
        0,
        INVALID_HASH_ENTRY,
        103,
        22,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        69,
        INVALID_HASH_ENTRY,
        -61,
        INVALID_HASH_ENTRY,
        79,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        33,
        INVALID_HASH_ENTRY,
        52,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        45,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        87,
        17,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        111,
        -97,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        108,
        43,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        86,
        118,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -23,
        66,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        89,
        INVALID_HASH_ENTRY,
        69,
        INVALID_HASH_ENTRY,
        41,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        75,
        15,
        -90,
        5,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        9,
        INVALID_HASH_ENTRY,
        75,
        INVALID_HASH_ENTRY,
        48,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        68,
        -9,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        11,
        -31,
        INVALID_HASH_ENTRY,
        73,
        INVALID_HASH_ENTRY,
        119,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        110,
        INVALID_HASH_ENTRY,
        92,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
    };
    uint32_t k1, k2;
    uint64_t crc;
    uint16_t ix;

    crc = crc64i(UINT64_C(0x076259c3e291c26c), token);
    k1 = ((uint32_t)crc & 0x1fe) + 0;
    k2 = ((uint32_t)(crc >> 32) & 0x1fe) + 1;

    ix = hashdata[k1] + hashdata[k2];
    if (ix >= 120)
        return PP_invalid;

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

    return ix;
}


/* TASM compatibility preprocessor token hash */
enum preproc_token pp_tasm_token_hash(const char *token)
{
    static const int16_t hashdata[32] = {
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        69,
        0,
        83,
        32,
        2,
        0,
        0,
        77,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        79,
        68,
        INVALID_HASH_ENTRY,
        63,
        INVALID_HASH_ENTRY,
        -65,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
    };
    uint32_t k1, k2;
    uint64_t crc;
    uint16_t ix;

    crc = crc64i(UINT64_C(0x076259c3e291c26c), token);
    k1 = ((uint32_t)crc & 0x1e) + 0;
    k2 = ((uint32_t)(crc >> 32) & 0x1e) + 1;

    ix = hashdata[k1] + hashdata[k2];
    if (ix >= 120)
        return PP_invalid;

    if (!pp_directives[ix] || nasm_stricmp(pp_directives[ix]+1, token))
        return PP_invalid;

    return ix;
}
