drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 1 | /* Driver template for the LEMON parser generator. |
| 2 | ** The author disclaims copyright to this source code. |
| 3 | ** |
| 4 | ** This version of "lempar.c" is modified, slightly, for use by SQLite. |
| 5 | ** The only modifications are the addition of a couple of NEVER() |
| 6 | ** macros to disable tests that are needed in the case of a general |
| 7 | ** LALR(1) grammar but which are always false in the |
| 8 | ** specific grammar used by SQLite. |
| 9 | */ |
| 10 | /* First off, code is included that follows the "include" declaration |
| 11 | ** in the input grammar file. */ |
| 12 | #include <stdio.h> |
| 13 | %% |
| 14 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 15 | ** This section will be null unless lemon is run with the -m switch. |
| 16 | */ |
| 17 | /* |
| 18 | ** These constants (all generated automatically by the parser generator) |
| 19 | ** specify the various kinds of tokens (terminals) that the parser |
| 20 | ** understands. |
| 21 | ** |
| 22 | ** Each symbol here is a terminal symbol in the grammar. |
| 23 | */ |
| 24 | %% |
| 25 | /* Make sure the INTERFACE macro is defined. |
| 26 | */ |
| 27 | #ifndef INTERFACE |
| 28 | # define INTERFACE 1 |
| 29 | #endif |
| 30 | /* The next thing included is series of defines which control |
| 31 | ** various aspects of the generated parser. |
| 32 | ** YYCODETYPE is the data type used for storing terminal |
| 33 | ** and nonterminal numbers. "unsigned char" is |
| 34 | ** used if there are fewer than 250 terminals |
| 35 | ** and nonterminals. "int" is used otherwise. |
| 36 | ** YYNOCODE is a number of type YYCODETYPE which corresponds |
| 37 | ** to no legal terminal or nonterminal number. This |
| 38 | ** number is used to fill in empty slots of the hash |
| 39 | ** table. |
| 40 | ** YYFALLBACK If defined, this indicates that one or more tokens |
| 41 | ** have fall-back values which should be used if the |
| 42 | ** original value of the token will not parse. |
| 43 | ** YYACTIONTYPE is the data type used for storing terminal |
| 44 | ** and nonterminal numbers. "unsigned char" is |
| 45 | ** used if there are fewer than 250 rules and |
| 46 | ** states combined. "int" is used otherwise. |
| 47 | ** ParseTOKENTYPE is the data type used for minor tokens given |
| 48 | ** directly to the parser from the tokenizer. |
| 49 | ** YYMINORTYPE is the data type used for all minor tokens. |
| 50 | ** This is typically a union of many types, one of |
| 51 | ** which is ParseTOKENTYPE. The entry in the union |
| 52 | ** for base tokens is called "yy0". |
| 53 | ** YYSTACKDEPTH is the maximum depth of the parser's stack. If |
| 54 | ** zero the stack is dynamically sized using realloc() |
| 55 | ** ParseARG_SDECL A static variable declaration for the %extra_argument |
| 56 | ** ParseARG_PDECL A parameter declaration for the %extra_argument |
| 57 | ** ParseARG_STORE Code to store %extra_argument into yypParser |
| 58 | ** ParseARG_FETCH Code to extract %extra_argument from yypParser |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 59 | ** YYERRORSYMBOL is the code number of the error symbol. If not |
| 60 | ** defined, then do no error processing. |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 61 | ** YYNSTATE the combined number of states. |
| 62 | ** YYNRULE the number of rules in the grammar |
| 63 | ** YY_MAX_SHIFT Maximum value for shift actions |
| 64 | ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions |
| 65 | ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions |
| 66 | ** YY_MIN_REDUCE Maximum value for reduce actions |
| 67 | ** YY_ERROR_ACTION The yy_action[] code for syntax error |
| 68 | ** YY_ACCEPT_ACTION The yy_action[] code for accept |
| 69 | ** YY_NO_ACTION The yy_action[] code for no-op |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 70 | */ |
| 71 | %% |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 72 | |
| 73 | /* The yyzerominor constant is used to initialize instances of |
| 74 | ** YYMINORTYPE objects to zero. */ |
| 75 | static const YYMINORTYPE yyzerominor = { 0 }; |
| 76 | |
| 77 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 78 | ** otherwise. |
| 79 | ** |
| 80 | ** Applications can choose to define yytestcase() in the %include section |
| 81 | ** to a macro that can assist in verifying code coverage. For production |
| 82 | ** code the yytestcase() macro should be turned off. But it is useful |
| 83 | ** for testing. |
| 84 | */ |
| 85 | #ifndef yytestcase |
| 86 | # define yytestcase(X) |
| 87 | #endif |
| 88 | |
| 89 | |
| 90 | /* Next are the tables used to determine what action to take based on the |
| 91 | ** current state and lookahead token. These tables are used to implement |
| 92 | ** functions that take a state number and lookahead value and return an |
| 93 | ** action integer. |
| 94 | ** |
| 95 | ** Suppose the action integer is N. Then the action is determined as |
| 96 | ** follows |
| 97 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 98 | ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 99 | ** token onto the stack and goto state N. |
| 100 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 101 | ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then |
| 102 | ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 103 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 104 | ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE |
| 105 | ** and YY_MAX_REDUCE |
| 106 | |
| 107 | ** N == YY_ERROR_ACTION A syntax error has occurred. |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 108 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 109 | ** N == YY_ACCEPT_ACTION The parser accepts its input. |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 110 | ** |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 111 | ** N == YY_NO_ACTION No such action. Denotes unused |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 112 | ** slots in the yy_action[] table. |
| 113 | ** |
| 114 | ** The action table is constructed as a single large table named yy_action[]. |
| 115 | ** Given state S and lookahead X, the action is computed as |
| 116 | ** |
| 117 | ** yy_action[ yy_shift_ofst[S] + X ] |
| 118 | ** |
| 119 | ** If the index value yy_shift_ofst[S]+X is out of range or if the value |
| 120 | ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] |
| 121 | ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table |
| 122 | ** and that yy_default[S] should be used instead. |
| 123 | ** |
| 124 | ** The formula above is for computing the action when the lookahead is |
| 125 | ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
| 126 | ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
| 127 | ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of |
| 128 | ** YY_SHIFT_USE_DFLT. |
| 129 | ** |
| 130 | ** The following are the tables generated in this section: |
| 131 | ** |
| 132 | ** yy_action[] A single table containing all actions. |
| 133 | ** yy_lookahead[] A table containing the lookahead for each entry in |
| 134 | ** yy_action. Used to detect hash collisions. |
| 135 | ** yy_shift_ofst[] For each state, the offset into yy_action for |
| 136 | ** shifting terminals. |
| 137 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 138 | ** shifting non-terminals after a reduce. |
| 139 | ** yy_default[] Default action for each state. |
| 140 | */ |
| 141 | %% |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 142 | |
| 143 | /* The next table maps tokens into fallback tokens. If a construct |
| 144 | ** like the following: |
| 145 | ** |
| 146 | ** %fallback ID X Y Z. |
| 147 | ** |
| 148 | ** appears in the grammar, then ID becomes a fallback token for X, Y, |
| 149 | ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
| 150 | ** but it does not parse, the type of the token is changed to ID and |
| 151 | ** the parse is retried before an error is thrown. |
| 152 | */ |
| 153 | #ifdef YYFALLBACK |
| 154 | static const YYCODETYPE yyFallback[] = { |
| 155 | %% |
| 156 | }; |
| 157 | #endif /* YYFALLBACK */ |
| 158 | |
| 159 | /* The following structure represents a single element of the |
| 160 | ** parser's stack. Information stored includes: |
| 161 | ** |
| 162 | ** + The state number for the parser at this level of the stack. |
| 163 | ** |
| 164 | ** + The value of the token stored at this level of the stack. |
| 165 | ** (In other words, the "major" token.) |
| 166 | ** |
| 167 | ** + The semantic value stored at this level of the stack. This is |
| 168 | ** the information used by the action routines in the grammar. |
| 169 | ** It is sometimes called the "minor" token. |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 170 | ** |
| 171 | ** After the "shift" half of a SHIFTREDUCE action, the stateno field |
| 172 | ** actually contains the reduce action for the second half of the |
| 173 | ** SHIFTREDUCE. |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 174 | */ |
| 175 | struct yyStackEntry { |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 176 | YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 177 | YYCODETYPE major; /* The major token value. This is the code |
| 178 | ** number for the token at this stack level */ |
| 179 | YYMINORTYPE minor; /* The user-supplied minor token value. This |
| 180 | ** is the value of the token */ |
| 181 | }; |
| 182 | typedef struct yyStackEntry yyStackEntry; |
| 183 | |
| 184 | /* The state of the parser is completely contained in an instance of |
| 185 | ** the following structure */ |
| 186 | struct yyParser { |
| 187 | int yyidx; /* Index of top element in stack */ |
| 188 | #ifdef YYTRACKMAXSTACKDEPTH |
| 189 | int yyidxMax; /* Maximum value of yyidx */ |
| 190 | #endif |
| 191 | int yyerrcnt; /* Shifts left before out of the error */ |
| 192 | ParseARG_SDECL /* A place to hold %extra_argument */ |
| 193 | #if YYSTACKDEPTH<=0 |
| 194 | int yystksz; /* Current side of the stack */ |
| 195 | yyStackEntry *yystack; /* The parser's stack */ |
| 196 | #else |
| 197 | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
| 198 | #endif |
| 199 | }; |
| 200 | typedef struct yyParser yyParser; |
| 201 | |
| 202 | #ifndef NDEBUG |
| 203 | #include <stdio.h> |
| 204 | static FILE *yyTraceFILE = 0; |
| 205 | static char *yyTracePrompt = 0; |
| 206 | #endif /* NDEBUG */ |
| 207 | |
| 208 | #ifndef NDEBUG |
| 209 | /* |
| 210 | ** Turn parser tracing on by giving a stream to which to write the trace |
| 211 | ** and a prompt to preface each trace message. Tracing is turned off |
| 212 | ** by making either argument NULL |
| 213 | ** |
| 214 | ** Inputs: |
| 215 | ** <ul> |
| 216 | ** <li> A FILE* to which trace output should be written. |
| 217 | ** If NULL, then tracing is turned off. |
| 218 | ** <li> A prefix string written at the beginning of every |
| 219 | ** line of trace output. If NULL, then tracing is |
| 220 | ** turned off. |
| 221 | ** </ul> |
| 222 | ** |
| 223 | ** Outputs: |
| 224 | ** None. |
| 225 | */ |
| 226 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ |
| 227 | yyTraceFILE = TraceFILE; |
| 228 | yyTracePrompt = zTracePrompt; |
| 229 | if( yyTraceFILE==0 ) yyTracePrompt = 0; |
| 230 | else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
| 231 | } |
| 232 | #endif /* NDEBUG */ |
| 233 | |
| 234 | #ifndef NDEBUG |
| 235 | /* For tracing shifts, the names of all terminals and nonterminals |
| 236 | ** are required. The following table supplies these names */ |
| 237 | static const char *const yyTokenName[] = { |
| 238 | %% |
| 239 | }; |
| 240 | #endif /* NDEBUG */ |
| 241 | |
| 242 | #ifndef NDEBUG |
| 243 | /* For tracing reduce actions, the names of all rules are required. |
| 244 | */ |
| 245 | static const char *const yyRuleName[] = { |
| 246 | %% |
| 247 | }; |
| 248 | #endif /* NDEBUG */ |
| 249 | |
| 250 | |
| 251 | #if YYSTACKDEPTH<=0 |
| 252 | /* |
| 253 | ** Try to increase the size of the parser stack. |
| 254 | */ |
| 255 | static void yyGrowStack(yyParser *p){ |
| 256 | int newSize; |
| 257 | yyStackEntry *pNew; |
| 258 | |
| 259 | newSize = p->yystksz*2 + 100; |
| 260 | pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
| 261 | if( pNew ){ |
| 262 | p->yystack = pNew; |
| 263 | p->yystksz = newSize; |
| 264 | #ifndef NDEBUG |
| 265 | if( yyTraceFILE ){ |
| 266 | fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", |
| 267 | yyTracePrompt, p->yystksz); |
| 268 | } |
| 269 | #endif |
| 270 | } |
| 271 | } |
| 272 | #endif |
| 273 | |
| 274 | /* |
| 275 | ** This function allocates a new parser. |
| 276 | ** The only argument is a pointer to a function which works like |
| 277 | ** malloc. |
| 278 | ** |
| 279 | ** Inputs: |
| 280 | ** A pointer to the function used to allocate memory. |
| 281 | ** |
| 282 | ** Outputs: |
| 283 | ** A pointer to a parser. This pointer is used in subsequent calls |
| 284 | ** to Parse and ParseFree. |
| 285 | */ |
drh | fb046e7 | 2014-09-12 04:28:33 +0000 | [diff] [blame] | 286 | void *ParseAlloc(void *(*mallocProc)(u64)){ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 287 | yyParser *pParser; |
drh | fb046e7 | 2014-09-12 04:28:33 +0000 | [diff] [blame] | 288 | pParser = (yyParser*)(*mallocProc)( (u64)sizeof(yyParser) ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 289 | if( pParser ){ |
| 290 | pParser->yyidx = -1; |
| 291 | #ifdef YYTRACKMAXSTACKDEPTH |
| 292 | pParser->yyidxMax = 0; |
| 293 | #endif |
| 294 | #if YYSTACKDEPTH<=0 |
| 295 | pParser->yystack = NULL; |
| 296 | pParser->yystksz = 0; |
| 297 | yyGrowStack(pParser); |
| 298 | #endif |
| 299 | } |
| 300 | return pParser; |
| 301 | } |
| 302 | |
| 303 | /* The following function deletes the value associated with a |
| 304 | ** symbol. The symbol can be either a terminal or nonterminal. |
| 305 | ** "yymajor" is the symbol code, and "yypminor" is a pointer to |
| 306 | ** the value. |
| 307 | */ |
| 308 | static void yy_destructor( |
| 309 | yyParser *yypParser, /* The parser */ |
| 310 | YYCODETYPE yymajor, /* Type code for object to destroy */ |
| 311 | YYMINORTYPE *yypminor /* The object to be destroyed */ |
| 312 | ){ |
| 313 | ParseARG_FETCH; |
| 314 | switch( yymajor ){ |
| 315 | /* Here is inserted the actions which take place when a |
| 316 | ** terminal or non-terminal is destroyed. This can happen |
| 317 | ** when the symbol is popped from the stack during a |
| 318 | ** reduce or during error processing or when a parser is |
| 319 | ** being destroyed before it is finished parsing. |
| 320 | ** |
| 321 | ** Note: during a reduce, the only symbols destroyed are those |
| 322 | ** which appear on the RHS of the rule, but which are not used |
| 323 | ** inside the C code. |
| 324 | */ |
| 325 | %% |
| 326 | default: break; /* If no destructor action specified: do nothing */ |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /* |
| 331 | ** Pop the parser's stack once. |
| 332 | ** |
| 333 | ** If there is a destructor routine associated with the token which |
| 334 | ** is popped from the stack, then call it. |
| 335 | ** |
| 336 | ** Return the major token number for the symbol popped. |
| 337 | */ |
| 338 | static int yy_pop_parser_stack(yyParser *pParser){ |
| 339 | YYCODETYPE yymajor; |
| 340 | yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; |
| 341 | |
| 342 | /* There is no mechanism by which the parser stack can be popped below |
| 343 | ** empty in SQLite. */ |
drh | 98ef0f6 | 2015-06-30 01:25:52 +0000 | [diff] [blame] | 344 | assert( pParser->yyidx>=0 ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 345 | #ifndef NDEBUG |
| 346 | if( yyTraceFILE && pParser->yyidx>=0 ){ |
| 347 | fprintf(yyTraceFILE,"%sPopping %s\n", |
| 348 | yyTracePrompt, |
| 349 | yyTokenName[yytos->major]); |
| 350 | } |
| 351 | #endif |
| 352 | yymajor = yytos->major; |
| 353 | yy_destructor(pParser, yymajor, &yytos->minor); |
| 354 | pParser->yyidx--; |
| 355 | return yymajor; |
| 356 | } |
| 357 | |
| 358 | /* |
| 359 | ** Deallocate and destroy a parser. Destructors are all called for |
| 360 | ** all stack elements before shutting the parser down. |
| 361 | ** |
| 362 | ** Inputs: |
| 363 | ** <ul> |
| 364 | ** <li> A pointer to the parser. This should be a pointer |
| 365 | ** obtained from ParseAlloc. |
| 366 | ** <li> A pointer to a function used to reclaim memory obtained |
| 367 | ** from malloc. |
| 368 | ** </ul> |
| 369 | */ |
| 370 | void ParseFree( |
| 371 | void *p, /* The parser to be deleted */ |
| 372 | void (*freeProc)(void*) /* Function used to reclaim memory */ |
| 373 | ){ |
| 374 | yyParser *pParser = (yyParser*)p; |
| 375 | /* In SQLite, we never try to destroy a parser that was not successfully |
| 376 | ** created in the first place. */ |
| 377 | if( NEVER(pParser==0) ) return; |
| 378 | while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); |
| 379 | #if YYSTACKDEPTH<=0 |
| 380 | free(pParser->yystack); |
| 381 | #endif |
| 382 | (*freeProc)((void*)pParser); |
| 383 | } |
| 384 | |
| 385 | /* |
| 386 | ** Return the peak depth of the stack for a parser. |
| 387 | */ |
| 388 | #ifdef YYTRACKMAXSTACKDEPTH |
| 389 | int ParseStackPeak(void *p){ |
| 390 | yyParser *pParser = (yyParser*)p; |
| 391 | return pParser->yyidxMax; |
| 392 | } |
| 393 | #endif |
| 394 | |
| 395 | /* |
| 396 | ** Find the appropriate action for a parser given the terminal |
| 397 | ** look-ahead token iLookAhead. |
| 398 | ** |
| 399 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
| 400 | ** independent of the look-ahead. If it is, return the action, otherwise |
| 401 | ** return YY_NO_ACTION. |
| 402 | */ |
| 403 | static int yy_find_shift_action( |
| 404 | yyParser *pParser, /* The parser */ |
| 405 | YYCODETYPE iLookAhead /* The look-ahead token */ |
| 406 | ){ |
| 407 | int i; |
| 408 | int stateno = pParser->yystack[pParser->yyidx].stateno; |
| 409 | |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 410 | if( stateno>=YY_MIN_REDUCE ) return stateno; |
drh | ae2a408 | 2015-09-07 20:02:39 +0000 | [diff] [blame] | 411 | assert( stateno <= YY_SHIFT_COUNT ); |
| 412 | i = yy_shift_ofst[stateno]; |
| 413 | if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno]; |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 414 | assert( iLookAhead!=YYNOCODE ); |
| 415 | i += iLookAhead; |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 416 | if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 417 | if( iLookAhead>0 ){ |
| 418 | #ifdef YYFALLBACK |
| 419 | YYCODETYPE iFallback; /* Fallback token */ |
| 420 | if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |
| 421 | && (iFallback = yyFallback[iLookAhead])!=0 ){ |
| 422 | #ifndef NDEBUG |
| 423 | if( yyTraceFILE ){ |
| 424 | fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
| 425 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
| 426 | } |
| 427 | #endif |
| 428 | return yy_find_shift_action(pParser, iFallback); |
| 429 | } |
| 430 | #endif |
| 431 | #ifdef YYWILDCARD |
| 432 | { |
| 433 | int j = i - iLookAhead + YYWILDCARD; |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 434 | if( |
| 435 | #if YY_SHIFT_MIN+YYWILDCARD<0 |
| 436 | j>=0 && |
| 437 | #endif |
| 438 | #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT |
| 439 | j<YY_ACTTAB_COUNT && |
| 440 | #endif |
| 441 | yy_lookahead[j]==YYWILDCARD |
| 442 | ){ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 443 | #ifndef NDEBUG |
| 444 | if( yyTraceFILE ){ |
| 445 | fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |
| 446 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); |
| 447 | } |
| 448 | #endif /* NDEBUG */ |
| 449 | return yy_action[j]; |
| 450 | } |
| 451 | } |
| 452 | #endif /* YYWILDCARD */ |
| 453 | } |
| 454 | return yy_default[stateno]; |
| 455 | }else{ |
| 456 | return yy_action[i]; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | ** Find the appropriate action for a parser given the non-terminal |
| 462 | ** look-ahead token iLookAhead. |
| 463 | ** |
| 464 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
| 465 | ** independent of the look-ahead. If it is, return the action, otherwise |
| 466 | ** return YY_NO_ACTION. |
| 467 | */ |
| 468 | static int yy_find_reduce_action( |
| 469 | int stateno, /* Current state number */ |
| 470 | YYCODETYPE iLookAhead /* The look-ahead token */ |
| 471 | ){ |
| 472 | int i; |
| 473 | #ifdef YYERRORSYMBOL |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 474 | if( stateno>YY_REDUCE_COUNT ){ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 475 | return yy_default[stateno]; |
| 476 | } |
| 477 | #else |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 478 | assert( stateno<=YY_REDUCE_COUNT ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 479 | #endif |
| 480 | i = yy_reduce_ofst[stateno]; |
| 481 | assert( i!=YY_REDUCE_USE_DFLT ); |
| 482 | assert( iLookAhead!=YYNOCODE ); |
| 483 | i += iLookAhead; |
| 484 | #ifdef YYERRORSYMBOL |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 485 | if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 486 | return yy_default[stateno]; |
| 487 | } |
| 488 | #else |
drh | f16371d | 2009-11-03 19:18:31 +0000 | [diff] [blame] | 489 | assert( i>=0 && i<YY_ACTTAB_COUNT ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 490 | assert( yy_lookahead[i]==iLookAhead ); |
| 491 | #endif |
| 492 | return yy_action[i]; |
| 493 | } |
| 494 | |
| 495 | /* |
| 496 | ** The following routine is called if the stack overflows. |
| 497 | */ |
| 498 | static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ |
| 499 | ParseARG_FETCH; |
| 500 | yypParser->yyidx--; |
| 501 | #ifndef NDEBUG |
| 502 | if( yyTraceFILE ){ |
| 503 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
| 504 | } |
| 505 | #endif |
| 506 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 507 | /* Here code is inserted which will execute if the parser |
| 508 | ** stack every overflows */ |
| 509 | %% |
| 510 | ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 511 | } |
| 512 | |
| 513 | /* |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 514 | ** Print tracing information for a SHIFT action |
| 515 | */ |
| 516 | #ifndef NDEBUG |
| 517 | static void yyTraceShift(yyParser *yypParser, int yyNewState){ |
| 518 | if( yyTraceFILE ){ |
| 519 | int i; |
| 520 | if( yyNewState<YYNSTATE ){ |
| 521 | fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
| 522 | fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
| 523 | for(i=1; i<=yypParser->yyidx; i++) |
| 524 | fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
| 525 | fprintf(yyTraceFILE,"\n"); |
| 526 | }else{ |
| 527 | fprintf(yyTraceFILE,"%sShift *\n",yyTracePrompt); |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | #else |
| 532 | # define yyTraceShift(X,Y) |
| 533 | #endif |
| 534 | |
| 535 | /* |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 536 | ** Perform a shift action. Return the number of errors. |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 537 | */ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 538 | static void yy_shift( |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 539 | yyParser *yypParser, /* The parser to be shifted */ |
| 540 | int yyNewState, /* The new state to shift in */ |
| 541 | int yyMajor, /* The major token to shift in */ |
| 542 | YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ |
| 543 | ){ |
| 544 | yyStackEntry *yytos; |
| 545 | yypParser->yyidx++; |
| 546 | #ifdef YYTRACKMAXSTACKDEPTH |
| 547 | if( yypParser->yyidx>yypParser->yyidxMax ){ |
| 548 | yypParser->yyidxMax = yypParser->yyidx; |
| 549 | } |
| 550 | #endif |
| 551 | #if YYSTACKDEPTH>0 |
| 552 | if( yypParser->yyidx>=YYSTACKDEPTH ){ |
| 553 | yyStackOverflow(yypParser, yypMinor); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 554 | return; |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 555 | } |
| 556 | #else |
| 557 | if( yypParser->yyidx>=yypParser->yystksz ){ |
| 558 | yyGrowStack(yypParser); |
| 559 | if( yypParser->yyidx>=yypParser->yystksz ){ |
| 560 | yyStackOverflow(yypParser, yypMinor); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 561 | return; |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 562 | } |
| 563 | } |
| 564 | #endif |
| 565 | yytos = &yypParser->yystack[yypParser->yyidx]; |
| 566 | yytos->stateno = (YYACTIONTYPE)yyNewState; |
| 567 | yytos->major = (YYCODETYPE)yyMajor; |
| 568 | yytos->minor = *yypMinor; |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 569 | yyTraceShift(yypParser, yyNewState); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /* The following table contains information about every rule that |
| 573 | ** is used during the reduce. |
| 574 | */ |
| 575 | static const struct { |
| 576 | YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
| 577 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
| 578 | } yyRuleInfo[] = { |
| 579 | %% |
| 580 | }; |
| 581 | |
| 582 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 583 | |
| 584 | /* |
| 585 | ** Perform a reduce action and the shift that must immediately |
| 586 | ** follow the reduce. |
| 587 | */ |
| 588 | static void yy_reduce( |
| 589 | yyParser *yypParser, /* The parser */ |
| 590 | int yyruleno /* Number of the rule by which to reduce */ |
| 591 | ){ |
| 592 | int yygoto; /* The next state */ |
| 593 | int yyact; /* The next action */ |
| 594 | YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ |
| 595 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
| 596 | int yysize; /* Amount to pop the stack */ |
| 597 | ParseARG_FETCH; |
| 598 | yymsp = &yypParser->yystack[yypParser->yyidx]; |
| 599 | #ifndef NDEBUG |
| 600 | if( yyTraceFILE && yyruleno>=0 |
| 601 | && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 602 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 603 | fprintf(yyTraceFILE, "%sReduce [%s] -> state %d.\n", yyTracePrompt, |
| 604 | yyRuleName[yyruleno], yymsp[-yysize].stateno); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 605 | } |
| 606 | #endif /* NDEBUG */ |
| 607 | |
| 608 | /* Silence complaints from purify about yygotominor being uninitialized |
| 609 | ** in some cases when it is copied into the stack after the following |
| 610 | ** switch. yygotominor is uninitialized when a rule reduces that does |
| 611 | ** not set the value of its left-hand side nonterminal. Leaving the |
| 612 | ** value of the nonterminal uninitialized is utterly harmless as long |
| 613 | ** as the value is never used. So really the only thing this code |
| 614 | ** accomplishes is to quieten purify. |
| 615 | ** |
| 616 | ** 2007-01-16: The wireshark project (www.wireshark.org) reports that |
| 617 | ** without this code, their parser segfaults. I'm not sure what there |
| 618 | ** parser is doing to make this happen. This is the second bug report |
| 619 | ** from wireshark this week. Clearly they are stressing Lemon in ways |
| 620 | ** that it has not been previously stressed... (SQLite ticket #2172) |
| 621 | */ |
| 622 | /*memset(&yygotominor, 0, sizeof(yygotominor));*/ |
| 623 | yygotominor = yyzerominor; |
| 624 | |
| 625 | |
| 626 | switch( yyruleno ){ |
| 627 | /* Beginning here are the reduction cases. A typical example |
| 628 | ** follows: |
| 629 | ** case 0: |
| 630 | ** #line <lineno> <grammarfile> |
| 631 | ** { ... } // User supplied code |
| 632 | ** #line <lineno> <thisfile> |
| 633 | ** break; |
| 634 | */ |
| 635 | %% |
| 636 | }; |
drh | 5a05be1 | 2012-10-09 18:51:44 +0000 | [diff] [blame] | 637 | assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 638 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 639 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 640 | yypParser->yyidx -= yysize; |
| 641 | yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 642 | if( yyact <= YY_MAX_SHIFTREDUCE ){ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 643 | if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 644 | /* If the reduce action popped at least |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 645 | ** one element off the stack, then we can push the new element back |
| 646 | ** onto the stack here, and skip the stack overflow test in yy_shift(). |
| 647 | ** That gives a significant speed improvement. */ |
| 648 | if( yysize ){ |
| 649 | yypParser->yyidx++; |
| 650 | yymsp -= yysize-1; |
| 651 | yymsp->stateno = (YYACTIONTYPE)yyact; |
| 652 | yymsp->major = (YYCODETYPE)yygoto; |
| 653 | yymsp->minor = yygotominor; |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 654 | yyTraceShift(yypParser, yyact); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 655 | }else{ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 656 | yy_shift(yypParser,yyact,yygoto,&yygotominor); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 657 | } |
| 658 | }else{ |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 659 | assert( yyact == YY_ACCEPT_ACTION ); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 660 | yy_accept(yypParser); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | /* |
| 665 | ** The following code executes when the parse fails |
| 666 | */ |
| 667 | #ifndef YYNOERRORRECOVERY |
| 668 | static void yy_parse_failed( |
| 669 | yyParser *yypParser /* The parser */ |
| 670 | ){ |
| 671 | ParseARG_FETCH; |
| 672 | #ifndef NDEBUG |
| 673 | if( yyTraceFILE ){ |
| 674 | fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
| 675 | } |
| 676 | #endif |
| 677 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 678 | /* Here code is inserted which will be executed whenever the |
| 679 | ** parser fails */ |
| 680 | %% |
| 681 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 682 | } |
| 683 | #endif /* YYNOERRORRECOVERY */ |
| 684 | |
| 685 | /* |
| 686 | ** The following code executes when a syntax error first occurs. |
| 687 | */ |
| 688 | static void yy_syntax_error( |
| 689 | yyParser *yypParser, /* The parser */ |
| 690 | int yymajor, /* The major type of the error token */ |
| 691 | YYMINORTYPE yyminor /* The minor type of the error token */ |
| 692 | ){ |
| 693 | ParseARG_FETCH; |
| 694 | #define TOKEN (yyminor.yy0) |
| 695 | %% |
| 696 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 697 | } |
| 698 | |
| 699 | /* |
| 700 | ** The following is executed when the parser accepts |
| 701 | */ |
| 702 | static void yy_accept( |
| 703 | yyParser *yypParser /* The parser */ |
| 704 | ){ |
| 705 | ParseARG_FETCH; |
| 706 | #ifndef NDEBUG |
| 707 | if( yyTraceFILE ){ |
| 708 | fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
| 709 | } |
| 710 | #endif |
| 711 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 712 | /* Here code is inserted which will be executed whenever the |
| 713 | ** parser accepts */ |
| 714 | %% |
| 715 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 716 | } |
| 717 | |
| 718 | /* The main parser program. |
| 719 | ** The first argument is a pointer to a structure obtained from |
| 720 | ** "ParseAlloc" which describes the current state of the parser. |
| 721 | ** The second argument is the major token number. The third is |
| 722 | ** the minor token. The fourth optional argument is whatever the |
| 723 | ** user wants (and specified in the grammar) and is available for |
| 724 | ** use by the action routines. |
| 725 | ** |
| 726 | ** Inputs: |
| 727 | ** <ul> |
| 728 | ** <li> A pointer to the parser (an opaque structure.) |
| 729 | ** <li> The major token number. |
| 730 | ** <li> The minor token number. |
| 731 | ** <li> An option argument of a grammar-specified type. |
| 732 | ** </ul> |
| 733 | ** |
| 734 | ** Outputs: |
| 735 | ** None. |
| 736 | */ |
| 737 | void Parse( |
| 738 | void *yyp, /* The parser */ |
| 739 | int yymajor, /* The major token code number */ |
| 740 | ParseTOKENTYPE yyminor /* The value for the token */ |
| 741 | ParseARG_PDECL /* Optional %extra_argument parameter */ |
| 742 | ){ |
| 743 | YYMINORTYPE yyminorunion; |
| 744 | int yyact; /* The parser action. */ |
drh | 30ddce6 | 2011-10-15 00:16:30 +0000 | [diff] [blame] | 745 | #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 746 | int yyendofinput; /* True if we are at the end of input */ |
drh | 30ddce6 | 2011-10-15 00:16:30 +0000 | [diff] [blame] | 747 | #endif |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 748 | #ifdef YYERRORSYMBOL |
| 749 | int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
| 750 | #endif |
| 751 | yyParser *yypParser; /* The parser */ |
| 752 | |
| 753 | /* (re)initialize the parser, if necessary */ |
| 754 | yypParser = (yyParser*)yyp; |
| 755 | if( yypParser->yyidx<0 ){ |
| 756 | #if YYSTACKDEPTH<=0 |
| 757 | if( yypParser->yystksz <=0 ){ |
| 758 | /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ |
| 759 | yyminorunion = yyzerominor; |
| 760 | yyStackOverflow(yypParser, &yyminorunion); |
| 761 | return; |
| 762 | } |
| 763 | #endif |
| 764 | yypParser->yyidx = 0; |
| 765 | yypParser->yyerrcnt = -1; |
| 766 | yypParser->yystack[0].stateno = 0; |
| 767 | yypParser->yystack[0].major = 0; |
| 768 | } |
| 769 | yyminorunion.yy0 = yyminor; |
drh | 30ddce6 | 2011-10-15 00:16:30 +0000 | [diff] [blame] | 770 | #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 771 | yyendofinput = (yymajor==0); |
drh | 30ddce6 | 2011-10-15 00:16:30 +0000 | [diff] [blame] | 772 | #endif |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 773 | ParseARG_STORE; |
| 774 | |
| 775 | #ifndef NDEBUG |
| 776 | if( yyTraceFILE ){ |
| 777 | fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); |
| 778 | } |
| 779 | #endif |
| 780 | |
| 781 | do{ |
| 782 | yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 783 | if( yyact <= YY_MAX_SHIFTREDUCE ){ |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 784 | if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 785 | yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
| 786 | yypParser->yyerrcnt--; |
| 787 | yymajor = YYNOCODE; |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 788 | }else if( yyact <= YY_MAX_REDUCE ){ |
| 789 | yy_reduce(yypParser,yyact-YY_MIN_REDUCE); |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 790 | }else{ |
| 791 | assert( yyact == YY_ERROR_ACTION ); |
| 792 | #ifdef YYERRORSYMBOL |
| 793 | int yymx; |
| 794 | #endif |
| 795 | #ifndef NDEBUG |
| 796 | if( yyTraceFILE ){ |
| 797 | fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); |
| 798 | } |
| 799 | #endif |
| 800 | #ifdef YYERRORSYMBOL |
| 801 | /* A syntax error has occurred. |
| 802 | ** The response to an error depends upon whether or not the |
| 803 | ** grammar defines an error token "ERROR". |
| 804 | ** |
| 805 | ** This is what we do if the grammar does define ERROR: |
| 806 | ** |
| 807 | ** * Call the %syntax_error function. |
| 808 | ** |
| 809 | ** * Begin popping the stack until we enter a state where |
| 810 | ** it is legal to shift the error symbol, then shift |
| 811 | ** the error symbol. |
| 812 | ** |
| 813 | ** * Set the error count to three. |
| 814 | ** |
| 815 | ** * Begin accepting and shifting new tokens. No new error |
| 816 | ** processing will occur until three tokens have been |
| 817 | ** shifted successfully. |
| 818 | ** |
| 819 | */ |
| 820 | if( yypParser->yyerrcnt<0 ){ |
| 821 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
| 822 | } |
| 823 | yymx = yypParser->yystack[yypParser->yyidx].major; |
| 824 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
| 825 | #ifndef NDEBUG |
| 826 | if( yyTraceFILE ){ |
| 827 | fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
| 828 | yyTracePrompt,yyTokenName[yymajor]); |
| 829 | } |
| 830 | #endif |
| 831 | yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); |
| 832 | yymajor = YYNOCODE; |
| 833 | }else{ |
| 834 | while( |
| 835 | yypParser->yyidx >= 0 && |
| 836 | yymx != YYERRORSYMBOL && |
| 837 | (yyact = yy_find_reduce_action( |
| 838 | yypParser->yystack[yypParser->yyidx].stateno, |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 839 | YYERRORSYMBOL)) >= YY_MIN_REDUCE |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 840 | ){ |
| 841 | yy_pop_parser_stack(yypParser); |
| 842 | } |
| 843 | if( yypParser->yyidx < 0 || yymajor==0 ){ |
| 844 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 845 | yy_parse_failed(yypParser); |
| 846 | yymajor = YYNOCODE; |
| 847 | }else if( yymx!=YYERRORSYMBOL ){ |
| 848 | YYMINORTYPE u2; |
| 849 | u2.YYERRSYMDT = 0; |
| 850 | yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); |
| 851 | } |
| 852 | } |
| 853 | yypParser->yyerrcnt = 3; |
| 854 | yyerrorhit = 1; |
| 855 | #elif defined(YYNOERRORRECOVERY) |
| 856 | /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to |
| 857 | ** do any kind of error recovery. Instead, simply invoke the syntax |
| 858 | ** error routine and continue going as if nothing had happened. |
| 859 | ** |
| 860 | ** Applications can set this macro (for example inside %include) if |
| 861 | ** they intend to abandon the parse upon the first syntax error seen. |
| 862 | */ |
| 863 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
| 864 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 865 | yymajor = YYNOCODE; |
| 866 | |
| 867 | #else /* YYERRORSYMBOL is not defined */ |
| 868 | /* This is what we do if the grammar does not define ERROR: |
| 869 | ** |
| 870 | ** * Report an error message, and throw away the input token. |
| 871 | ** |
| 872 | ** * If the input token is $, then fail the parse. |
| 873 | ** |
| 874 | ** As before, subsequent error messages are suppressed until |
| 875 | ** three input tokens have been successfully shifted. |
| 876 | */ |
| 877 | if( yypParser->yyerrcnt<=0 ){ |
| 878 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
| 879 | } |
| 880 | yypParser->yyerrcnt = 3; |
| 881 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 882 | if( yyendofinput ){ |
| 883 | yy_parse_failed(yypParser); |
| 884 | } |
| 885 | yymajor = YYNOCODE; |
| 886 | #endif |
| 887 | } |
| 888 | }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
drh | a248a72 | 2015-09-07 19:52:55 +0000 | [diff] [blame] | 889 | #ifndef NDEBUG |
drh | 3bd48ab | 2015-09-07 18:23:37 +0000 | [diff] [blame] | 890 | if( yyTraceFILE ){ |
| 891 | fprintf(yyTraceFILE,"%sReturn\n",yyTracePrompt); |
| 892 | } |
| 893 | #endif |
drh | 53bc21b | 2009-07-03 17:09:28 +0000 | [diff] [blame] | 894 | return; |
| 895 | } |