mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
The makefile now runs mkkeywordhash.c. Keywords that are unused are
omitted from the keyword hash table. (CVS 2045) FossilOrigin-Name: 007aec11333432e08d1091b728773011e9078bc3
This commit is contained in:
101
src/tokenize.c
101
src/tokenize.c
@@ -15,7 +15,7 @@
|
||||
** individual tokens and sends those tokens one-by-one over to the
|
||||
** parser for analysis.
|
||||
**
|
||||
** $Id: tokenize.c,v 1.93 2004/10/31 02:22:49 drh Exp $
|
||||
** $Id: tokenize.c,v 1.94 2004/11/03 03:59:58 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -23,104 +23,17 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
** This function looks up an identifier to determine if it is a
|
||||
** keyword. If it is a keyword, the token code of that keyword is
|
||||
** The sqlite3KeywordCode function looks up an identifier to determine if
|
||||
** it is a keyword. If it is a keyword, the token code of that keyword is
|
||||
** returned. If the input is not a keyword, TK_ID is returned.
|
||||
**
|
||||
** The implementation of this routine was generated by a program,
|
||||
** mkkeywordhash.c, located in the tool subdirectory of the distribution.
|
||||
** The output of the mkkeywordhash.c program was manually cut and pasted
|
||||
** into this file. When the set of keywords for SQLite changes, you
|
||||
** must modify the mkkeywordhash.c program (to add or remove keywords from
|
||||
** the data tables) then rerun that program to regenerate this function.
|
||||
** The output of the mkkeywordhash.c program is written into a file
|
||||
** named keywordhash.c and then included into this source file by
|
||||
** the #include below.
|
||||
*/
|
||||
int sqlite3KeywordCode(const char *z, int n){
|
||||
static const char zText[443] =
|
||||
"ABORTABLEFTEMPORARYAFTERAISELECTHENDATABASEACHECKEYANDEFAULTRANSACTION"
|
||||
"ATURALIKELSEXCEPTRIGGEREFERENCESTATEMENTATTACHAVINGLOBEFOREIGN"
|
||||
"OREPLACEXCLUSIVEXPLAINDEXBEGINITIALLYBETWEENOTNULLIMITBYCASCADE"
|
||||
"FERRABLECASECOLLATECOMMITCONFLICTCONSTRAINTERSECTCREATECROSSDEFERRED"
|
||||
"ELETEDESCDETACHDISTINCTDROPRAGMATCHFAILFROMFULLGROUPDATEIMMEDIATE"
|
||||
"INNERESTRICTINSERTINSTEADINTOFFSETISNULLJOINORDERIGHTOUTEROLLBACK"
|
||||
"PRIMARYROWHENUNIONUNIQUEUSINGVACUUMVALUESVIEWHERE";
|
||||
static const unsigned char aHash[154] = {
|
||||
0, 26, 82, 0, 0, 91, 90, 0, 27, 0, 0, 0, 0,
|
||||
0, 0, 49, 0, 96, 17, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 97, 5, 31, 0, 62, 51, 28, 58, 52, 0, 0, 60,
|
||||
61, 0, 12, 41, 50, 0, 0, 0, 36, 63, 0, 0, 15,
|
||||
0, 0, 0, 39, 0, 42, 0, 0, 0, 0, 78, 0, 34,
|
||||
29, 0, 74, 71, 0, 66, 70, 37, 0, 0, 59, 0, 33,
|
||||
0, 53, 0, 54, 0, 55, 0, 83, 72, 67, 0, 24, 0,
|
||||
0, 79, 80, 84, 0, 0, 0, 0, 0, 0, 0, 75, 0,
|
||||
0, 0, 0, 0, 45, 77, 35, 44, 57, 0, 0, 0, 0,
|
||||
20, 2, 0, 38, 0, 3, 46, 93, 0, 0, 40, 0, 94,
|
||||
0, 43, 87, 98, 0, 0, 0, 0, 0, 81, 0, 0, 0,
|
||||
0, 10, 0, 0, 0, 0, 0, 92, 19, 0, 95,
|
||||
};
|
||||
static const unsigned char aNext[98] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,
|
||||
0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0,
|
||||
0, 0, 0, 0, 0, 18, 22, 0, 0, 0, 0, 0, 0,
|
||||
0, 23, 0, 16, 21, 8, 0, 32, 0, 0, 30, 0, 48,
|
||||
0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0,
|
||||
0, 56, 0, 1, 0, 69, 64, 0, 0, 65, 0, 0, 13,
|
||||
68, 0, 0, 76, 47, 0, 0, 0, 85, 6, 0, 89, 25,
|
||||
4, 73, 88, 86, 0, 0, 0,
|
||||
};
|
||||
static const unsigned char aLen[98] = {
|
||||
5, 5, 4, 4, 9, 2, 5, 5, 6, 4, 3, 8, 2,
|
||||
4, 5, 3, 3, 7, 11, 2, 7, 4, 4, 6, 7, 10,
|
||||
9, 6, 6, 4, 6, 3, 7, 6, 7, 9, 7, 5, 5,
|
||||
9, 3, 7, 3, 7, 4, 5, 2, 7, 3, 10, 4, 7,
|
||||
6, 8, 10, 2, 9, 6, 5, 8, 6, 4, 6, 8, 2,
|
||||
4, 6, 5, 4, 4, 4, 5, 6, 9, 5, 8, 6, 7,
|
||||
4, 2, 6, 3, 6, 4, 5, 5, 5, 8, 7, 3, 4,
|
||||
5, 6, 5, 6, 6, 4, 5,
|
||||
};
|
||||
static const unsigned short int aOffset[98] = {
|
||||
0, 4, 7, 10, 10, 14, 19, 23, 26, 31, 33, 35, 40,
|
||||
42, 44, 48, 51, 53, 59, 68, 69, 75, 78, 81, 86, 92,
|
||||
101, 110, 115, 120, 123, 125, 125, 129, 133, 139, 147, 152, 157,
|
||||
160, 165, 169, 175, 175, 178, 181, 186, 188, 189, 193, 203, 207,
|
||||
214, 220, 228, 235, 235, 244, 250, 255, 262, 268, 272, 278, 279,
|
||||
286, 289, 293, 298, 302, 306, 310, 313, 319, 328, 332, 340, 346,
|
||||
353, 356, 356, 359, 362, 368, 372, 376, 381, 385, 393, 400, 402,
|
||||
406, 411, 417, 422, 428, 434, 437,
|
||||
};
|
||||
static const unsigned char aCode[98] = {
|
||||
TK_ABORT, TK_TABLE, TK_JOIN_KW, TK_TEMP, TK_TEMP,
|
||||
TK_OR, TK_AFTER, TK_RAISE, TK_SELECT, TK_THEN,
|
||||
TK_END, TK_DATABASE, TK_AS, TK_EACH, TK_CHECK,
|
||||
TK_KEY, TK_AND, TK_DEFAULT, TK_TRANSACTION,TK_ON,
|
||||
TK_JOIN_KW, TK_LIKE, TK_ELSE, TK_EXCEPT, TK_TRIGGER,
|
||||
TK_REFERENCES, TK_STATEMENT, TK_ATTACH, TK_HAVING, TK_GLOB,
|
||||
TK_BEFORE, TK_FOR, TK_FOREIGN, TK_IGNORE, TK_REPLACE,
|
||||
TK_EXCLUSIVE, TK_EXPLAIN, TK_INDEX, TK_BEGIN, TK_INITIALLY,
|
||||
TK_ALL, TK_BETWEEN, TK_NOT, TK_NOTNULL, TK_NULL,
|
||||
TK_LIMIT, TK_BY, TK_CASCADE, TK_ASC, TK_DEFERRABLE,
|
||||
TK_CASE, TK_COLLATE, TK_COMMIT, TK_CONFLICT, TK_CONSTRAINT,
|
||||
TK_IN, TK_INTERSECT, TK_CREATE, TK_JOIN_KW, TK_DEFERRED,
|
||||
TK_DELETE, TK_DESC, TK_DETACH, TK_DISTINCT, TK_IS,
|
||||
TK_DROP, TK_PRAGMA, TK_MATCH, TK_FAIL, TK_FROM,
|
||||
TK_JOIN_KW, TK_GROUP, TK_UPDATE, TK_IMMEDIATE, TK_JOIN_KW,
|
||||
TK_RESTRICT, TK_INSERT, TK_INSTEAD, TK_INTO, TK_OF,
|
||||
TK_OFFSET, TK_SET, TK_ISNULL, TK_JOIN, TK_ORDER,
|
||||
TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_PRIMARY, TK_ROW,
|
||||
TK_WHEN, TK_UNION, TK_UNIQUE, TK_USING, TK_VACUUM,
|
||||
TK_VALUES, TK_VIEW, TK_WHERE,
|
||||
};
|
||||
int h, i;
|
||||
if( n<2 ) return TK_ID;
|
||||
h = (sqlite3UpperToLower[((unsigned char*)z)[0]]*5 +
|
||||
sqlite3UpperToLower[((unsigned char*)z)[n-1]]*3 +
|
||||
n) % 154;
|
||||
for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
|
||||
if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
|
||||
return aCode[i];
|
||||
}
|
||||
}
|
||||
return TK_ID;
|
||||
}
|
||||
#include "keywordhash.c"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user