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:
214
tests/test-4.exp
214
tests/test-4.exp
@@ -7,9 +7,9 @@ struct resword { const char *name; short token; enum rid rid; };
|
||||
#define TOTAL_KEYWORDS 83
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 20
|
||||
#define MIN_HASH_VALUE 6
|
||||
#define MAX_HASH_VALUE 170
|
||||
/* maximum key range = 165, duplicates = 8 */
|
||||
#define MIN_HASH_VALUE 4
|
||||
#define MAX_HASH_VALUE 127
|
||||
/* maximum key range = 124, duplicates = 8 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
@@ -25,32 +25,32 @@ hash (str, len)
|
||||
{
|
||||
static unsigned char asso_values[] =
|
||||
{
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 30, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 0, 171, 10, 80, 60,
|
||||
15, 20, 85, 45, 0, 30, 171, 0, 40, 35,
|
||||
45, 20, 171, 171, 60, 0, 10, 15, 35, 0,
|
||||
5, 60, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
|
||||
171, 171, 171, 171, 171, 171
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 0, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 5, 128, 0, 15, 50,
|
||||
55, 0, 15, 35, 65, 60, 128, 40, 0, 60,
|
||||
65, 10, 128, 128, 15, 20, 30, 20, 40, 0,
|
||||
20, 15, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128
|
||||
};
|
||||
return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
|
||||
}
|
||||
@@ -65,7 +65,17 @@ in_word_set (str, len)
|
||||
{
|
||||
static struct resword wordlist[] =
|
||||
{
|
||||
{"switch", SWITCH, NORID},
|
||||
{"else", ELSE, NORID},
|
||||
{"while", WHILE, NORID},
|
||||
{"@encode", ENCODE, NORID},
|
||||
{"@private", PRIVATE, NORID},
|
||||
{"@protocol", PROTOCOL, NORID},
|
||||
{"@interface", INTERFACE, NORID},
|
||||
{"__real", REALPART, NORID},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"auto", SCSPEC, RID_AUTO},
|
||||
{"__volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"__attribute", ATTRIBUTE, NORID},
|
||||
{"__asm__", ASM_KEYWORD, NORID},
|
||||
{"__imag__", IMAGPART, NORID},
|
||||
{"__real__", REALPART, NORID},
|
||||
@@ -81,99 +91,83 @@ in_word_set (str, len)
|
||||
{"__restrict__", TYPE_QUAL, RID_RESTRICT},
|
||||
{"__attribute__", ATTRIBUTE, NORID},
|
||||
{"__extension__", EXTENSION, NORID},
|
||||
{"__complex", TYPESPEC, RID_COMPLEX},
|
||||
{"short", TYPESPEC, RID_SHORT},
|
||||
{"struct", STRUCT, NORID},
|
||||
{"__const", TYPE_QUAL, RID_CONST},
|
||||
{"__restrict", TYPE_QUAL, RID_RESTRICT},
|
||||
{"signed", TYPESPEC, RID_SIGNED},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{"while", WHILE, NORID},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"__volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"__attribute", ATTRIBUTE, NORID},
|
||||
{"default", DEFAULT, NORID},
|
||||
{"out", TYPE_QUAL, RID_OUT},
|
||||
{"auto", SCSPEC, RID_AUTO},
|
||||
{"@selector", SELECTOR, NORID},
|
||||
{"@defs", DEFS, NORID},
|
||||
{"@class", CLASS, NORID},
|
||||
{"do", DO, NORID},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED},
|
||||
{"__asm", ASM_KEYWORD, NORID},
|
||||
{"double", TYPESPEC, RID_DOUBLE},
|
||||
{"int", TYPESPEC, RID_INT},
|
||||
{"else", ELSE, NORID},
|
||||
{"inout", TYPE_QUAL, RID_INOUT},
|
||||
{"__real", REALPART, NORID},
|
||||
{"id", OBJECTNAME, RID_ID},
|
||||
{"asm", ASM_KEYWORD, NORID},
|
||||
{"@end", END, NORID},
|
||||
{"@compatibility_alias", ALIAS, NORID},
|
||||
{"__imag", IMAGPART, NORID},
|
||||
{"void", TYPESPEC, RID_VOID},
|
||||
{"@protected", PROTECTED, NORID},
|
||||
{"inline", SCSPEC, RID_INLINE},
|
||||
{"@encode", ENCODE, NORID},
|
||||
{"@private", PRIVATE, NORID},
|
||||
{"enum", ENUM, NORID},
|
||||
{"@interface", INTERFACE, NORID},
|
||||
{"volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"union", UNION, NORID},
|
||||
{"static", SCSPEC, RID_STATIC},
|
||||
{"goto", GOTO, NORID},
|
||||
{"__iterator", SCSPEC, RID_ITERATOR},
|
||||
{"extern", SCSPEC, RID_EXTERN},
|
||||
{"const", TYPE_QUAL, RID_CONST},
|
||||
{"in", TYPE_QUAL, RID_IN},
|
||||
{"restrict", TYPE_QUAL, RID_RESTRICT},
|
||||
{"@protocol", PROTOCOL, NORID},
|
||||
{"case", CASE, NORID},
|
||||
{"break", BREAK, NORID},
|
||||
{"oneway", TYPE_QUAL, RID_ONEWAY},
|
||||
{"continue", CONTINUE, NORID},
|
||||
{"long", TYPESPEC, RID_LONG},
|
||||
{"@implementation", IMPLEMENTATION, NORID},
|
||||
{"sizeof", SIZEOF, NORID},
|
||||
{"__typeof", TYPEOF, NORID},
|
||||
{"__alignof", ALIGNOF, NORID},
|
||||
{"@public", PUBLIC, NORID},
|
||||
{"@selector", SELECTOR, NORID},
|
||||
{"__iterator", SCSPEC, RID_ITERATOR},
|
||||
{"oneway", TYPE_QUAL, RID_ONEWAY},
|
||||
{"for", FOR, NORID},
|
||||
{"__complex", TYPESPEC, RID_COMPLEX},
|
||||
{"byref", TYPE_QUAL, RID_BYREF},
|
||||
{"bycopy", TYPE_QUAL, RID_BYCOPY},
|
||||
{"register", SCSPEC, RID_REGISTER},
|
||||
{"long", TYPESPEC, RID_LONG},
|
||||
{"@compatibility_alias", ALIAS, NORID},
|
||||
{"sizeof", SIZEOF, NORID},
|
||||
{"__const", TYPE_QUAL, RID_CONST},
|
||||
{"out", TYPE_QUAL, RID_OUT},
|
||||
{"__restrict", TYPE_QUAL, RID_RESTRICT},
|
||||
{"__imag", IMAGPART, NORID},
|
||||
{"volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"goto", GOTO, NORID},
|
||||
{"float", TYPESPEC, RID_FLOAT},
|
||||
{"typeof", TYPEOF, NORID},
|
||||
{"typedef", SCSPEC, RID_TYPEDEF},
|
||||
{"return", RETURN, NORID},
|
||||
{"if", IF, NORID},
|
||||
{"restrict", TYPE_QUAL, RID_RESTRICT},
|
||||
{"case", CASE, NORID},
|
||||
{"short", TYPESPEC, RID_SHORT},
|
||||
{"struct", STRUCT, NORID},
|
||||
{"@public", PUBLIC, NORID},
|
||||
{"continue", CONTINUE, NORID},
|
||||
{"@end", END, NORID},
|
||||
{"break", BREAK, NORID},
|
||||
{"double", TYPESPEC, RID_DOUBLE},
|
||||
{"asm", ASM_KEYWORD, NORID},
|
||||
{"enum", ENUM, NORID},
|
||||
{"@protected", PROTECTED, NORID},
|
||||
{"inline", SCSPEC, RID_INLINE},
|
||||
{"do", DO, NORID},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{"char", TYPESPEC, RID_CHAR},
|
||||
{"register", SCSPEC, RID_REGISTER},
|
||||
{"bycopy", TYPE_QUAL, RID_BYCOPY},
|
||||
{"for", FOR, NORID},
|
||||
{"byref", TYPE_QUAL, RID_BYREF}
|
||||
{"__asm", ASM_KEYWORD, NORID},
|
||||
{"extern", SCSPEC, RID_EXTERN},
|
||||
{"static", SCSPEC, RID_STATIC},
|
||||
{"if", IF, NORID},
|
||||
{"@implementation", IMPLEMENTATION, NORID},
|
||||
{"signed", TYPESPEC, RID_SIGNED},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED},
|
||||
{"const", TYPE_QUAL, RID_CONST},
|
||||
{"return", RETURN, NORID},
|
||||
{"union", UNION, NORID},
|
||||
{"switch", SWITCH, NORID},
|
||||
{"default", DEFAULT, NORID},
|
||||
{"int", TYPESPEC, RID_INT},
|
||||
{"inout", TYPE_QUAL, RID_INOUT},
|
||||
{"void", TYPESPEC, RID_VOID},
|
||||
{"id", OBJECTNAME, RID_ID},
|
||||
{"in", TYPE_QUAL, RID_IN}
|
||||
};
|
||||
|
||||
static short lookup[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, 0, 1,
|
||||
-156, -151, -145, -136, -110, -102, 16, 17,
|
||||
18, 19, -69, -2, 20, 21, -1, 22,
|
||||
-1, 23, -72, -3, 24, -1, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, -1,
|
||||
34, 35, -1, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, -74, -2, 45, 46,
|
||||
47, 48, 49, 50, 51, -77, -3, 52,
|
||||
-1, 53, 54, -79, -2, 55, 56, 57,
|
||||
-81, -2, -1, 58, -1, 59, 60, 61,
|
||||
-1, -1, -1, -1, 62, 63, 64, -1,
|
||||
65, 66, 67, 68, -1, 69, 70, -1,
|
||||
-1, 71, -1, 72, 73, 74, 75, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, 76,
|
||||
-1, -1, -1, -1, -1, 77, -1, -1,
|
||||
-1, -1, -1, -1, 78, -1, -1, -1,
|
||||
79, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, 0, 1, -1, 2,
|
||||
3, 4, 5, 6, -1, 7, 8, 9,
|
||||
10, 11, -184, -180, -171, -162, -158, -156,
|
||||
26, 27, 28, -1, 29, 30, 31, 32,
|
||||
-1, 33, 34, 35, 36, -1, 37, 38,
|
||||
39, 40, 41, 42, -1, 43, 44, -1,
|
||||
45, 46, 47, 48, 49, 50, 51, 52,
|
||||
53, 54, 55, 56, 57, 58, -1, 59,
|
||||
60, 61, 62, 63, 64, 65, 66, 67,
|
||||
-59, -2, -62, -3, 68, 69, -64, -2,
|
||||
70, 71, -1, 72, -1, 73, 74, -67,
|
||||
-3, -1, 75, 76, 77, 78, -1, 79,
|
||||
-69, -2, -1, 80, -71, -2, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, 80, -1, 81, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, 82
|
||||
-1, -1, -1, -1, -1, 81, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, 82
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
|
||||
Reference in New Issue
Block a user