keyword.h 5.63 KB
Newer Older
1 2
/* C code produced by gperf version 2.7 */
/* Command-line: gperf -L C -C -F , 0 -p -t -j1 -i 1 -g -o -N java_keyword -k1,4,$ keyword.gperf  */
Kaveh R. Ghazi committed
3
/* Keyword definition for the GNU compiler for the Java(TM) language.
Anthony Green committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
   Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)

This file is part of GNU CC.

GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

Java and all Java-based marks are trademarks or registered trademarks
of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc.  */

28
struct java_keyword { const char *const name; const int token; };
29 30 31 32 33 34 35
#ifdef __GNUC__
__inline
#endif
static unsigned int hash		PARAMS ((const char *, unsigned int));
#ifdef __GNUC__
__inline
#endif
36
const struct java_keyword *java_keyword	PARAMS ((const char *, unsigned int));
Anthony Green committed
37

38
#define TOTAL_KEYWORDS 52
Anthony Green committed
39 40
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 12
41
#define MIN_HASH_VALUE 7
42 43
#define MAX_HASH_VALUE 85
/* maximum key range = 79, duplicates = 0 */
Anthony Green committed
44 45

#ifdef __GNUC__
Kaveh R. Ghazi committed
46
__inline
Anthony Green committed
47 48 49
#endif
static unsigned int
hash (str, len)
50
     register const char *str;
Kaveh R. Ghazi committed
51
     register unsigned int len;
Anthony Green committed
52
{
53
  static const unsigned char asso_values[] =
Anthony Green committed
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
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86,  1, 34,  3,
       1,  1, 18,  7, 21, 28, 86, 14,  1, 86,
      18, 20, 37, 86, 15,  6,  2,  5, 40, 36,
      86, 36, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
      86, 86, 86, 86, 86, 86
Anthony Green committed
81 82 83 84 85 86
    };
  register int hval = len;

  switch (hval)
    {
      default:
87 88
      case 4:
        hval += asso_values[(unsigned char)str[3]];
Anthony Green committed
89 90 91
      case 3:
      case 2:
      case 1:
Kaveh R. Ghazi committed
92
        hval += asso_values[(unsigned char)str[0]];
Anthony Green committed
93 94
        break;
    }
Kaveh R. Ghazi committed
95
  return hval + asso_values[(unsigned char)str[len - 1]];
Anthony Green committed
96 97 98
}

#ifdef __GNUC__
Kaveh R. Ghazi committed
99
__inline
Anthony Green committed
100
#endif
101
const struct java_keyword *
Anthony Green committed
102
java_keyword (str, len)
103
     register const char *str;
Anthony Green committed
104 105
     register unsigned int len;
{
106
  static const struct java_keyword wordlist[] =
Anthony Green committed
107
    {
108
      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
Kaveh R. Ghazi committed
109
      {"else", ELSE_TK},
110 111
      {"true", TRUE_TK},
      {"case", CASE_TK},
112 113
      {"assert", ASSERT_TK},
      {"default", DEFAULT_TK},
114
      {"", 0},
115
      {"abstract", ABSTRACT_TK},
116
      {"continue", CONTINUE_TK},
Kaveh R. Ghazi committed
117
      {"extends", EXTENDS_TK},
118 119
      {"const", CONST_TK},
      {"static", STATIC_TK},
Kaveh R. Ghazi committed
120
      {"this", THIS_TK},
121
      {"long", LONG_TK},
122
      {"class", CLASS_TK},
123
      {"", 0},
124
      {"synchronized", SYNCHRONIZED_TK},
125 126 127 128
      {"do", DO_TK},
      {"null", NULL_TK},
      {"final", FINAL_TK},
      {"float", FLOAT_TK},
129 130 131
      {"super", SUPER_TK},
      {"short", SHORT_TK},
      {"", 0},
132 133 134
      {"false", FALSE_TK},
      {"transient", TRANSIENT_TK},
      {"catch", CATCH_TK},
135
      {"int", INT_TK},
136 137
      {"throws", THROWS_TK},
      {"switch", SWITCH_TK},
138
      {"for", FOR_TK},
139
      {"char", CHAR_TK},
Kaveh R. Ghazi committed
140 141
      {"", 0},
      {"interface", INTERFACE_TK},
142 143 144 145 146
      {"byte", BYTE_TK},
      {"try", TRY_TK},
      {"double", DOUBLE_TK},
      {"while", WHILE_TK},
      {"return", RETURN_TK},
Kaveh R. Ghazi committed
147
      {"implements", IMPLEMENTS_TK},
148
      {"void", VOID_TK},
149
      {"public", PUBLIC_TK},
150
      {"if", IF_TK},
151 152 153 154 155
      {"protected", PROTECTED_TK},
      {"volatile", VOLATILE_TK},
      {"goto", GOTO_TK},
      {"", 0},
      {"native", NATIVE_TK},
156
      {"break", BREAK_TK},
Kaveh R. Ghazi committed
157
      {"", 0},
158
      {"import", IMPORT_TK},
159 160
      {"new", NEW_TK},
      {"instanceof", INSTANCEOF_TK},
161 162
      {"package", PACKAGE_TK},
      {"boolean", BOOLEAN_TK},
163
      {"", 0},
164
      {"finally", FINALLY_TK},
Kaveh R. Ghazi committed
165
      {"throw", THROW_TK},
166
      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
167
      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
168 169 170
      {"strictfp", STRICT_TK},
      {"", 0}, {"", 0}, {"", 0}, {"", 0}, {"", 0},
      {"private", PRIVATE_TK}
Anthony Green committed
171 172 173 174 175 176 177 178
    };

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

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
179
          register const char *s = wordlist[key].name;
Anthony Green committed
180

Kaveh R. Ghazi committed
181
          if (*str == *s && !strcmp (str + 1, s + 1))
Anthony Green committed
182 183 184 185 186
            return &wordlist[key];
        }
    }
  return 0;
}