summaryrefslogtreecommitdiff
path: root/apps/gperf/tests/test-1.exp
blob: 5788cf7dfc3480a77dd105ab85241e367cf91729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: ../src/gperf -p -j1 -g -o -t -N is_reserved_word -k1,3,$  */
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf  */ 
struct resword { char *name; short token; enum rid rid; };

#define TOTAL_KEYWORDS 51
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 13
#define MIN_HASH_VALUE 8
#define MAX_HASH_VALUE 82
/* maximum key range = 75, duplicates = 0 */

#ifdef __GNUC__
inline
#endif
static unsigned int
hash (str, len)
     register char *str;
     register int unsigned len;
{
  static unsigned char asso_values[] =
    {
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
     83, 83, 83, 83, 83,  0, 83,  1,  2, 34,
     19,  6, 11, 29,  0, 17, 83,  0, 23, 28,
     26, 30, 31, 83, 15,  1,  0, 28, 13,  4,
     83, 83,  5, 83, 83, 83, 83, 83,
    };
  register int hval = len;

  switch (hval)
    {
      default:
      case 3:
        hval += asso_values[str[2]];
      case 2:
      case 1:
        hval += asso_values[str[0]];
        break;
    }
  return hval + asso_values[str[len - 1]];
}

#ifdef __GNUC__
inline
#endif
struct resword *
is_reserved_word (str, len)
     register char *str;
     register unsigned int len;
{
  static struct resword wordlist[] =
    {
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"__asm__",  ASM, NORID},
      {"",}, 
      {"__typeof__",  TYPEOF, NORID},
      {"__signed__",  TYPESPEC, RID_SIGNED},
      {"__alignof__",  ALIGNOF, NORID},
      {"break",  BREAK, NORID},
      {"__attribute__",  ATTRIBUTE, NORID},
      {"",}, {"",}, 
      {"else",  ELSE, NORID},
      {"__attribute",  ATTRIBUTE, NORID},
      {"__typeof",  TYPEOF, NORID},
      {"int",  TYPESPEC, RID_INT},
      {"__alignof",  ALIGNOF, NORID},
      {"struct",  STRUCT, NORID},
      {"sizeof",  SIZEOF, NORID},
      {"switch",  SWITCH, NORID},
      {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
      {"",}, 
      {"__inline__",  SCSPEC, RID_INLINE},
      {"__signed",  TYPESPEC, RID_SIGNED},
      {"__volatile",  TYPE_QUAL, RID_VOLATILE},
      {"if",  IF, NORID},
      {"__inline",  SCSPEC, RID_INLINE},
      {"while",  WHILE, NORID},
      {"",}, 
      {"__asm",  ASM, NORID},
      {"auto",  SCSPEC, RID_AUTO},
      {"short",  TYPESPEC, RID_SHORT},
      {"default",  DEFAULT, NORID},
      {"extern",  SCSPEC, RID_EXTERN},
      {"",}, {"",}, 
      {"__const",  TYPE_QUAL, RID_CONST},
      {"static",  SCSPEC, RID_STATIC},
      {"__const__",  TYPE_QUAL, RID_CONST},
      {"for",  FOR, NORID},
      {"case",  CASE, NORID},
      {"float",  TYPESPEC, RID_FLOAT},
      {"return",  RETURN, NORID},
      {"typeof",  TYPEOF, NORID},
      {"typedef",  SCSPEC, RID_TYPEDEF},
      {"volatile",  TYPE_QUAL, RID_VOLATILE},
      {"do",  DO, NORID},
      {"inline",  SCSPEC, RID_INLINE},
      {"void",  TYPESPEC, RID_VOID},
      {"char",  TYPESPEC, RID_CHAR},
      {"signed",  TYPESPEC, RID_SIGNED},
      {"unsigned",  TYPESPEC, RID_UNSIGNED},
      {"",}, {"",}, 
      {"double",  TYPESPEC, RID_DOUBLE},
      {"asm",  ASM, NORID},
      {"",}, {"",}, 
      {"goto",  GOTO, NORID},
      {"",}, 
      {"const",  TYPE_QUAL, RID_CONST},
      {"enum",  ENUM, NORID},
      {"register",  SCSPEC, RID_REGISTER},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"continue",  CONTINUE, NORID},
      {"",}, 
      {"union",  UNION, NORID},
      {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"long",  TYPESPEC, RID_LONG},
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register char *s = wordlist[key].name;

          if (*s == *str && !strcmp (str + 1, s + 1))
            return &wordlist[key];
        }
    }
  return 0;
}