mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Completely new asso_values search algorithm.
This commit is contained in:
@@ -8,8 +8,8 @@ struct resword { const char *name; short token; enum rid rid;};
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 16
|
||||
#define MIN_HASH_VALUE 4
|
||||
#define MAX_HASH_VALUE 250
|
||||
/* maximum key range = 247, duplicates = 0 */
|
||||
#define MAX_HASH_VALUE 163
|
||||
/* maximum key range = 160, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
@@ -25,32 +25,32 @@ hash (str, len)
|
||||
{
|
||||
static unsigned char asso_values[] =
|
||||
{
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 0, 251, 64, 93, 3,
|
||||
0, 0, 74, 35, 0, 26, 251, 2, 31, 65,
|
||||
23, 76, 7, 19, 45, 37, 6, 64, 12, 38,
|
||||
14, 4, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
|
||||
251, 251, 251, 251, 251, 251
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 0, 164, 44, 58, 15,
|
||||
55, 0, 24, 23, 25, 2, 164, 4, 26, 75,
|
||||
36, 11, 40, 74, 14, 23, 1, 45, 45, 90,
|
||||
50, 50, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
|
||||
164, 164, 164, 164, 164, 164
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
@@ -84,162 +84,141 @@ is_reserved_word (str, len)
|
||||
{
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"else", ELSE, NORID,},
|
||||
{"true", CXX_TRUE, NORID,},
|
||||
{"int", TYPESPEC, RID_INT,},
|
||||
{"", 0, 0},
|
||||
{"delete", DELETE, NORID,},
|
||||
{"case", CASE, NORID,},
|
||||
{"__real__", REALPART, NORID},
|
||||
{"", 0, 0},
|
||||
{"true", CXX_TRUE, NORID,},
|
||||
{"catch", CATCH, NORID,},
|
||||
{"typeid", TYPEID, NORID,},
|
||||
{"try", TRY, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"void", TYPESPEC, RID_VOID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"inline", SCSPEC, RID_INLINE,},
|
||||
{"", 0, 0},
|
||||
{"private", VISSPEC, RID_PRIVATE,},
|
||||
{"template", TEMPLATE, RID_TEMPLATE,},
|
||||
{"protected", VISSPEC, RID_PROTECTED,},
|
||||
{"extern", SCSPEC, RID_EXTERN,},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"not", '!', NORID,},
|
||||
{"", 0, 0},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{"int", TYPESPEC, RID_INT,},
|
||||
{"__signed__", TYPESPEC, RID_SIGNED},
|
||||
{"__real", REALPART, NORID},
|
||||
{"", 0, 0},
|
||||
{"xor_eq", ASSIGN, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"__attribute", ATTRIBUTE, NORID},
|
||||
{"__asm__", ASM_KEYWORD, NORID},
|
||||
{"", 0, 0},
|
||||
{"__attribute__", ATTRIBUTE, NORID},
|
||||
{"compl", '~', NORID,},
|
||||
{"public", VISSPEC, RID_PUBLIC,},
|
||||
{"not_eq", EQCOMPARE, NORID,},
|
||||
{"switch", SWITCH, NORID,},
|
||||
{"__extension__", EXTENSION, NORID},
|
||||
{"", 0, 0},
|
||||
{"export", SCSPEC, RID_EXPORT,},
|
||||
{"case", CASE, NORID,},
|
||||
{"__const", CV_QUALIFIER, RID_CONST},
|
||||
{"__const__", CV_QUALIFIER, RID_CONST},
|
||||
{"__volatile", CV_QUALIFIER, RID_VOLATILE},
|
||||
{"", 0, 0},
|
||||
{"__volatile__", CV_QUALIFIER, RID_VOLATILE},
|
||||
{"__restrict", CV_QUALIFIER, RID_RESTRICT},
|
||||
{"__restrict__", CV_QUALIFIER, RID_RESTRICT},
|
||||
{"or", OROR, NORID,},
|
||||
{"if", IF, NORID,},
|
||||
{"", 0, 0},
|
||||
{"__asm__", ASM_KEYWORD, NORID},
|
||||
{"typeof", TYPEOF, NORID,},
|
||||
{"__real", REALPART, NORID},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"__sigof__", SIGOF, NORID /* Extension */,},
|
||||
{"static_cast", STATIC_CAST, NORID,},
|
||||
{"explicit", SCSPEC, RID_EXPLICIT,},
|
||||
{"register", SCSPEC, RID_REGISTER,},
|
||||
{"__wchar_t", TYPESPEC, RID_WCHAR /* Unique to ANSI C++ */,},
|
||||
{"not", '!', NORID,},
|
||||
{"for", FOR, NORID,},
|
||||
{"extern", SCSPEC, RID_EXTERN,},
|
||||
{"short", TYPESPEC, RID_SHORT,},
|
||||
{"const", CV_QUALIFIER, RID_CONST,},
|
||||
{"static", SCSPEC, RID_STATIC,},
|
||||
{"", 0, 0},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"", 0, 0},
|
||||
{"__inline__", SCSPEC, RID_INLINE},
|
||||
{"__restrict__", CV_QUALIFIER, RID_RESTRICT},
|
||||
{"inline", SCSPEC, RID_INLINE,},
|
||||
{"const_cast", CONST_CAST, NORID,},
|
||||
{"static_cast", STATIC_CAST, NORID,},
|
||||
{"__restrict", CV_QUALIFIER, RID_RESTRICT},
|
||||
{"xor", '^', NORID,},
|
||||
{"__wchar_t", TYPESPEC, RID_WCHAR /* Unique to ANSI C++ */,},
|
||||
{"new", NEW, NORID,},
|
||||
{"__alignof__", ALIGNOF, NORID},
|
||||
{"signed", TYPESPEC, RID_SIGNED,},
|
||||
{"and", ANDAND, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"explicit", SCSPEC, RID_EXPLICIT,},
|
||||
{"", 0, 0},
|
||||
{"__imag__", IMAGPART, NORID},
|
||||
{"while", WHILE, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"do", DO, NORID,},
|
||||
{"typename", TYPENAME_KEYWORD, NORID,},
|
||||
{"friend", SCSPEC, RID_FRIEND,},
|
||||
{"continue", CONTINUE, NORID,},
|
||||
{"class", AGGR, RID_CLASS,},
|
||||
{"default", DEFAULT, NORID,},
|
||||
{"this", THIS, NORID,},
|
||||
{"dynamic_cast", DYNAMIC_CAST, NORID,},
|
||||
{"typeof", TYPEOF, NORID,},
|
||||
{"virtual", SCSPEC, RID_VIRTUAL,},
|
||||
{"export", SCSPEC, RID_EXPORT,},
|
||||
{"and_eq", ASSIGN, NORID,},
|
||||
{"__typeof__", TYPEOF, NORID},
|
||||
{"__const__", CV_QUALIFIER, RID_CONST},
|
||||
{"__volatile", CV_QUALIFIER, RID_VOLATILE},
|
||||
{"short", TYPESPEC, RID_SHORT,},
|
||||
{"__volatile__", CV_QUALIFIER, RID_VOLATILE},
|
||||
{"__const", CV_QUALIFIER, RID_CONST},
|
||||
{"namespace", NAMESPACE, NORID,},
|
||||
{"char", TYPESPEC, RID_CHAR,},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED,},
|
||||
{"double", TYPESPEC, RID_DOUBLE,},
|
||||
{"or_eq", ASSIGN, NORID,},
|
||||
{"__null", CONSTANT, RID_NULL},
|
||||
{"if", IF, NORID,},
|
||||
{"__signature__", AGGR, RID_SIGNATURE /* Extension */,},
|
||||
{"__label__", LABEL, NORID},
|
||||
{"long", TYPESPEC, RID_LONG,},
|
||||
{"__imag", IMAGPART, NORID},
|
||||
{"__asm", ASM_KEYWORD, NORID},
|
||||
{"", 0, 0},
|
||||
{"__sigof__", SIGOF, NORID /* Extension */,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"struct", AGGR, RID_RECORD,},
|
||||
{"", 0, 0},
|
||||
{"volatile", CV_QUALIFIER, RID_VOLATILE,},
|
||||
{"__complex__", TYPESPEC, RID_COMPLEX},
|
||||
{"goto", GOTO, NORID,},
|
||||
{"template", TEMPLATE, RID_TEMPLATE,},
|
||||
{"this", THIS, NORID,},
|
||||
{"false", CXX_FALSE, NORID,},
|
||||
{"sizeof", SIZEOF, NORID,},
|
||||
{"__complex__", TYPESPEC, RID_COMPLEX},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"for", FOR, NORID,},
|
||||
{"or", OROR, NORID,},
|
||||
{"register", SCSPEC, RID_REGISTER,},
|
||||
{"throw", THROW, NORID,},
|
||||
{"try", TRY, NORID,},
|
||||
{"switch", SWITCH, NORID,},
|
||||
{"typedef", SCSPEC, RID_TYPEDEF,},
|
||||
{"", 0, 0},
|
||||
{"using", USING, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"__complex", TYPESPEC, RID_COMPLEX},
|
||||
{"operator", OPERATOR, NORID,},
|
||||
{"__signature__", AGGR, RID_SIGNATURE /* Extension */,},
|
||||
{"catch", CATCH, NORID,},
|
||||
{"delete", DELETE, NORID,},
|
||||
{"typeid", TYPEID, NORID,},
|
||||
{"sigof", SIGOF, NORID /* Extension */,},
|
||||
{"const_cast", CONST_CAST, NORID,},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{"class", AGGR, RID_CLASS,},
|
||||
{"xor", '^', NORID,},
|
||||
{"do", DO, NORID,},
|
||||
{"continue", CONTINUE, NORID,},
|
||||
{"auto", SCSPEC, RID_AUTO,},
|
||||
{"__typeof__", TYPEOF, NORID},
|
||||
{"", 0, 0},
|
||||
{"asm", ASM_KEYWORD, NORID,},
|
||||
{"signature", AGGR, RID_SIGNATURE /* Extension */,},
|
||||
{"enum", ENUM, NORID,},
|
||||
{"reinterpret_cast", REINTERPRET_CAST, NORID,},
|
||||
{"mutable", SCSPEC, RID_MUTABLE,},
|
||||
{"__alignof", ALIGNOF, NORID},
|
||||
{"return", RETURN_KEYWORD, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"__alignof__", ALIGNOF, NORID},
|
||||
{"float", TYPESPEC, RID_FLOAT,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"struct", AGGR, RID_RECORD,},
|
||||
{"long", TYPESPEC, RID_LONG,},
|
||||
{"__null", CONSTANT, RID_NULL},
|
||||
{"", 0, 0},
|
||||
{"__label__", LABEL, NORID},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"reinterpret_cast", REINTERPRET_CAST, NORID,},
|
||||
{"__inline__", SCSPEC, RID_INLINE},
|
||||
{"__imag__", IMAGPART, NORID},
|
||||
{"typename", TYPENAME_KEYWORD, NORID,},
|
||||
{"friend", SCSPEC, RID_FRIEND,},
|
||||
{"compl", '~', NORID,},
|
||||
{"public", VISSPEC, RID_PUBLIC,},
|
||||
{"bitor", '|', NORID,},
|
||||
{"namespace", NAMESPACE, NORID,},
|
||||
{"or_eq", ASSIGN, NORID,},
|
||||
{"", 0, 0},
|
||||
{"private", VISSPEC, RID_PRIVATE,},
|
||||
{"__typeof", TYPEOF, NORID},
|
||||
{"", 0, 0},
|
||||
{"__alignof", ALIGNOF, NORID},
|
||||
{"__complex", TYPESPEC, RID_COMPLEX},
|
||||
{"union", AGGR, RID_UNION,},
|
||||
{"", 0, 0},
|
||||
{"__extension__", EXTENSION, NORID},
|
||||
{"", 0, 0},
|
||||
{"return", RETURN_KEYWORD, NORID,},
|
||||
{"and", ANDAND, NORID,},
|
||||
{"__asm", ASM_KEYWORD, NORID},
|
||||
{"__imag", IMAGPART, NORID},
|
||||
{"virtual", SCSPEC, RID_VIRTUAL,},
|
||||
{"protected", VISSPEC, RID_PROTECTED,},
|
||||
{"throw", THROW, NORID,},
|
||||
{"default", DEFAULT, NORID,},
|
||||
{"using", USING, NORID,},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED,},
|
||||
{"break", BREAK, NORID,},
|
||||
{"", 0, 0},
|
||||
{"signature", AGGR, RID_SIGNATURE /* Extension */,},
|
||||
{"bool", TYPESPEC, RID_BOOL,},
|
||||
{"", 0, 0},
|
||||
{"typedef", SCSPEC, RID_TYPEDEF,},
|
||||
{"__typeof", TYPEOF, NORID},
|
||||
{"bitand", '&', NORID,},
|
||||
{"break", BREAK, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"union", AGGR, RID_UNION,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"not_eq", EQCOMPARE, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"goto", GOTO, NORID,},
|
||||
{"sigof", SIGOF, NORID /* Extension */,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0},
|
||||
{"bitor", '|', NORID,},
|
||||
{"auto", SCSPEC, RID_AUTO,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"double", TYPESPEC, RID_DOUBLE,},
|
||||
{"signed", TYPESPEC, RID_SIGNED,},
|
||||
{"while", WHILE, NORID,},
|
||||
{"asm", ASM_KEYWORD, NORID,},
|
||||
{"volatile", CV_QUALIFIER, RID_VOLATILE,},
|
||||
{"and_eq", ASSIGN, NORID,},
|
||||
{"", 0, 0},
|
||||
{"operator", OPERATOR, NORID,}
|
||||
{"mutable", SCSPEC, RID_MUTABLE,},
|
||||
{"dynamic_cast", DYNAMIC_CAST, NORID,},
|
||||
{"", 0, 0},
|
||||
{"new", NEW, NORID,},
|
||||
{"xor_eq", ASSIGN, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"enum", ENUM, NORID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"void", TYPESPEC, RID_VOID,},
|
||||
{"", 0, 0}, {"", 0, 0}, {"", 0, 0},
|
||||
{"bitand", '&', NORID,}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
|
||||
Reference in New Issue
Block a user