mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Initial revision
This commit is contained in:
186
tests/test-3.exp
Normal file
186
tests/test-3.exp
Normal file
@@ -0,0 +1,186 @@
|
||||
/* C code produced by gperf version 2.7 */
|
||||
/* Command-line: ../src/gperf -p -j 1 -o -a -C -g -t -k1,4,$ */
|
||||
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
|
||||
struct resword { char *name; short token; enum rid rid;};
|
||||
|
||||
#define TOTAL_KEYWORDS 71
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 13
|
||||
#define MIN_HASH_VALUE 4
|
||||
#define MAX_HASH_VALUE 147
|
||||
/* maximum key range = 144, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
static unsigned int
|
||||
hash (str, len)
|
||||
register const char *str;
|
||||
register unsigned int len;
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 0, 148, 19, 6, 27,
|
||||
37, 0, 12, 1, 15, 63, 148, 4, 0, 56,
|
||||
20, 15, 42, 148, 31, 5, 26, 39, 32, 10,
|
||||
148, 40, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
|
||||
148, 148, 148, 148, 148, 148
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
case 4:
|
||||
hval += asso_values[(unsigned char)str[3]];
|
||||
case 3:
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#endif
|
||||
const struct resword *
|
||||
in_word_set (str, len)
|
||||
register const char *str;
|
||||
register unsigned int len;
|
||||
{
|
||||
static const struct resword wordlist[] =
|
||||
{
|
||||
{""}, {""}, {""}, {""},
|
||||
{"else", ELSE, NORID,},
|
||||
{""},
|
||||
{"long", TYPESPEC, RID_LONG,},
|
||||
{""}, {""}, {""}, {""},
|
||||
{"__alignof__", ALIGNOF, NORID},
|
||||
{"__asm__", ASM, NORID},
|
||||
{""}, {""},
|
||||
{"while", WHILE, NORID,},
|
||||
{""}, {""}, {""}, {""}, {""},
|
||||
{"__alignof", ALIGNOF, NORID},
|
||||
{"all", ALL, NORID /* Extension */,},
|
||||
{"sizeof", SIZEOF, NORID,},
|
||||
{"__const__", TYPE_QUAL, RID_CONST},
|
||||
{"__volatile", TYPE_QUAL, RID_VOLATILE},
|
||||
{"extern", SCSPEC, RID_EXTERN,},
|
||||
{"__volatile__", TYPE_QUAL, RID_VOLATILE},
|
||||
{"__inline", SCSPEC, RID_INLINE},
|
||||
{"exception", AGGR, RID_EXCEPTION /* Extension */,},
|
||||
{"__inline__", SCSPEC, RID_INLINE},
|
||||
{"case", CASE, NORID,},
|
||||
{"except", EXCEPT, NORID /* Extension */,},
|
||||
{"new", NEW, NORID,},
|
||||
{"break", BREAK, NORID,},
|
||||
{"goto", GOTO, NORID,},
|
||||
{""},
|
||||
{"__attribute", ATTRIBUTE, NORID},
|
||||
{""},
|
||||
{"__attribute__", ATTRIBUTE, NORID},
|
||||
{"this", THIS, NORID,},
|
||||
{"raise", RAISE, NORID /* Extension */,},
|
||||
{"class", AGGR, RID_CLASS,},
|
||||
{"delete", DELETE, NORID,},
|
||||
{"typeof", TYPEOF, NORID,},
|
||||
{"typedef", SCSPEC, RID_TYPEDEF,},
|
||||
{"for", FOR, NORID,},
|
||||
{"raises", RAISES, NORID /* Extension */,},
|
||||
{"__const", TYPE_QUAL, RID_CONST},
|
||||
{"double", TYPESPEC, RID_DOUBLE,},
|
||||
{"__typeof__", TYPEOF, NORID},
|
||||
{""},
|
||||
{"switch", SWITCH, NORID,},
|
||||
{"auto", SCSPEC, RID_AUTO,},
|
||||
{"do", DO, NORID,},
|
||||
{"friend", SCSPEC, RID_FRIEND,},
|
||||
{""},
|
||||
{"reraise", RERAISE, NORID /* Extension */,},
|
||||
{""},
|
||||
{"volatile", TYPE_QUAL, RID_VOLATILE,},
|
||||
{"__typeof", TYPEOF, NORID},
|
||||
{"continue", CONTINUE, NORID,},
|
||||
{"float", TYPESPEC, RID_FLOAT,},
|
||||
{"const", TYPE_QUAL, RID_CONST,},
|
||||
{"static", SCSPEC, RID_STATIC,},
|
||||
{"virtual", SCSPEC, RID_VIRTUAL,},
|
||||
{"__asm", ASM, NORID},
|
||||
{"short", TYPESPEC, RID_SHORT,},
|
||||
{"signed", TYPESPEC, RID_SIGNED,},
|
||||
{"try", TRY, NORID /* Extension */,},
|
||||
{""}, {""}, {""},
|
||||
{"__signed__", TYPESPEC, RID_SIGNED},
|
||||
{"catch", CATCH, NORID,},
|
||||
{"public", PUBLIC, NORID,},
|
||||
{"struct", AGGR, RID_RECORD,},
|
||||
{"if", IF, NORID,},
|
||||
{"asm", ASM, NORID,},
|
||||
{"union", AGGR, RID_UNION,},
|
||||
{""},
|
||||
{"private", PRIVATE, NORID,},
|
||||
{""}, {""}, {""},
|
||||
{"operator", OPERATOR, NORID,},
|
||||
{""}, {""}, {""},
|
||||
{"default", DEFAULT, NORID,},
|
||||
{"dynamic", DYNAMIC, NORID,},
|
||||
{"overload", OVERLOAD, NORID,},
|
||||
{"int", TYPESPEC, RID_INT,},
|
||||
{"char", TYPESPEC, RID_CHAR,},
|
||||
{""}, {""},
|
||||
{"return", RETURN, NORID,},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""},
|
||||
{"__signed", TYPESPEC, RID_SIGNED},
|
||||
{""},
|
||||
{"void", TYPESPEC, RID_VOID,},
|
||||
{""}, {""}, {""},
|
||||
{"protected", PROTECTED, NORID,},
|
||||
{""},
|
||||
{"enum", ENUM, NORID,},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""}, {""}, {""},
|
||||
{"inline", SCSPEC, RID_INLINE,},
|
||||
{"register", SCSPEC, RID_REGISTER,},
|
||||
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
|
||||
{""}, {""}, {""}, {""},
|
||||
{"unsigned", TYPESPEC, RID_UNSIGNED,}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register const char *s = wordlist[key].name;
|
||||
|
||||
if (*str == *s && !strcmp (str + 1, s + 1))
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user