root/libparser/asm_res.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. asm_hash
  2. asm_lookup
  3. asm_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=asm_hash --lookup-fn-name=asm_lookup  */
   3 /* Computed positions: -k'3,5' */
   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 SHARP_SHARP     3001
  44 #define SHARP_ASSERT    3002
  45 #define SHARP_DEFINE    3003
  46 #define SHARP_ELIF      3004
  47 #define SHARP_ELSE      3005
  48 #define SHARP_ENDIF     3006
  49 #define SHARP_ERROR     3007
  50 #define SHARP_IDENT     3008
  51 #define SHARP_IF        3009
  52 #define SHARP_IFDEF     3010
  53 #define SHARP_IFNDEF    3011
  54 #define SHARP_IMPORT    3012
  55 #define SHARP_INCLUDE   3013
  56 #define SHARP_INCLUDE_NEXT      3014
  57 #define SHARP_LINE      3015
  58 #define SHARP_PRAGMA    3016
  59 #define SHARP_SCCS      3017
  60 #define SHARP_UNASSERT  3018
  61 #define SHARP_UNDEF     3019
  62 #define SHARP_WARNING   3020
  63 struct keyword { char *name; int token; };
  64 
  65 #define TOTAL_KEYWORDS 20
  66 #define MIN_WORD_LENGTH 2
  67 #define MAX_WORD_LENGTH 13
  68 #define MIN_HASH_VALUE 2
  69 #define MAX_HASH_VALUE 32
  70 /* maximum key range = 31, duplicates = 0 */
  71 
  72 #ifdef __GNUC__
  73 __inline
  74 #else
  75 #ifdef __cplusplus
  76 inline
  77 #endif
  78 #endif
  79 static unsigned int
  80 asm_hash (register const char *str, register unsigned int len)
  81 {
  82   static unsigned char asso_values[] =
  83     {
  84       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  85       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  86       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  87       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  88       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  89       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  90       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  91       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  92       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  93       33, 33, 33, 33, 33, 33, 33, 15, 33, 10,
  94       10,  0, 15,  5, 33,  5, 33, 33,  0,  0,
  95        0, 10, 33, 33, 10,  0, 33, 33, 33, 33,
  96       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  97       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  98       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
  99       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 100       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 101       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 102       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 103       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 104       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 105       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 106       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 107       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 108       33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
 109       33, 33, 33, 33, 33, 33
 110     };
 111   register int hval = len;
 112 
 113   switch (hval)
 114     {
 115       default:
 116         hval += asso_values[(unsigned char)str[4]];
 117       /*FALLTHROUGH*/
 118       case 4:
 119       case 3:
 120         hval += asso_values[(unsigned char)str[2]];
 121       /*FALLTHROUGH*/
 122       case 2:
 123         break;
 124     }
 125   return hval;
 126 }
 127 
 128 #ifdef __GNUC__
 129 __inline
 130 #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 131 __attribute__ ((__gnu_inline__))
 132 #endif
 133 #endif
 134 struct keyword *
 135 asm_lookup (register const char *str, register unsigned int len)
 136 {
 137   static struct keyword wordlist[] =
 138     {
 139       {""}, {""},
 140       {"##", SHARP_SHARP},
 141       {""}, {""},
 142       {"#else", SHARP_ELSE},
 143       {"#undef", SHARP_UNDEF},
 144       {"#assert", SHARP_ASSERT},
 145       {"#include", SHARP_INCLUDE},
 146       {"#unassert", SHARP_UNASSERT},
 147       {"#line", SHARP_LINE},
 148       {"#endif", SHARP_ENDIF},
 149       {"#define", SHARP_DEFINE},
 150       {"#include_next", SHARP_INCLUDE_NEXT},
 151       {""},
 152       {"#sccs", SHARP_SCCS},
 153       {"#ident", SHARP_IDENT},
 154       {"#import", SHARP_IMPORT},
 155       {"#if", SHARP_IF},
 156       {""},
 157       {"#elif", SHARP_ELIF},
 158       {"#ifdef", SHARP_IFDEF},
 159       {"#pragma", SHARP_PRAGMA},
 160       {"#warning", SHARP_WARNING},
 161       {""}, {""},
 162       {"#error", SHARP_ERROR},
 163       {""}, {""}, {""}, {""}, {""},
 164       {"#ifndef", SHARP_IFNDEF}
 165     };
 166 
 167   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
 168     {
 169       register int key = asm_hash (str, len);
 170 
 171       if (key <= MAX_HASH_VALUE && key >= 0)
 172         {
 173           register const char *s = wordlist[key].name;
 174 
 175           if (*str == *s && !strcmp (str + 1, s + 1))
 176             return &wordlist[key];
 177         }
 178     }
 179   return 0;
 180 }
 181 
 182 int
 183 asm_reserved_sharp(const char *str, int len)
 184 {
 185         struct keyword *keyword;
 186 
 187         /* Delete blanks. Ex. ' # define ' => '#define' */
 188         str = strtrim(str, TRIM_ALL, &len);
 189 
 190         keyword = asm_lookup(str, len);
 191         return (keyword && IS_RESERVED_SHARP(keyword->token)) ? keyword->token : 0;
 192 }

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