/* 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[184] = {
    "%if",
    NULL,
    "%ifctx",
    "%ifdef",
    "%ifdefalias",
    "%ifdifi",
    "%ifdirective",
    "%ifempty",
    "%ifenv",
    "%iffile",
    "%ifid",
    "%ifidn",
    "%ifidni",
    "%ifmacro",
    "%ifnum",
    "%ifstr",
    "%iftoken",
    "%ifusable",
    "%ifusing",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%ifn",
    NULL,
    "%ifnctx",
    "%ifndef",
    "%ifndefalias",
    "%ifndifi",
    "%ifndirective",
    "%ifnempty",
    "%ifnenv",
    "%ifnfile",
    "%ifnid",
    "%ifnidn",
    "%ifnidni",
    "%ifnmacro",
    "%ifnnum",
    "%ifnstr",
    "%ifntoken",
    "%ifnusable",
    "%ifnusing",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%elif",
    NULL,
    "%elifctx",
    "%elifdef",
    "%elifdefalias",
    "%elifdifi",
    "%elifdirective",
    "%elifempty",
    "%elifenv",
    "%eliffile",
    "%elifid",
    "%elifidn",
    "%elifidni",
    "%elifmacro",
    "%elifnum",
    "%elifstr",
    "%eliftoken",
    "%elifusable",
    "%elifusing",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%elifn",
    NULL,
    "%elifnctx",
    "%elifndef",
    "%elifndefalias",
    "%elifndifi",
    "%elifndirective",
    "%elifnempty",
    "%elifnenv",
    "%elifnfile",
    "%elifnid",
    "%elifnidn",
    "%elifnidni",
    "%elifnmacro",
    "%elifnnum",
    "%elifnstr",
    "%elifntoken",
    "%elifnusable",
    "%elifnusing",
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    "%aliases",
    "%arg",
    "%clear",
    "%depend",
    "%else",
    "%endif",
    "%endm",
    "%endmacro",
    "%endrep",
    "%error",
    "%exitmacro",
    "%exitrep",
    "%fatal",
    "%include",
    "%line",
    "%local",
    "%note",
    "%null",
    "%pop",
    "%pragma",
    "%push",
    "%rep",
    "%repl",
    "%require",
    "%rotate",
    "%stacksize",
    "%undef",
    "%undefalias",
    "%use",
    "%warning",
    "%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[184] = {
    3,
    9,
    6,
    6,
    11,
    7,
    12,
    8,
    6,
    7,
    5,
    6,
    7,
    8,
    6,
    6,
    8,
    9,
    8,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    11,
    4,
    10,
    7,
    7,
    12,
    8,
    13,
    9,
    7,
    8,
    6,
    7,
    8,
    9,
    7,
    7,
    9,
    10,
    9,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    12,
    5,
    11,
    8,
    8,
    13,
    9,
    14,
    10,
    8,
    9,
    7,
    8,
    9,
    10,
    8,
    8,
    10,
    11,
    10,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    13,
    6,
    12,
    9,
    9,
    14,
    10,
    15,
    11,
    9,
    10,
    8,
    9,
    10,
    11,
    9,
    9,
    11,
    12,
    11,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    14,
    8,
    4,
    6,
    7,
    5,
    6,
    5,
    9,
    7,
    6,
    10,
    8,
    6,
    8,
    5,
    6,
    5,
    5,
    4,
    7,
    5,
    4,
    5,
    8,
    7,
    10,
    6,
    11,
    4,
    8,
    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,
        171,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        171,
        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,
        131,
        INVALID_HASH_ENTRY,
        0,
        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,
        129,
        -160,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        158,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        50,
        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,
        72,
        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,
        142,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        0,
        104,
        134,
        INVALID_HASH_ENTRY,
        13,
        39,
        0,
        0,
        4,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        145,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        98,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -139,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        48,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        107,
        INVALID_HASH_ENTRY,
        82,
        INVALID_HASH_ENTRY,
        71,
        0,
        INVALID_HASH_ENTRY,
        37,
        0,
        0,
        -36,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        7,
        -139,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        180,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -94,
        74,
        INVALID_HASH_ENTRY,
        136,
        INVALID_HASH_ENTRY,
        0,
        0,
        305,
        -103,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        45,
        0,
        -54,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        -87,
        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,
        40,
        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,
        162,
        0,
        135,
        INVALID_HASH_ENTRY,
        103,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        140,
        INVALID_HASH_ENTRY,
        114,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        37,
        INVALID_HASH_ENTRY,
        163,
        INVALID_HASH_ENTRY,
        17,
        6,
        -39,
        171,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        307,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        72,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        110,
        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,
        181,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        36,
        INVALID_HASH_ENTRY,
        32,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        169,
        INVALID_HASH_ENTRY,
        35,
        -95,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        185,
        11,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        173,
        INVALID_HASH_ENTRY,
        5,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        158,
        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,
        150,
        INVALID_HASH_ENTRY,
        120,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        0,
        64,
        0,
        111,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        102,
        0,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -26,
        168,
        129,
        INVALID_HASH_ENTRY,
        177,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        47,
        176,
        109,
        INVALID_HASH_ENTRY,
        1,
        113,
        70,
        99,
        43,
        79,
        INVALID_HASH_ENTRY,
        81,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        155,
        -89,
        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,
        100,
        -29,
        148,
        109,
        INVALID_HASH_ENTRY,
        75,
        INVALID_HASH_ENTRY,
        195,
        -39,
        INVALID_HASH_ENTRY,
        167,
        40,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        133,
        INVALID_HASH_ENTRY,
        -122,
        INVALID_HASH_ENTRY,
        143,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        66,
        INVALID_HASH_ENTRY,
        101,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        80,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        152,
        73,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        175,
        -158,
        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,
        172,
        78,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        151,
        182,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        -23,
        130,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        154,
        41,
        98,
        INVALID_HASH_ENTRY,
        76,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        139,
        16,
        -169,
        4,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        12,
        INVALID_HASH_ENTRY,
        141,
        INVALID_HASH_ENTRY,
        96,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        163,
        -25,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        14,
        -45,
        INVALID_HASH_ENTRY,
        137,
        105,
        183,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        174,
        INVALID_HASH_ENTRY,
        157,
        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 >= 184)
        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,
        133,
        0,
        163,
        64,
        3,
        0,
        0,
        141,
        INVALID_HASH_ENTRY,
        0,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        INVALID_HASH_ENTRY,
        143,
        132,
        INVALID_HASH_ENTRY,
        126,
        INVALID_HASH_ENTRY,
        -128,
        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 >= 184)
        return PP_invalid;

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

    return ix;
}
