📄 parse.c
字号:
#include "eDbInit.h"#include "parse.h"#ifndef INTERFACE
#define INTERFACE 1
#endif
#define yyCode unsigned char
#define YYNOCODE 96
#define yyAction unsigned short int
#define eDbParserToken Token
typedef union {
eDbParserToken yy0;
IdExprList * yy5;
IdList * yy20;
ExprList * yy64;
Token yy68;
Expr * yy82;
IdList* yy90;
SrcList * yy95;
int yy122;
int yy191;
} yyMinor;
#define YYSTACKDEPTH 100
#define eDbParserARG_SDECL Parser *pParse
#define eDbParserARG_PDECL Parser *pParse
#define eDbParserARG_FETCH Parser *pParse = yypParser->pParse
#define eDbParserARG_STORE yypParser->pParse = pParse
#define YYNSTATE 169
#define YYNRULE 90
#define YYERRORSYMBOL 58
#define YYERRSYMDT yy191
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
static yyAction yy_action[] = {
/* 0 */ 75, 71, 92, 90, 84, 88, 82, 86, 18, 19,
/* 10 */ 94, 96, 18, 19, 75, 71, 92, 90, 84, 88,
/* 20 */ 82, 86, 18, 19, 94, 96, 47, 35, 36, 37,
/* 30 */ 74, 23, 24, 152, 75, 71, 92, 90, 84, 88,
/* 40 */ 82, 86, 203, 152, 94, 96, 165, 34, 9, 38,
/* 50 */ 13, 105, 139, 140, 75, 71, 92, 90, 84, 88,
/* 60 */ 82, 86, 10, 11, 94, 96, 101, 35, 36, 37,
/* 70 */ 198, 71, 92, 90, 84, 88, 82, 86, 72, 100,
/* 80 */ 94, 96, 39, 212, 92, 90, 84, 88, 82, 86,
/* 90 */ 102, 103, 94, 96, 76, 65, 66, 37, 80, 40,
/* 100 */ 51, 72, 212, 28, 30, 54, 207, 117, 85, 59,
/* 110 */ 27, 76, 106, 154, 162, 112, 110, 124, 65, 66,
/* 120 */ 37, 80, 200, 79, 53, 141, 163, 84, 88, 82,
/* 130 */ 86, 199, 161, 94, 96, 110, 21, 55, 135, 14,
/* 140 */ 160, 33, 20, 68, 69, 34, 79, 12, 13, 3,
/* 150 */ 5, 6, 76, 18, 19, 260, 1, 2, 76, 235,
/* 160 */ 57, 76, 154, 154, 76, 67, 99, 150, 236, 76,
/* 170 */ 76, 76, 70, 136, 76, 73, 76, 52, 149, 49,
/* 180 */ 50, 157, 155, 144, 81, 83, 156, 48, 137, 158,
/* 190 */ 87, 76, 166, 167, 126, 110, 62, 76, 42, 159,
/* 200 */ 76, 121, 61, 76, 133, 97, 128, 76, 76, 94,
/* 210 */ 96, 123, 63, 76, 120, 76, 127, 95, 115, 64,
/* 220 */ 76, 111, 98, 60, 58, 45, 185, 91, 46, 89,
/* 230 */ 186, 44, 43, 197, 93, 204, 41, 175, 56, 119,
/* 240 */ 104, 4, 118, 116, 78, 31, 214, 114, 170, 153,
/* 250 */ 113, 77, 148, 8, 151, 147, 176, 108, 138, 107,
/* 260 */ 134, 217, 29, 143, 168, 145, 208, 130, 132, 171,
/* 270 */ 169, 164, 17, 32, 131, 146, 172, 16, 22, 125,
/* 280 */ 15, 142, 129, 174, 26, 25, 7, 109, 211, 187,
/* 290 */ 187, 122,
};
static yyCode yy_lookahead[] = {
/* 0 */ 17, 18, 19, 20, 21, 22, 23, 24, 29, 30,
/* 10 */ 27, 28, 29, 30, 17, 18, 19, 20, 21, 22,
/* 20 */ 23, 24, 29, 30, 27, 28, 12, 29, 30, 31,
/* 30 */ 13, 13, 14, 50, 17, 18, 19, 20, 21, 22,
/* 40 */ 23, 24, 9, 50, 27, 28, 48, 66, 67, 68,
/* 50 */ 69, 66, 55, 56, 17, 18, 19, 20, 21, 22,
/* 60 */ 23, 24, 13, 14, 27, 28, 81, 29, 30, 31,
/* 70 */ 9, 18, 19, 20, 21, 22, 23, 24, 12, 12,
/* 80 */ 27, 28, 10, 9, 19, 20, 21, 22, 23, 24,
/* 90 */ 13, 14, 27, 28, 66, 29, 30, 31, 32, 11,
/* 100 */ 66, 12, 9, 25, 26, 33, 39, 14, 80, 37,
/* 110 */ 32, 66, 40, 72, 48, 43, 42, 45, 29, 30,
/* 120 */ 31, 32, 34, 57, 36, 80, 66, 21, 22, 23,
/* 130 */ 24, 34, 91, 27, 28, 42, 12, 11, 93, 70,
/* 140 */ 80, 72, 73, 13, 14, 66, 57, 68, 69, 62,
/* 150 */ 63, 64, 66, 29, 30, 59, 60, 61, 66, 9,
/* 160 */ 34, 66, 72, 72, 66, 79, 80, 14, 9, 66,
/* 170 */ 66, 66, 80, 14, 66, 80, 66, 66, 80, 13,
/* 180 */ 14, 91, 91, 80, 80, 80, 66, 76, 80, 14,
/* 190 */ 80, 66, 46, 47, 85, 42, 78, 66, 75, 90,
/* 200 */ 66, 66, 66, 66, 54, 80, 86, 66, 66, 27,
/* 210 */ 28, 80, 39, 66, 80, 66, 41, 80, 83, 12,
/* 220 */ 66, 80, 80, 38, 66, 35, 49, 80, 66, 80,
/* 230 */ 49, 66, 34, 9, 80, 9, 66, 12, 66, 19,
/* 240 */ 66, 9, 66, 82, 66, 32, 9, 44, 0, 66,
/* 250 */ 66, 49, 14, 12, 66, 92, 9, 66, 94, 41,
/* 260 */ 52, 9, 32, 53, 9, 51, 39, 87, 89, 0,
/* 270 */ 0, 49, 16, 72, 88, 52, 9, 15, 74, 84,
/* 280 */ 71, 94, 82, 9, 13, 74, 65, 82, 9, 95,
/* 290 */ 95, 19,
};
#define YY_SHIFT_USE_DFLT (-22)
static short yy_shift_ofst[] = {
/* 0 */ 255, 270, 72, 232, 248, 267, 241, 274, 38, 49,
/* 10 */ 247, 38, -22, -21, 262, -22, 256, -22, -22, -22,
/* 20 */ 124, 78, 18, -22, 78, 271, -22, -22, 230, -22,
/* 30 */ 213, -22, -22, -22, -22, -22, -22, -22, -22, 88,
/* 40 */ 38, 225, 198, 38, 190, 38, 14, 38, 166, 61,
/* 50 */ 38, -22, -22, 97, 126, 38, 224, 38, 33, 185,
/* 60 */ 38, 67, 173, 207, 89, 177, 181, 130, 226, 89,
/* 70 */ 37, 89, 89, 17, -22, 89, 202, 38, -22, -22,
/* 80 */ -22, 53, 89, 182, 89, 182, 89, 182, 89, 182,
/* 90 */ 89, 106, 89, 106, 89, -22, 89, -22, 65, 37,
/* 100 */ 38, 77, 227, 38, -22, -22, 218, 38, 74, 279,
/* 110 */ 89, 37, 38, 203, 38, 93, 237, 38, 220, 89,
/* 120 */ 37, 272, 89, 37, 146, -22, 175, 38, 153, 214,
/* 130 */ 210, 150, 252, 208, 89, 159, 89, -3, -22, -22,
/* 140 */ -22, -3, -22, 89, 37, 223, -22, 238, 89, 37,
/* 150 */ 38, -7, 38, -22, -22, -22, -7, -22, -22, 66,
/* 160 */ -17, -22, -22, 222, -2, -22, -22, -22, 269,
};
#define YY_REDUCE_USE_DFLT (-20)
static short yy_reduce_ofst[] = {
/* 0 */ 96, -20, 87, -20, -20, -20, 221, -20, -19, -20,
/* 10 */ -20, 79, -20, 69, 209, -20, -20, -20, -20, -20,
/* 20 */ 201, 204, -20, -20, 211, -20, -20, -20, -20, -20,
/* 30 */ -20, -20, -20, -20, -20, -20, -20, -20, -20, 123,
/* 40 */ 170, -20, -20, 165, -20, 162, -20, 111, -20, -20,
/* 50 */ 34, -20, -20, -20, -20, 172, -20, 158, -20, -20,
/* 60 */ 136, 118, -20, -20, 86, -20, -20, -20, -20, 92,
/* 70 */ -20, 142, 95, -20, -20, 104, -20, 178, -20, -20,
/* 80 */ -20, -20, 105, -20, 28, -20, 110, -20, 149, -20,
/* 90 */ 147, -20, 154, -20, 137, -20, 125, -20, -20, -20,
/* 100 */ -15, -20, -20, 174, -20, -20, -20, 191, 205, -20,
/* 110 */ 141, -20, 184, -20, 135, 161, -20, 176, -20, 134,
/* 120 */ -20, -20, 131, -20, 195, 109, -20, 120, 200, 180,
/* 130 */ 186, 179, -20, -20, 45, -20, 108, 164, -20, -20,
/* 140 */ -20, 187, -20, 103, -20, -20, 163, -20, 98, -20,
/* 150 */ 188, 91, 183, -20, -20, -20, 90, -20, -20, 60,
/* 160 */ 41, -20, -20, -20, 178, -20, -20, -20, -20,
};
static yyAction yy_default[] = {
/* 0 */ 173, 259, 259, 259, 259, 259, 259, 259, 259, 259,
/* 10 */ 259, 259, 177, 188, 182, 179, 259, 181, 183, 184,
/* 20 */ 189, 259, 259, 190, 259, 259, 191, 194, 259, 195,
/* 30 */ 259, 196, 193, 192, 180, 185, 186, 187, 178, 259,
/* 40 */ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
/* 50 */ 259, 201, 202, 259, 259, 259, 259, 259, 259, 259,
/* 60 */ 259, 259, 259, 259, 259, 245, 247, 259, 259, 259,
/* 70 */ 205, 259, 259, 259, 242, 259, 259, 259, 243, 244,
/* 80 */ 246, 249, 259, 250, 259, 251, 259, 252, 259, 253,
/* 90 */ 259, 254, 259, 255, 259, 256, 259, 257, 248, 206,
/* 100 */ 259, 259, 259, 259, 209, 210, 259, 259, 259, 259,
/* 110 */ 259, 213, 259, 259, 259, 259, 259, 259, 259, 259,
/* 120 */ 215, 259, 259, 216, 220, 222, 259, 259, 212, 231,
/* 130 */ 233, 259, 259, 259, 259, 259, 259, 241, 237, 239,
/* 140 */ 240, 241, 238, 259, 234, 259, 259, 232, 259, 258,
/* 150 */ 259, 228, 259, 226, 227, 229, 228, 230, 221, 259,
/* 160 */ 228, 223, 224, 259, 259, 225, 218, 219, 259,
};
#define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0]))
#ifdef YYFALLBACK
static const yyCode yyFallback[] = {
};
#endif /* YYFALLBACK */
struct yyStackEntry {
int stateno; /* The state-number */
int major; /* The major token value. */
yyMinor minor; /* The user-supplied minor token value*/
};
typedef struct yyStackEntry yyStackEntry;
struct yyParser {
int yyidx; /* Index of top element in stack */
int yyerrcnt; /* Shifts left before out of the error */
eDbParserARG_SDECL; /* A place to hold %extra_argument */
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
};
typedef struct yyParser yyParser;
#ifndef NDEBUG
static FILE *yyTraceFILE = 0;
static char *yyTracePrompt = 0;
#endif /* NDEBUG */
#ifndef NDEBUG
void eDbParserTrace(FILE *TraceFILE, char *zTracePrompt){
yyTraceFILE = TraceFILE;
yyTracePrompt = zTracePrompt;
if( yyTraceFILE==0 ) yyTracePrompt = 0;
else if( yyTracePrompt==0 ) yyTraceFILE = 0;
}
#endif /* NDEBUG */
#ifndef NDEBUG
static const char *yyTokenName[] = {
"$", "END_OF_FILE", "ILLEGAL", "SPACE",
"UNCLOSED_STRING", "COMMENT", "FUNCTION", "COLUMN",
"AGG_FUNCTION", "SEMI", "CREATE", "TABLE",
"LP", "RP", "COMMA", "PRIMARY",
"KEY", "OR", "AND", "EQ",
"NE", "GT", "GE", "LT",
"LE", "PLUS", "MINUS", "LSHIFT",
"RSHIFT", "ID", "STRING", "JOIN_KW",
"INTEGER", "DROP", "INDEX", "ON",
"UNIQUE", "INSERT", "INTO", "VALUES",
"DELETE", "FROM", "WHERE", "UPDATE",
"SET", "SELECT", "DISTINCT", "ALL",
"STAR", "DOT", "AS", "GROUP",
"BY", "HAVING", "ORDER", "ASC",
"DESC", "NULL", "error", "input",
"ecmd", "explain", "cmdx", "cmd",
"create_table", "create_table_args", "nm", "columnlist",
"column", "columnid", "type", "ccons",
"ids", "typename", "signed", "uniqueflag",
"idxlist", "idxitem", "inscollist_opt", "itemlist",
"expr", "inscollist", "where_opt", "setlist",
"distinct", "selcollist", "seltablist", "group_opt",
"having_opt", "orderby_opt", "sclp", "as",
"exprlist", "sortlist", "sortorder",
};
#endif /* NDEBUG */
#ifndef NDEBUG
static const char *yyRuleName[] = {
/* 0 */ "input ::= ecmd",
/* 1 */ "ecmd ::= explain cmdx SEMI",
/* 2 */ "ecmd ::= SEMI",
/* 3 */ "cmdx ::= cmd",
/* 4 */ "explain ::=",
/* 5 */ "cmd ::= create_table create_table_args",
/* 6 */ "create_table ::= CREATE TABLE nm",
/* 7 */ "create_table_args ::= LP columnlist RP",
/* 8 */ "columnlist ::= columnlist COMMA column",
/* 9 */ "columnlist ::= column",
/* 10 */ "column ::= columnid type ccons",
/* 11 */ "columnid ::= nm",
/* 12 */ "ccons ::= PRIMARY KEY",
/* 13 */ "ccons ::=",
/* 14 */ "ids ::= ID",
/* 15 */ "ids ::= STRING",
/* 16 */ "nm ::= ID",
/* 17 */ "nm ::= STRING",
/* 18 */ "nm ::= JOIN_KW",
/* 19 */ "type ::=",
/* 20 */ "type ::= typename",
/* 21 */ "type ::= typename LP signed RP",
/* 22 */ "type ::= typename LP signed COMMA signed RP",
/* 23 */ "typename ::= ids",
/* 24 */ "typename ::= typename ids",
/* 25 */ "signed ::= INTEGER",
/* 26 */ "signed ::= PLUS INTEGER",
/* 27 */ "signed ::= MINUS INTEGER",
/* 28 */ "cmd ::= DROP TABLE nm",
/* 29 */ "cmd ::= CREATE uniqueflag INDEX nm ON nm LP idxlist RP",
/* 30 */ "uniqueflag ::= UNIQUE",
/* 31 */ "uniqueflag ::=",
/* 32 */ "idxlist ::= idxlist COMMA nm",
/* 33 */ "idxlist ::= nm",
/* 34 */ "cmd ::= DROP INDEX nm",
/* 35 */ "cmd ::= INSERT INTO nm inscollist_opt VALUES LP itemlist RP",
/* 36 */ "itemlist ::= itemlist COMMA expr",
/* 37 */ "itemlist ::= expr",
/* 38 */ "inscollist_opt ::=",
/* 39 */ "inscollist_opt ::= LP inscollist RP",
/* 40 */ "inscollist ::= inscollist COMMA nm",
/* 41 */ "inscollist ::= nm",
/* 42 */ "cmd ::= DELETE FROM nm where_opt",
/* 43 */ "where_opt ::=",
/* 44 */ "where_opt ::= WHERE expr",
/* 45 */ "cmd ::= UPDATE nm SET setlist where_opt",
/* 46 */ "setlist ::= setlist COMMA nm EQ expr",
/* 47 */ "setlist ::= nm EQ expr",
/* 48 */ "cmd ::= SELECT distinct selcollist FROM seltablist where_opt group_opt having_opt orderby_opt",
/* 49 */ "distinct ::= DISTINCT",
/* 50 */ "distinct ::= ALL",
/* 51 */ "distinct ::=",
/* 52 */ "sclp ::= selcollist COMMA",
/* 53 */ "sclp ::=",
/* 54 */ "selcollist ::= sclp expr as",
/* 55 */ "selcollist ::= sclp STAR",
/* 56 */ "selcollist ::= sclp nm DOT STAR",
/* 57 */ "as ::= AS nm",
/* 58 */ "as ::= ids",
/* 59 */ "as ::=",
/* 60 */ "seltablist ::= seltablist COMMA nm as",
/* 61 */ "seltablist ::= nm as",
/* 62 */ "group_opt ::=",
/* 63 */ "group_opt ::= GROUP BY exprlist",
/* 64 */ "having_opt ::=",
/* 65 */ "having_opt ::= HAVING expr",
/* 66 */ "orderby_opt ::=",
/* 67 */ "orderby_opt ::= ORDER BY sortlist",
/* 68 */ "sortlist ::= sortlist COMMA expr sortorder",
/* 69 */ "sortlist ::= expr sortorder",
/* 70 */ "sortorder ::= ASC",
/* 71 */ "sortorder ::= DESC",
/* 72 */ "sortorder ::=",
/* 73 */ "expr ::= LP expr RP",
/* 74 */ "expr ::= nm DOT nm",
/* 75 */ "expr ::= NULL",
/* 76 */ "expr ::= ID",
/* 77 */ "expr ::= INTEGER",
/* 78 */ "expr ::= STRING",
/* 79 */ "expr ::= expr AND expr",
/* 80 */ "expr ::= expr OR expr",
/* 81 */ "expr ::= expr LT expr",
/* 82 */ "expr ::= expr GT expr",
/* 83 */ "expr ::= expr LE expr",
/* 84 */ "expr ::= expr GE expr",
/* 85 */ "expr ::= expr NE expr",
/* 86 */ "expr ::= expr EQ expr",
/* 87 */ "expr ::= expr LSHIFT expr",
/* 88 */ "expr ::= expr RSHIFT expr",
/* 89 */ "exprlist ::= exprlist COMMA expr",
};
#endif /* NDEBUG */
const char *eDbParserTokenName(int tokenType){
#ifndef NDEBUG
if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){
return yyTokenName[tokenType];
}else{
return "Unknown";
}
#else
return "";
#endif
}
void *eDbParserAlloc(void *(*mallocProc)(size_t)){
yyParser *pParser;
pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
if( pParser ){
pParser->yyidx = -1;
}
return pParser;
}
static void yy_destructor(yyCode yymajor, yyMinor *yypminor){
switch( yymajor ){
case 76:
eDbIdListDelete((yypminor->yy90)); break;
case 78:
eDbIdListDelete((yypminor->yy20)); break;
case 79:
eDbExprListDelete((yypminor->yy64)); break;
case 80:
eDbExprDelete((yypminor->yy82)); break;
case 81:
eDbIdListDelete((yypminor->yy20)); break;
case 82:
eDbExprDelete((yypminor->yy82)); break;
case 83:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -