root/libparser/cpp_res.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. cpp_hash
  2. cpp_lookup
  3. cpp_reserved_word
  4. cpp_reserved_sharp

   1 /* ANSI-C code produced by gperf version 3.0.4 */
   2 /* Command-line: gperf --language=ANSI-C --struct-type --slot-name=name --hash-fn-name=cpp_hash --lookup-fn-name=cpp_lookup  */
   3 /* Computed positions: -k'2-4' */
   4 
   5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
   6       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
   7       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
   8       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
   9       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
  10       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
  11       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
  12       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
  13       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
  14       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
  15       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
  16       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
  17       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
  18       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
  19       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
  20       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
  21       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
  22       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
  23       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
  24       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
  25       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
  26       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
  27       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
  28 /* The character set is not based on ISO-646.  */
  29 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
  30 #endif
  31 
  32 
  33 #include "strmake.h"
  34 #define START_VARIABLE  1001
  35 #define START_WORD      2001
  36 #define START_SHARP     3001
  37 #define START_YACC      4001
  38 #define IS_RESERVED_WORD(a)     ((a) >= START_WORD)
  39 #define IS_RESERVED_VARIABLE(a) ((a) >= START_VARIABLE && (a) < START_WORD)
  40 #define IS_RESERVED_SHARP(a)    ((a) >= START_SHARP && (a) < START_YACC)
  41 #define IS_RESERVED_YACC(a)     ((a) >= START_YACC)
  42 
  43 #define CPP_WCOLON      2001
  44 #define CPP___P 2002
  45 #define CPP___ATTRIBUTE__       2003
  46 #define CPP___EXTENSION__       2004
  47 #define CPP___THREAD    2005
  48 #define CPP_ASM 2006
  49 #define CPP_CONST       2007
  50 #define CPP_INLINE      2008
  51 #define CPP_SIGNED      2009
  52 #define CPP_VOLATILE    2010
  53 #define CPP_AUTO        2011
  54 #define CPP_BOOL        2012
  55 #define CPP_BREAK       2013
  56 #define CPP_CASE        2014
  57 #define CPP_CATCH       2015
  58 #define CPP_CHAR        2016
  59 #define CPP_CLASS       2017
  60 #define CPP_CONST_CAST  2018
  61 #define CPP_CONTINUE    2019
  62 #define CPP_DEFAULT     2020
  63 #define CPP_DELETE      2021
  64 #define CPP_DO  2022
  65 #define CPP_DOUBLE      2023
  66 #define CPP_DYNAMIC_CAST        2024
  67 #define CPP_ELSE        2025
  68 #define CPP_ENUM        2026
  69 #define CPP_EXPLICIT    2027
  70 #define CPP_EXPORT      2028
  71 #define CPP_EXTERN      2029
  72 #define CPP_FALSE       2030
  73 #define CPP_FLOAT       2031
  74 #define CPP_FOR 2032
  75 #define CPP_FRIEND      2033
  76 #define CPP_GOTO        2034
  77 #define CPP_IF  2035
  78 #define CPP_INT 2036
  79 #define CPP_LONG        2037
  80 #define CPP_MUTABLE     2038
  81 #define CPP_NAMESPACE   2039
  82 #define CPP_NEW 2040
  83 #define CPP_OPERATOR    2041
  84 #define CPP_PRIVATE     2042
  85 #define CPP_PROTECTED   2043
  86 #define CPP_PUBLIC      2044
  87 #define CPP_REGISTER    2045
  88 #define CPP_REINTERPRET_CAST    2046
  89 #define CPP_RETURN      2047
  90 #define CPP_SHORT       2048
  91 #define CPP_SIZEOF      2049
  92 #define CPP_STATIC      2050
  93 #define CPP_STATIC_CAST 2051
  94 #define CPP_STRUCT      2052
  95 #define CPP_SWITCH      2053
  96 #define CPP_TEMPLATE    2054
  97 #define CPP_THIS        2055
  98 #define CPP_THROW       2056
  99 #define CPP_TRUE        2057
 100 #define CPP_TRY 2058
 101 #define CPP_TYPEDEF     2059
 102 #define CPP_TYPENAME    2060
 103 #define CPP_TYPEID      2061
 104 #define CPP_UNION       2062
 105 #define CPP_UNSIGNED    2063
 106 #define CPP_USING       2064
 107 #define CPP_VIRTUAL     2065
 108 #define CPP_VOID        2066
 109 #define CPP_WCHAR_T     2067
 110 #define CPP_WHILE       2068
 111 #define SHARP_SHARP     3001
 112 #define SHARP_ASSERT    3002
 113 #define SHARP_DEFINE    3003
 114 #define SHARP_ELIF      3004
 115 #define SHARP_ELSE      3005
 116 #define SHARP_ENDIF     3006
 117 #define SHARP_ERROR     3007
 118 #define SHARP_IDENT     3008
 119 #define SHARP_IF        3009
 120 #define SHARP_IFDEF     3010
 121 #define SHARP_IFNDEF    3011
 122 #define SHARP_IMPORT    3012
 123 #define SHARP_INCLUDE   3013
 124 #define SHARP_INCLUDE_NEXT      3014
 125 #define SHARP_LINE      3015
 126 #define SHARP_PRAGMA    3016
 127 #define SHARP_SCCS      3017
 128 #define SHARP_UNASSERT  3018
 129 #define SHARP_UNDEF     3019
 130 #define SHARP_WARNING   3020
 131 struct keyword { char *name; int token; };
 132 
 133 #define TOTAL_KEYWORDS 99
 134 #define MIN_WORD_LENGTH 2
 135 #define MAX_WORD_LENGTH 16
 136 #define MIN_HASH_VALUE 2
 137 #define MAX_HASH_VALUE 242
 138 /* maximum key range = 241, duplicates = 0 */
 139 
 140 #ifdef __GNUC__
 141 __inline
 142 #else
 143 #ifdef __cplusplus
 144 inline
 145 #endif
 146 #endif
 147 static unsigned int
 148 cpp_hash (register const char *str, register unsigned int len)
 149 {
 150   static unsigned char asso_values[] =
 151     {
 152       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 153       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 154       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 155       243, 243, 243, 243, 243,  10, 243, 243, 243, 243,
 156       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 157       243, 243, 243, 243, 243, 243, 243, 243,   0, 243,
 158       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 159       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 160       243,  45, 243, 243, 243, 243, 243, 243, 243, 243,
 161       243, 243, 243, 243, 243,   5, 243,  10,  15,  35,
 162        45,  25,  95,  70,  35,  15,  65, 243,  70,  20,
 163         0,   5,  60,  15,   5,   0,   0,  10,  90,  80,
 164        20,  80,  30,  40, 243, 243, 243, 243, 243, 243,
 165       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 166       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 167       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 168       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 169       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 170       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 171       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 172       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 173       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 174       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 175       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 176       243, 243, 243, 243, 243, 243, 243, 243, 243, 243,
 177       243, 243, 243, 243, 243, 243, 243
 178     };
 179   register int hval = len;
 180 
 181   switch (hval)
 182     {
 183       default:
 184         hval += asso_values[(unsigned char)str[3]];
 185       /*FALLTHROUGH*/
 186       case 3:
 187         hval += asso_values[(unsigned char)str[2]+1];
 188       /*FALLTHROUGH*/
 189       case 2:
 190         hval += asso_values[(unsigned char)str[1]];
 191         break;
 192     }
 193   return hval;
 194 }
 195 
 196 #ifdef __GNUC__
 197 __inline
 198 #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 199 __attribute__ ((__gnu_inline__))
 200 #endif
 201 #endif
 202 struct keyword *
 203 cpp_lookup (register const char *str, register unsigned int len)
 204 {
 205   static struct keyword wordlist[] =
 206     {
 207       {""}, {""},
 208       {"::", CPP_WCOLON},
 209       {"asm", CPP_ASM},
 210       {""}, {""}, {""},
 211       {"do", CPP_DO},
 212       {"for", CPP_FOR},
 213       {""}, {""}, {""},
 214       {"##", SHARP_SHARP},
 215       {"int", CPP_INT},
 216       {""},
 217       {"const", CPP_CONST},
 218       {"struct", CPP_STRUCT},
 219       {"#assert", SHARP_ASSERT},
 220       {"continue", CPP_CONTINUE},
 221       {""},
 222       {"const_cast", CPP_CONST_CAST},
 223       {"static", CPP_STATIC},
 224       {"virtual", CPP_VIRTUAL},
 225       {"unsigned", CPP_UNSIGNED},
 226       {"goto", CPP_GOTO},
 227       {"__asm", CPP_ASM},
 228       {"static_cast", CPP_STATIC_CAST},
 229       {"__asm__", CPP_ASM},
 230       {"__signed", CPP_SIGNED},
 231       {"auto", CPP_AUTO},
 232       {"__signed__", CPP_SIGNED},
 233       {"__attribute", CPP___ATTRIBUTE__},
 234       {""},
 235       {"__attribute__", CPP___ATTRIBUTE__},
 236       {"#unassert", SHARP_UNASSERT},
 237       {"false", CPP_FALSE},
 238       {"#error", SHARP_ERROR},
 239       {"mutable", CPP_MUTABLE},
 240       {"try", CPP_TRY},
 241       {"case", CPP_CASE},
 242       {""},
 243       {"inline", CPP_INLINE},
 244       {""},
 245       {"volatile", CPP_VOLATILE},
 246       {"namespace", CPP_NAMESPACE},
 247       {"throw", CPP_THROW},
 248       {"export", CPP_EXPORT},
 249       {""},
 250       {"new", CPP_NEW},
 251       {""},
 252       {"#else", SHARP_ELSE},
 253       {"return", CPP_RETURN},
 254       {""},
 255       {"__P", CPP___P},
 256       {""}, {""},
 257       {"signed", CPP_SIGNED},
 258       {""},
 259       {"__thread", CPP___THREAD},
 260       {"char", CPP_CHAR},
 261       {"catch", CPP_CATCH},
 262       {"extern", CPP_EXTERN},
 263       {"__const", CPP_CONST},
 264       {"#include", SHARP_INCLUDE},
 265       {"__const__", CPP_CONST},
 266       {"#elif", SHARP_ELIF},
 267       {"#undef", SHARP_UNDEF},
 268       {"wchar_t", CPP_WCHAR_T},
 269       {"#include_next", SHARP_INCLUDE_NEXT},
 270       {""},
 271       {"using", CPP_USING},
 272       {"#ident", SHARP_IDENT},
 273       {""}, {""},
 274       {"protected", CPP_PROTECTED},
 275       {"union", CPP_UNION},
 276       {"delete", CPP_DELETE},
 277       {"#pragma", SHARP_PRAGMA},
 278       {"__inline", CPP_INLINE},
 279       {""},
 280       {"__inline__", CPP_INLINE},
 281       {"#endif", SHARP_ENDIF},
 282       {"#import", SHARP_IMPORT},
 283       {"register", CPP_REGISTER},
 284       {"long", CPP_LONG},
 285       {"#sccs", SHARP_SCCS},
 286       {"sizeof", CPP_SIZEOF},
 287       {""},
 288       {"#if", SHARP_IF},
 289       {""},
 290       {"class", CPP_CLASS},
 291       {""},
 292       {"#ifndef", SHARP_IFNDEF},
 293       {"template", CPP_TEMPLATE},
 294       {""}, {""}, {""},
 295       {"if", CPP_IF},
 296       {""},
 297       {"else", CPP_ELSE},
 298       {"__volatile", CPP_VOLATILE},
 299       {"friend", CPP_FRIEND},
 300       {"__volatile__", CPP_VOLATILE},
 301       {""},
 302       {"this", CPP_THIS},
 303       {"short", CPP_SHORT},
 304       {"reinterpret_cast", CPP_REINTERPRET_CAST},
 305       {"dynamic_cast", CPP_DYNAMIC_CAST},
 306       {"#warning", SHARP_WARNING},
 307       {""}, {""}, {""},
 308       {"default", CPP_DEFAULT},
 309       {"explicit", CPP_EXPLICIT},
 310       {"enum", CPP_ENUM},
 311       {"break", CPP_BREAK},
 312       {"double", CPP_DOUBLE},
 313       {""}, {""},
 314       {"void", CPP_VOID},
 315       {""},
 316       {"public", CPP_PUBLIC},
 317       {""}, {""},
 318       {"true", CPP_TRUE},
 319       {""},
 320       {"typeid", CPP_TYPEID},
 321       {"typedef", CPP_TYPEDEF},
 322       {"typename", CPP_TYPENAME},
 323       {""}, {""}, {""}, {""},
 324       {"__extension__", CPP___EXTENSION__},
 325       {""}, {""},
 326       {"#ifdef", SHARP_IFDEF},
 327       {""}, {""},
 328       {"bool", CPP_BOOL},
 329       {"#line", SHARP_LINE},
 330       {""}, {""}, {""}, {""},
 331       {"float", CPP_FLOAT},
 332       {""}, {""}, {""}, {""}, {""},
 333       {"switch", CPP_SWITCH},
 334       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 335       {""}, {""}, {""}, {""}, {""}, {""},
 336       {"private", CPP_PRIVATE},
 337       {"operator", CPP_OPERATOR},
 338       {""}, {""}, {""}, {""}, {""}, {""},
 339       {"while", CPP_WHILE},
 340       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 341       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 342       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 343       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 344       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 345       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 346       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 347       {""}, {""}, {""},
 348       {"#define", SHARP_DEFINE}
 349     };
 350 
 351   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
 352     {
 353       register int key = cpp_hash (str, len);
 354 
 355       if (key <= MAX_HASH_VALUE && key >= 0)
 356         {
 357           register const char *s = wordlist[key].name;
 358 
 359           if (*str == *s && !strcmp (str + 1, s + 1))
 360             return &wordlist[key];
 361         }
 362     }
 363   return 0;
 364 }
 365 
 366 int
 367 cpp_reserved_word(const char *str, int len)
 368 {
 369         struct keyword *keyword;
 370 
 371         keyword = cpp_lookup(str, len);
 372         return (keyword && IS_RESERVED_WORD(keyword->token)) ? keyword->token : 0;
 373 }
 374 int
 375 cpp_reserved_sharp(const char *str, int len)
 376 {
 377         struct keyword *keyword;
 378 
 379         /* Delete blanks. Ex. ' # define ' => '#define' */
 380         str = strtrim(str, TRIM_ALL, &len);
 381 
 382         keyword = cpp_lookup(str, len);
 383         return (keyword && IS_RESERVED_SHARP(keyword->token)) ? keyword->token : 0;
 384 }

/* [previous][next][first][last][top][bottom][index][help] */