os/persistentdata/persistentstorage/sql/SQLite364/keywordhash.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/***** This file contains automatically generated code ******
sl@0
     2
**
sl@0
     3
** The code in this file has been automatically generated by
sl@0
     4
**
sl@0
     5
**     $Header: /sqlite/sqlite/tool/mkkeywordhash.c,v 1.32 2008/10/06 05:32:19 danielk1977 Exp $
sl@0
     6
**
sl@0
     7
** The code in this file implements a function that determines whether
sl@0
     8
** or not a given identifier is really an SQL keyword.  The same thing
sl@0
     9
** might be implemented more directly using a hand-written hash table.
sl@0
    10
** But by using this automatically generated code, the size of the code
sl@0
    11
** is substantially reduced.  This is important for embedded applications
sl@0
    12
** on platforms with limited memory.
sl@0
    13
*/
sl@0
    14
/* Hash score: 159 */
sl@0
    15
static int keywordCode(const char *z, int n){
sl@0
    16
  /* zText[] encodes 775 bytes of keywords in 521 bytes */
sl@0
    17
  static const char zText[521] =
sl@0
    18
    "REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECTABLE"
sl@0
    19
    "FTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTSCONSTRAINT"
sl@0
    20
    "ERSECTRIGGEREFERENCESUNIQUERYATTACHAVINGROUPDATEMPORARYBEGINNER"
sl@0
    21
    "ENAMEBETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATE"
sl@0
    22
    "DETACHIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESWHENWHERE"
sl@0
    23
    "PLACEAFTERESTRICTANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICT"
sl@0
    24
    "CROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILIMITFROMFULL"
sl@0
    25
    "GLOBYIFINTOFFSETISNULLORDERIGHTOUTEROLLBACKROWUNIONUSINGVACUUM"
sl@0
    26
    "VIEWINITIALLY";
sl@0
    27
  static const unsigned char aHash[127] = {
sl@0
    28
      65,  92, 109,  63,   0,  44,   0,   0,  71,   0,  66,   0,   0,
sl@0
    29
     103,  12,  67,  15,   0, 107,  72, 104, 100,   0,  19,   0,   0,
sl@0
    30
     113,   0, 111,  76,   0,  22,  80,   0,   9,   0,   0,  59,  60,
sl@0
    31
       0,  58,   6,   0,  39,  77,  89,   0, 110,  88,   0,   0,  45,
sl@0
    32
       0,  90,  24,   0,  17,   0, 114,  40,  23,   0,   5,  98,  25,
sl@0
    33
      83,   0,   0, 116,  93,  50, 115,  47,   7,  42,   0,  78,   0,
sl@0
    34
      87,  26,   0,  86,   0,   0,   0,  82,  79,  84,  75,  97,  14,
sl@0
    35
      34,  96,   0,  70,   0,  18,  74,  99,  31,   0, 112,  69, 105,
sl@0
    36
      52,  46,  95,   0,   0,  81, 101,   0, 108,   0,  35,   0,   0,
sl@0
    37
      28,   0,  73,  48,  53,   0,  20,  51,   0,  43,
sl@0
    38
  };
sl@0
    39
  static const unsigned char aNext[116] = {
sl@0
    40
       0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,
sl@0
    41
       0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,
sl@0
    42
       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
sl@0
    43
       0,   0,   3,  38,   0,  32,  21,   0,   0,   0,   0,  29,   0,
sl@0
    44
       0,  37,   0,   0,   0,   1,  55,   0,   0,  56,   0,   0,   0,
sl@0
    45
       0,   0,   0,   0,   0,   0,   0,   0,   0,  30,   0,  16,  33,
sl@0
    46
      10,   0,   0,   0,   0,   0,   0,   0,  11,  61,  68,   0,   8,
sl@0
    47
       0,  91,  85,   0,   0,  94,   0,  49,   0,   0,  64,   0,  41,
sl@0
    48
     102,   0,  27, 106,  36,  62,  54,   0,   0,  57,   0,   0,
sl@0
    49
  };
sl@0
    50
  static const unsigned char aLen[116] = {
sl@0
    51
       7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,
sl@0
    52
       7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,
sl@0
    53
      11,   2,   7,   5,   5,   9,   6,  10,   9,   7,  10,   6,   5,
sl@0
    54
       6,   6,   5,   6,   4,   9,   2,   5,   5,   6,   7,   7,   3,
sl@0
    55
       4,   4,   7,   3,   6,   4,   7,   6,  12,   6,   9,   4,   6,
sl@0
    56
       5,   4,   7,   6,   5,   6,   4,   5,   7,   5,   8,   3,   7,
sl@0
    57
      13,   2,   2,   4,   6,   6,   8,   5,  17,  12,   7,   8,   8,
sl@0
    58
       2,   4,   4,   5,   4,   4,   4,   2,   2,   4,   6,   2,   3,
sl@0
    59
       6,   5,   5,   5,   8,   3,   5,   5,   6,   4,   9,   3,
sl@0
    60
  };
sl@0
    61
  static const unsigned short int aOffset[116] = {
sl@0
    62
       0,   2,   2,   8,   9,  14,  16,  20,  23,  25,  25,  29,  33,
sl@0
    63
      36,  41,  46,  48,  53,  54,  59,  62,  65,  67,  69,  78,  81,
sl@0
    64
      86,  95,  96, 101, 105, 109, 117, 123, 130, 138, 144, 154, 157,
sl@0
    65
     162, 167, 172, 175, 179, 179, 183, 188, 191, 195, 201, 207, 207,
sl@0
    66
     210, 213, 217, 218, 222, 228, 232, 239, 245, 257, 263, 272, 274,
sl@0
    67
     280, 285, 287, 294, 299, 304, 310, 314, 317, 324, 328, 336, 338,
sl@0
    68
     345, 347, 349, 358, 362, 368, 374, 382, 387, 387, 403, 410, 417,
sl@0
    69
     418, 425, 429, 432, 437, 441, 445, 448, 450, 452, 455, 455, 458,
sl@0
    70
     461, 467, 471, 476, 480, 488, 491, 496, 501, 507, 511, 516,
sl@0
    71
  };
sl@0
    72
  static const unsigned char aCode[116] = {
sl@0
    73
    TK_REINDEX,    TK_INDEXED,    TK_INDEX,      TK_DESC,       TK_ESCAPE,     
sl@0
    74
    TK_EACH,       TK_CHECK,      TK_KEY,        TK_BEFORE,     TK_FOREIGN,    
sl@0
    75
    TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    TK_EXPLAIN,    TK_INSTEAD,    
sl@0
    76
    TK_ADD,        TK_DATABASE,   TK_AS,         TK_SELECT,     TK_TABLE,      
sl@0
    77
    TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DEFERRABLE, TK_ELSE,       
sl@0
    78
    TK_EXCEPT,     TK_TRANSACTION,TK_ON,         TK_JOIN_KW,    TK_ALTER,      
sl@0
    79
    TK_RAISE,      TK_EXCLUSIVE,  TK_EXISTS,     TK_CONSTRAINT, TK_INTERSECT,  
sl@0
    80
    TK_TRIGGER,    TK_REFERENCES, TK_UNIQUE,     TK_QUERY,      TK_ATTACH,     
sl@0
    81
    TK_HAVING,     TK_GROUP,      TK_UPDATE,     TK_TEMP,       TK_TEMP,       
sl@0
    82
    TK_OR,         TK_BEGIN,      TK_JOIN_KW,    TK_RENAME,     TK_BETWEEN,    
sl@0
    83
    TK_NOTNULL,    TK_NOT,        TK_NULL,       TK_LIKE_KW,    TK_CASCADE,    
sl@0
    84
    TK_ASC,        TK_DELETE,     TK_CASE,       TK_COLLATE,    TK_CREATE,     
sl@0
    85
    TK_CTIME_KW,   TK_DETACH,     TK_IMMEDIATE,  TK_JOIN,       TK_INSERT,     
sl@0
    86
    TK_MATCH,      TK_PLAN,       TK_ANALYZE,    TK_PRAGMA,     TK_ABORT,      
sl@0
    87
    TK_VALUES,     TK_WHEN,       TK_WHERE,      TK_REPLACE,    TK_AFTER,      
sl@0
    88
    TK_RESTRICT,   TK_AND,        TK_DEFAULT,    TK_AUTOINCR,   TK_TO,         
sl@0
    89
    TK_IN,         TK_CAST,       TK_COLUMNKW,   TK_COMMIT,     TK_CONFLICT,   
sl@0
    90
    TK_JOIN_KW,    TK_CTIME_KW,   TK_CTIME_KW,   TK_PRIMARY,    TK_DEFERRED,   
sl@0
    91
    TK_DISTINCT,   TK_IS,         TK_DROP,       TK_FAIL,       TK_LIMIT,      
sl@0
    92
    TK_FROM,       TK_JOIN_KW,    TK_LIKE_KW,    TK_BY,         TK_IF,         
sl@0
    93
    TK_INTO,       TK_OFFSET,     TK_OF,         TK_SET,        TK_ISNULL,     
sl@0
    94
    TK_ORDER,      TK_JOIN_KW,    TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        
sl@0
    95
    TK_UNION,      TK_USING,      TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  
sl@0
    96
    TK_ALL,        
sl@0
    97
  };
sl@0
    98
  int h, i;
sl@0
    99
  if( n<2 ) return TK_ID;
sl@0
   100
  h = ((charMap(z[0])*4) ^
sl@0
   101
      (charMap(z[n-1])*3) ^
sl@0
   102
      n) % 127;
sl@0
   103
  for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
sl@0
   104
    if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
sl@0
   105
      return aCode[i];
sl@0
   106
    }
sl@0
   107
  }
sl@0
   108
  return TK_ID;
sl@0
   109
}
sl@0
   110
int sqlite3KeywordCode(const unsigned char *z, int n){
sl@0
   111
  return keywordCode((char*)z, n);
sl@0
   112
}