Below is the file 'sqlite/parse.c' from this revision. You can also download the file.
/* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> #include "sqliteInt.h" #include "parse.h" #line 54 "parse.y" /* ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. */ struct LimitVal { Expr *pLimit; /* The LIMIT expression. NULL if there is no limit */ Expr *pOffset; /* The OFFSET expression. NULL if there is none */ }; /* ** An instance of this structure is used to store the LIKE, ** GLOB, NOT LIKE, and NOT GLOB operators. */ struct LikeOp { Token operator; /* "like" or "glob" or "regexp" */ int not; /* True if the NOT keyword is present */ }; /* ** An instance of the following structure describes the event of a ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, ** TK_DELETE, or TK_INSTEAD. If the event is of the form ** ** UPDATE ON (a,b,c) ** ** Then the "b" IdList records the list "a,b,c". */ struct TrigEvent { int a; IdList * b; }; /* ** An instance of this structure holds the ATTACH key and the key type. */ struct AttachKey { int type; Token key; }; #line 48 "parse.c" /* Next is all token values, in a form suitable for use by makeheaders. ** This section will be null unless lemon is run with the -m switch. */ /* ** These constants (all generated automatically by the parser generator) ** specify the various kinds of tokens (terminals) that the parser ** understands. ** ** Each symbol here is a terminal symbol in the grammar. */ /* Make sure the INTERFACE macro is defined. */ #ifndef INTERFACE # define INTERFACE 1 #endif /* The next thing included is series of defines which control ** various aspects of the generated parser. ** YYCODETYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 terminals ** and nonterminals. "int" is used otherwise. ** YYNOCODE is a number of type YYCODETYPE which corresponds ** to no legal terminal or nonterminal number. This ** number is used to fill in empty slots of the hash ** table. ** YYFALLBACK If defined, this indicates that one or more tokens ** have fall-back values which should be used if the ** original value of the token will not parse. ** YYACTIONTYPE is the data type used for storing terminal ** and nonterminal numbers. "unsigned char" is ** used if there are fewer than 250 rules and ** states combined. "int" is used otherwise. ** sqlite3ParserTOKENTYPE is the data type used for minor tokens given ** directly to the parser from the tokenizer. ** YYMINORTYPE is the data type used for all minor tokens. ** This is typically a union of many types, one of ** which is sqlite3ParserTOKENTYPE. The entry in the union ** for base tokens is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. */ #define YYCODETYPE unsigned char #define YYNOCODE 247 #define YYACTIONTYPE unsigned short int #define sqlite3ParserTOKENTYPE Token typedef union { sqlite3ParserTOKENTYPE yy0; struct TrigEvent yy30; Expr* yy62; SrcList* yy151; Token yy198; struct LimitVal yy220; struct LikeOp yy222; IdList* yy240; int yy280; struct {int value; int mask;} yy359; TriggerStep* yy360; struct AttachKey yy361; Select* yy375; ExprList* yy418; int yy493; } YYMINORTYPE; #define YYSTACKDEPTH 100 #define sqlite3ParserARG_SDECL Parse *pParse; #define sqlite3ParserARG_PDECL ,Parse *pParse #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse #define sqlite3ParserARG_STORE yypParser->pParse = pParse #define YYNSTATE 581 #define YYNRULE 311 #define YYERRORSYMBOL 146 #define YYERRSYMDT yy493 #define YYFALLBACK 1 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) /* Next are that tables used to determine what action to take based on the ** current state and lookahead token. These tables are used to implement ** functions that take a state number and lookahead value and return an ** action integer. ** ** Suppose the action integer is N. Then the action is determined as ** follows ** ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead ** token onto the stack and goto state N. ** ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. ** ** N == YYNSTATE+YYNRULE A syntax error has occurred. ** ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. ** ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused ** slots in the yy_action[] table. ** ** The action table is constructed as a single large table named yy_action[]. ** Given state S and lookahead X, the action is computed as ** ** yy_action[ yy_shift_ofst[S] + X ] ** ** If the index value yy_shift_ofst[S]+X is out of range or if the value ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table ** and that yy_default[S] should be used instead. ** ** The formula above is for computing the action when the lookahead is ** a terminal symbol. If the lookahead is a non-terminal (as occurs after ** a reduce action) then the yy_reduce_ofst[] array is used in place of ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of ** YY_SHIFT_USE_DFLT. ** ** The following are the tables generated in this section: ** ** yy_action[] A single table containing all actions. ** yy_lookahead[] A table containing the lookahead for each entry in ** yy_action. Used to detect hash collisions. ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { /* 0 */ 286, 584, 113, 140, 142, 138, 144, 581, 150, 152, /* 10 */ 154, 156, 158, 160, 162, 164, 166, 168, 3, 577, /* 20 */ 740, 170, 178, 150, 152, 154, 156, 158, 160, 162, /* 30 */ 164, 166, 168, 158, 160, 162, 164, 166, 168, 135, /* 40 */ 97, 171, 181, 186, 191, 180, 185, 146, 148, 140, /* 50 */ 142, 138, 144, 51, 150, 152, 154, 156, 158, 160, /* 60 */ 162, 164, 166, 168, 16, 17, 18, 114, 7, 248, /* 70 */ 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, /* 80 */ 13, 37, 362, 40, 59, 67, 69, 326, 357, 170, /* 90 */ 6, 5, 331, 95, 364, 359, 25, 374, 258, 893, /* 100 */ 1, 580, 514, 13, 4, 575, 33, 135, 97, 171, /* 110 */ 181, 186, 191, 180, 185, 146, 148, 140, 142, 138, /* 120 */ 144, 9, 150, 152, 154, 156, 158, 160, 162, 164, /* 130 */ 166, 168, 374, 136, 592, 80, 112, 99, 269, 34, /* 140 */ 32, 33, 132, 373, 115, 14, 15, 378, 333, 99, /* 150 */ 380, 387, 392, 13, 367, 370, 194, 170, 78, 500, /* 160 */ 525, 315, 395, 369, 375, 408, 10, 98, 14, 15, /* 170 */ 78, 200, 286, 864, 113, 135, 97, 171, 181, 186, /* 180 */ 191, 180, 185, 146, 148, 140, 142, 138, 144, 80, /* 190 */ 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, /* 200 */ 104, 105, 106, 661, 496, 376, 374, 170, 467, 13, /* 210 */ 2, 28, 237, 4, 409, 33, 3, 577, 14, 15, /* 220 */ 51, 132, 133, 115, 241, 135, 97, 171, 181, 186, /* 230 */ 191, 180, 185, 146, 148, 140, 142, 138, 144, 114, /* 240 */ 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, /* 250 */ 40, 59, 67, 69, 326, 357, 136, 44, 45, 501, /* 260 */ 473, 463, 359, 36, 361, 130, 128, 660, 275, 31, /* 270 */ 84, 99, 356, 378, 14, 15, 380, 387, 392, 52, /* 280 */ 170, 117, 122, 123, 113, 541, 369, 643, 395, 348, /* 290 */ 98, 54, 78, 200, 302, 57, 58, 819, 135, 97, /* 300 */ 171, 181, 186, 191, 180, 185, 146, 148, 140, 142, /* 310 */ 138, 144, 861, 150, 152, 154, 156, 158, 160, 162, /* 320 */ 164, 166, 168, 104, 105, 106, 817, 80, 48, 316, /* 330 */ 162, 164, 166, 168, 319, 277, 12, 49, 99, 303, /* 340 */ 283, 818, 99, 124, 304, 99, 241, 172, 593, 114, /* 350 */ 50, 193, 46, 378, 170, 13, 380, 387, 392, 78, /* 360 */ 260, 276, 47, 78, 200, 64, 78, 260, 395, 174, /* 370 */ 175, 221, 135, 97, 171, 181, 186, 191, 180, 185, /* 380 */ 146, 148, 140, 142, 138, 144, 199, 150, 152, 154, /* 390 */ 156, 158, 160, 162, 164, 166, 168, 173, 252, 261, /* 400 */ 120, 122, 123, 212, 170, 268, 254, 130, 128, 288, /* 410 */ 590, 176, 246, 187, 192, 414, 195, 241, 197, 198, /* 420 */ 14, 15, 135, 97, 171, 181, 186, 191, 180, 185, /* 430 */ 146, 148, 140, 142, 138, 144, 433, 150, 152, 154, /* 440 */ 156, 158, 160, 162, 164, 166, 168, 311, 99, 707, /* 450 */ 99, 422, 708, 417, 275, 81, 318, 598, 99, 219, /* 460 */ 13, 231, 124, 13, 176, 48, 187, 192, 20, 78, /* 470 */ 317, 78, 214, 195, 49, 197, 198, 462, 170, 78, /* 480 */ 200, 116, 27, 13, 410, 113, 591, 50, 80, 225, /* 490 */ 195, 11, 197, 198, 506, 235, 135, 97, 171, 181, /* 500 */ 186, 191, 180, 185, 146, 148, 140, 142, 138, 144, /* 510 */ 80, 150, 152, 154, 156, 158, 160, 162, 164, 166, /* 520 */ 168, 277, 215, 324, 606, 14, 15, 301, 14, 15, /* 530 */ 512, 13, 508, 240, 196, 486, 195, 685, 197, 198, /* 540 */ 22, 834, 445, 331, 462, 170, 444, 276, 14, 15, /* 550 */ 114, 468, 278, 394, 599, 280, 470, 288, 446, 680, /* 560 */ 13, 321, 404, 135, 97, 171, 181, 186, 191, 180, /* 570 */ 185, 146, 148, 140, 142, 138, 144, 80, 150, 152, /* 580 */ 154, 156, 158, 160, 162, 164, 166, 168, 74, 99, /* 590 */ 540, 366, 73, 99, 352, 289, 14, 15, 176, 333, /* 600 */ 187, 192, 486, 869, 359, 273, 283, 542, 543, 867, /* 610 */ 78, 500, 510, 170, 78, 323, 682, 176, 472, 187, /* 620 */ 192, 746, 118, 470, 119, 14, 15, 195, 346, 197, /* 630 */ 198, 135, 97, 171, 181, 186, 191, 180, 185, 146, /* 640 */ 148, 140, 142, 138, 144, 99, 150, 152, 154, 156, /* 650 */ 158, 160, 162, 164, 166, 168, 532, 334, 341, 343, /* 660 */ 841, 39, 195, 170, 197, 198, 78, 94, 124, 356, /* 670 */ 271, 353, 439, 441, 440, 544, 883, 428, 72, 862, /* 680 */ 288, 135, 97, 171, 181, 186, 191, 180, 185, 146, /* 690 */ 148, 140, 142, 138, 144, 13, 150, 152, 154, 156, /* 700 */ 158, 160, 162, 164, 166, 168, 195, 99, 197, 198, /* 710 */ 406, 330, 195, 170, 197, 198, 568, 405, 306, 195, /* 720 */ 42, 197, 198, 65, 195, 539, 197, 198, 78, 96, /* 730 */ 66, 135, 97, 171, 181, 186, 191, 180, 185, 146, /* 740 */ 148, 140, 142, 138, 144, 885, 150, 152, 154, 156, /* 750 */ 158, 160, 162, 164, 166, 168, 99, 740, 99, 298, /* 760 */ 14, 15, 272, 170, 13, 74, 572, 86, 600, 73, /* 770 */ 126, 127, 614, 709, 309, 478, 24, 78, 247, 78, /* 780 */ 111, 135, 97, 171, 181, 186, 191, 180, 185, 146, /* 790 */ 148, 140, 142, 138, 144, 99, 150, 152, 154, 156, /* 800 */ 158, 160, 162, 164, 166, 168, 99, 238, 113, 239, /* 810 */ 295, 26, 296, 170, 338, 337, 78, 137, 294, 320, /* 820 */ 347, 239, 348, 390, 211, 348, 30, 78, 139, 14, /* 830 */ 15, 135, 189, 171, 181, 186, 191, 180, 185, 146, /* 840 */ 148, 140, 142, 138, 144, 99, 150, 152, 154, 156, /* 850 */ 158, 160, 162, 164, 166, 168, 99, 80, 99, 372, /* 860 */ 399, 442, 348, 170, 298, 243, 78, 141, 363, 601, /* 870 */ 428, 437, 438, 114, 411, 269, 605, 78, 143, 78, /* 880 */ 145, 448, 97, 171, 181, 186, 191, 180, 185, 146, /* 890 */ 148, 140, 142, 138, 144, 99, 150, 152, 154, 156, /* 900 */ 158, 160, 162, 164, 166, 168, 99, 80, 99, 430, /* 910 */ 99, 296, 555, 170, 413, 856, 78, 147, 672, 457, /* 920 */ 352, 348, 298, 443, 465, 45, 35, 78, 149, 78, /* 930 */ 151, 78, 153, 171, 181, 186, 191, 180, 185, 146, /* 940 */ 148, 140, 142, 138, 144, 99, 150, 152, 154, 156, /* 950 */ 158, 160, 162, 164, 166, 168, 99, 459, 99, 29, /* 960 */ 79, 464, 183, 483, 71, 339, 78, 155, 709, 421, /* 970 */ 428, 79, 109, 99, 491, 71, 296, 78, 157, 78, /* 980 */ 159, 490, 243, 109, 99, 340, 99, 449, 857, 223, /* 990 */ 99, 460, 182, 709, 78, 161, 99, 349, 827, 136, /* 1000 */ 223, 99, 80, 201, 99, 78, 163, 78, 165, 507, /* 1010 */ 136, 78, 167, 42, 201, 38, 493, 78, 169, 569, /* 1020 */ 207, 205, 78, 177, 674, 78, 179, 477, 203, 76, /* 1030 */ 77, 207, 205, 98, 99, 84, 99, 42, 336, 203, /* 1040 */ 76, 77, 99, 43, 98, 41, 428, 79, 494, 80, /* 1050 */ 428, 71, 84, 99, 352, 78, 188, 78, 190, 109, /* 1060 */ 499, 428, 497, 78, 202, 60, 104, 105, 106, 107, /* 1070 */ 108, 209, 213, 99, 78, 204, 223, 104, 105, 106, /* 1080 */ 107, 108, 209, 213, 820, 509, 136, 53, 383, 511, /* 1090 */ 201, 99, 56, 61, 78, 206, 55, 428, 428, 889, /* 1100 */ 513, 99, 243, 99, 352, 99, 79, 207, 205, 312, /* 1110 */ 71, 99, 78, 208, 483, 203, 76, 77, 109, 533, /* 1120 */ 98, 497, 78, 220, 78, 222, 78, 232, 84, 99, /* 1130 */ 428, 353, 78, 234, 352, 223, 517, 521, 389, 99, /* 1140 */ 62, 530, 99, 64, 63, 136, 68, 529, 70, 201, /* 1150 */ 78, 236, 352, 104, 105, 106, 107, 108, 209, 213, /* 1160 */ 78, 249, 99, 78, 265, 877, 207, 205, 398, 527, /* 1170 */ 99, 615, 616, 313, 203, 76, 77, 99, 523, 98, /* 1180 */ 80, 353, 8, 78, 270, 99, 456, 19, 21, 23, /* 1190 */ 412, 78, 300, 75, 78, 310, 82, 84, 78, 365, /* 1200 */ 563, 83, 547, 99, 87, 553, 78, 393, 85, 557, /* 1210 */ 99, 353, 104, 105, 106, 107, 108, 209, 213, 99, /* 1220 */ 269, 536, 99, 467, 78, 434, 88, 266, 534, 353, /* 1230 */ 560, 78, 481, 566, 264, 89, 250, 90, 93, 91, /* 1240 */ 78, 485, 101, 78, 498, 92, 100, 102, 103, 110, /* 1250 */ 131, 121, 134, 125, 129, 168, 184, 242, 686, 687, /* 1260 */ 688, 210, 233, 218, 224, 216, 227, 226, 217, 229, /* 1270 */ 228, 230, 243, 251, 515, 519, 463, 245, 253, 244, /* 1280 */ 505, 257, 255, 256, 258, 84, 259, 262, 263, 239, /* 1290 */ 267, 279, 274, 281, 282, 299, 285, 292, 284, 287, /* 1300 */ 290, 293, 297, 305, 314, 291, 307, 322, 308, 325, /* 1310 */ 327, 345, 329, 328, 332, 350, 354, 330, 358, 335, /* 1320 */ 342, 379, 381, 382, 344, 351, 368, 385, 355, 371, /* 1330 */ 388, 360, 396, 397, 400, 401, 415, 54, 416, 386, /* 1340 */ 384, 391, 418, 402, 407, 419, 377, 420, 423, 424, /* 1350 */ 403, 426, 425, 427, 429, 435, 431, 849, 436, 854, /* 1360 */ 432, 855, 450, 447, 451, 452, 454, 453, 825, 455, /* 1370 */ 458, 826, 469, 461, 466, 747, 748, 848, 471, 464, /* 1380 */ 863, 480, 474, 475, 476, 482, 865, 479, 487, 484, /* 1390 */ 489, 488, 492, 866, 495, 868, 504, 679, 502, 681, /* 1400 */ 833, 875, 518, 503, 516, 739, 520, 524, 522, 742, /* 1410 */ 745, 531, 526, 835, 535, 528, 538, 537, 836, 837, /* 1420 */ 838, 839, 545, 546, 840, 550, 876, 556, 551, 878, /* 1430 */ 548, 549, 554, 879, 559, 882, 884, 562, 886, 561, /* 1440 */ 552, 558, 564, 567, 570, 565, 571, 887, 576, 574, /* 1450 */ 573, 888, 578, 559, 559, 579, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 28, 11, 30, 77, 78, 79, 80, 0, 82, 83, /* 10 */ 84, 85, 86, 87, 88, 89, 90, 91, 11, 12, /* 20 */ 11, 49, 81, 82, 83, 84, 85, 86, 87, 88, /* 30 */ 89, 90, 91, 86, 87, 88, 89, 90, 91, 67, /* 40 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, /* 50 */ 78, 79, 80, 69, 82, 83, 84, 85, 86, 87, /* 60 */ 88, 89, 90, 91, 17, 18, 19, 95, 11, 29, /* 70 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, /* 80 */ 30, 97, 98, 99, 100, 101, 102, 103, 104, 49, /* 90 */ 150, 151, 50, 53, 26, 111, 156, 155, 30, 147, /* 100 */ 148, 149, 162, 30, 152, 163, 164, 67, 68, 69, /* 110 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 120 */ 80, 153, 82, 83, 84, 85, 86, 87, 88, 89, /* 130 */ 90, 91, 155, 65, 11, 195, 28, 155, 129, 165, /* 140 */ 163, 164, 168, 169, 170, 95, 96, 97, 106, 155, /* 150 */ 100, 101, 102, 30, 86, 87, 162, 49, 176, 177, /* 160 */ 220, 88, 112, 95, 187, 188, 154, 99, 95, 96, /* 170 */ 176, 177, 28, 21, 30, 67, 68, 69, 70, 71, /* 180 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 195, /* 190 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, /* 200 */ 132, 133, 134, 27, 222, 29, 155, 49, 56, 30, /* 210 */ 149, 160, 218, 152, 163, 164, 11, 12, 95, 96, /* 220 */ 69, 168, 169, 170, 230, 67, 68, 69, 70, 71, /* 230 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 95, /* 240 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, /* 250 */ 99, 100, 101, 102, 103, 104, 65, 192, 193, 107, /* 260 */ 108, 109, 111, 174, 175, 86, 87, 27, 29, 29, /* 270 */ 118, 155, 183, 97, 95, 96, 100, 101, 102, 99, /* 280 */ 49, 171, 172, 173, 30, 106, 95, 27, 112, 29, /* 290 */ 99, 111, 176, 177, 162, 17, 18, 139, 67, 68, /* 300 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, /* 310 */ 79, 80, 15, 82, 83, 84, 85, 86, 87, 88, /* 320 */ 89, 90, 91, 132, 133, 134, 21, 195, 22, 27, /* 330 */ 88, 89, 90, 91, 218, 96, 155, 31, 155, 207, /* 340 */ 208, 21, 155, 233, 212, 155, 230, 49, 11, 95, /* 350 */ 44, 26, 46, 97, 49, 30, 100, 101, 102, 176, /* 360 */ 177, 122, 56, 176, 177, 105, 176, 177, 112, 71, /* 370 */ 72, 140, 67, 68, 69, 70, 71, 72, 73, 74, /* 380 */ 75, 76, 77, 78, 79, 80, 27, 82, 83, 84, /* 390 */ 85, 86, 87, 88, 89, 90, 91, 99, 215, 216, /* 400 */ 171, 172, 173, 27, 49, 218, 216, 86, 87, 168, /* 410 */ 11, 223, 224, 225, 226, 24, 114, 230, 116, 117, /* 420 */ 95, 96, 67, 68, 69, 70, 71, 72, 73, 74, /* 430 */ 75, 76, 77, 78, 79, 80, 139, 82, 83, 84, /* 440 */ 85, 86, 87, 88, 89, 90, 91, 206, 155, 27, /* 450 */ 155, 60, 27, 62, 29, 162, 27, 11, 155, 139, /* 460 */ 30, 141, 233, 30, 223, 22, 225, 226, 154, 176, /* 470 */ 177, 176, 177, 114, 31, 116