drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 1 | /* Driver template for the LEMON parser generator. |
drh | b19a2bc | 2001-09-16 00:13:26 +0000 | [diff] [blame] | 2 | ** The author disclaims copyright to this source code. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 3 | */ |
| 4 | /* First off, code is include which follows the "include" declaration |
| 5 | ** in the input file. */ |
| 6 | #include <stdio.h> |
| 7 | %% |
| 8 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 9 | ** This section will be null unless lemon is run with the -m switch. |
| 10 | */ |
| 11 | /* |
| 12 | ** These constants (all generated automatically by the parser generator) |
| 13 | ** specify the various kinds of tokens (terminals) that the parser |
| 14 | ** understands. |
| 15 | ** |
| 16 | ** Each symbol here is a terminal symbol in the grammar. |
| 17 | */ |
| 18 | %% |
| 19 | /* Make sure the INTERFACE macro is defined. |
| 20 | */ |
| 21 | #ifndef INTERFACE |
| 22 | # define INTERFACE 1 |
| 23 | #endif |
| 24 | /* The next thing included is series of defines which control |
| 25 | ** various aspects of the generated parser. |
| 26 | ** YYCODETYPE is the data type used for storing terminal |
| 27 | ** and nonterminal numbers. "unsigned char" is |
| 28 | ** used if there are fewer than 250 terminals |
| 29 | ** and nonterminals. "int" is used otherwise. |
| 30 | ** YYNOCODE is a number of type YYCODETYPE which corresponds |
| 31 | ** to no legal terminal or nonterminal number. This |
| 32 | ** number is used to fill in empty slots of the hash |
| 33 | ** table. |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 34 | ** YYFALLBACK If defined, this indicates that one or more tokens |
| 35 | ** have fall-back values which should be used if the |
| 36 | ** original value of the token will not parse. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 37 | ** YYACTIONTYPE is the data type used for storing terminal |
| 38 | ** and nonterminal numbers. "unsigned char" is |
| 39 | ** used if there are fewer than 250 rules and |
| 40 | ** states combined. "int" is used otherwise. |
| 41 | ** ParseTOKENTYPE is the data type used for minor tokens given |
| 42 | ** directly to the parser from the tokenizer. |
| 43 | ** YYMINORTYPE is the data type used for all minor tokens. |
| 44 | ** This is typically a union of many types, one of |
| 45 | ** which is ParseTOKENTYPE. The entry in the union |
| 46 | ** for base tokens is called "yy0". |
| 47 | ** YYSTACKDEPTH is the maximum depth of the parser's stack. |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 48 | ** ParseARG_SDECL A static variable declaration for the %extra_argument |
| 49 | ** ParseARG_PDECL A parameter declaration for the %extra_argument |
| 50 | ** ParseARG_STORE Code to store %extra_argument into yypParser |
| 51 | ** ParseARG_FETCH Code to extract %extra_argument from yypParser |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 52 | ** YYNSTATE the combined number of states. |
| 53 | ** YYNRULE the number of rules in the grammar |
| 54 | ** YYERRORSYMBOL is the code number of the error symbol. If not |
| 55 | ** defined, then do no error processing. |
| 56 | */ |
| 57 | %% |
| 58 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 59 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 60 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 61 | |
drh | fdbf928 | 2003-10-21 16:34:41 +0000 | [diff] [blame] | 62 | /* Next are that tables used to determine what action to take based on the |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 63 | ** current state and lookahead token. These tables are used to implement |
| 64 | ** functions that take a state number and lookahead value and return an |
| 65 | ** action integer. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 66 | ** |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 67 | ** Suppose the action integer is N. Then the action is determined as |
| 68 | ** follows |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 69 | ** |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 70 | ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead |
| 71 | ** token onto the stack and goto state N. |
| 72 | ** |
| 73 | ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. |
| 74 | ** |
| 75 | ** N == YYNSTATE+YYNRULE A syntax error has occurred. |
| 76 | ** |
| 77 | ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. |
| 78 | ** |
| 79 | ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused |
| 80 | ** slots in the yy_action[] table. |
| 81 | ** |
| 82 | ** The action table is constructed as a single large table named yy_action[]. |
| 83 | ** Given state S and lookahead X, the action is computed as |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 84 | ** |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 85 | ** yy_action[ yy_shift_ofst[S] + X ] |
| 86 | ** |
drh | 8548a05 | 2003-10-22 22:15:27 +0000 | [diff] [blame] | 87 | ** If the index value yy_shift_ofst[S]+X is out of range or if the value |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 88 | ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] |
| 89 | ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table |
| 90 | ** and that yy_default[S] should be used instead. |
| 91 | ** |
| 92 | ** The formula above is for computing the action when the lookahead is |
| 93 | ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
| 94 | ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
| 95 | ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of |
| 96 | ** YY_SHIFT_USE_DFLT. |
| 97 | ** |
| 98 | ** The following are the tables generated in this section: |
| 99 | ** |
| 100 | ** yy_action[] A single table containing all actions. |
| 101 | ** yy_lookahead[] A table containing the lookahead for each entry in |
| 102 | ** yy_action. Used to detect hash collisions. |
| 103 | ** yy_shift_ofst[] For each state, the offset into yy_action for |
| 104 | ** shifting terminals. |
| 105 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 106 | ** shifting non-terminals after a reduce. |
| 107 | ** yy_default[] Default action for each state. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 108 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 109 | %% |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 110 | #define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 111 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 112 | /* The next table maps tokens into fallback tokens. If a construct |
| 113 | ** like the following: |
| 114 | ** |
| 115 | ** %fallback ID X Y Z. |
| 116 | ** |
| 117 | ** appears in the grammer, then ID becomes a fallback token for X, Y, |
| 118 | ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
| 119 | ** but it does not parse, the type of the token is changed to ID and |
| 120 | ** the parse is retried before an error is thrown. |
| 121 | */ |
| 122 | #ifdef YYFALLBACK |
| 123 | static const YYCODETYPE yyFallback[] = { |
| 124 | %% |
| 125 | }; |
| 126 | #endif /* YYFALLBACK */ |
| 127 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 128 | /* The following structure represents a single element of the |
| 129 | ** parser's stack. Information stored includes: |
| 130 | ** |
| 131 | ** + The state number for the parser at this level of the stack. |
| 132 | ** |
| 133 | ** + The value of the token stored at this level of the stack. |
| 134 | ** (In other words, the "major" token.) |
| 135 | ** |
| 136 | ** + The semantic value stored at this level of the stack. This is |
| 137 | ** the information used by the action routines in the grammar. |
| 138 | ** It is sometimes called the "minor" token. |
| 139 | */ |
| 140 | struct yyStackEntry { |
| 141 | int stateno; /* The state-number */ |
| 142 | int major; /* The major token value. This is the code |
| 143 | ** number for the token at this stack level */ |
| 144 | YYMINORTYPE minor; /* The user-supplied minor token value. This |
| 145 | ** is the value of the token */ |
| 146 | }; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 147 | typedef struct yyStackEntry yyStackEntry; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 148 | |
| 149 | /* The state of the parser is completely contained in an instance of |
| 150 | ** the following structure */ |
| 151 | struct yyParser { |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 152 | int yyidx; /* Index of top element in stack */ |
| 153 | int yyerrcnt; /* Shifts left before out of the error */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 154 | ParseARG_SDECL /* A place to hold %extra_argument */ |
| 155 | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 156 | }; |
| 157 | typedef struct yyParser yyParser; |
| 158 | |
| 159 | #ifndef NDEBUG |
| 160 | #include <stdio.h> |
| 161 | static FILE *yyTraceFILE = 0; |
| 162 | static char *yyTracePrompt = 0; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 163 | #endif /* NDEBUG */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 164 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 165 | #ifndef NDEBUG |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 166 | /* |
| 167 | ** Turn parser tracing on by giving a stream to which to write the trace |
| 168 | ** and a prompt to preface each trace message. Tracing is turned off |
| 169 | ** by making either argument NULL |
| 170 | ** |
| 171 | ** Inputs: |
| 172 | ** <ul> |
| 173 | ** <li> A FILE* to which trace output should be written. |
| 174 | ** If NULL, then tracing is turned off. |
| 175 | ** <li> A prefix string written at the beginning of every |
| 176 | ** line of trace output. If NULL, then tracing is |
| 177 | ** turned off. |
| 178 | ** </ul> |
| 179 | ** |
| 180 | ** Outputs: |
| 181 | ** None. |
| 182 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 183 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ |
| 184 | yyTraceFILE = TraceFILE; |
| 185 | yyTracePrompt = zTracePrompt; |
| 186 | if( yyTraceFILE==0 ) yyTracePrompt = 0; |
| 187 | else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
| 188 | } |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 189 | #endif /* NDEBUG */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 190 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 191 | #ifndef NDEBUG |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 192 | /* For tracing shifts, the names of all terminals and nonterminals |
| 193 | ** are required. The following table supplies these names */ |
drh | 5719628 | 2004-10-06 15:41:16 +0000 | [diff] [blame] | 194 | static const char *const yyTokenName[] = { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 195 | %% |
| 196 | }; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 197 | #endif /* NDEBUG */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 198 | |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 199 | #ifndef NDEBUG |
| 200 | /* For tracing reduce actions, the names of all rules are required. |
| 201 | */ |
drh | 5719628 | 2004-10-06 15:41:16 +0000 | [diff] [blame] | 202 | static const char *const yyRuleName[] = { |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 203 | %% |
| 204 | }; |
| 205 | #endif /* NDEBUG */ |
drh | a1b351a | 2001-09-14 16:42:12 +0000 | [diff] [blame] | 206 | |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 207 | /* |
| 208 | ** This function returns the symbolic name associated with a token |
| 209 | ** value. |
| 210 | */ |
| 211 | const char *ParseTokenName(int tokenType){ |
drh | a1b351a | 2001-09-14 16:42:12 +0000 | [diff] [blame] | 212 | #ifndef NDEBUG |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 213 | if( tokenType>0 && tokenType<(sizeof(yyTokenName)/sizeof(yyTokenName[0])) ){ |
| 214 | return yyTokenName[tokenType]; |
| 215 | }else{ |
| 216 | return "Unknown"; |
| 217 | } |
drh | a1b351a | 2001-09-14 16:42:12 +0000 | [diff] [blame] | 218 | #else |
| 219 | return ""; |
| 220 | #endif |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 221 | } |
| 222 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 223 | /* |
| 224 | ** This function allocates a new parser. |
| 225 | ** The only argument is a pointer to a function which works like |
| 226 | ** malloc. |
| 227 | ** |
| 228 | ** Inputs: |
| 229 | ** A pointer to the function used to allocate memory. |
| 230 | ** |
| 231 | ** Outputs: |
| 232 | ** A pointer to a parser. This pointer is used in subsequent calls |
| 233 | ** to Parse and ParseFree. |
| 234 | */ |
drh | 7218ac7 | 2002-03-10 21:21:00 +0000 | [diff] [blame] | 235 | void *ParseAlloc(void *(*mallocProc)(size_t)){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 236 | yyParser *pParser; |
drh | 7218ac7 | 2002-03-10 21:21:00 +0000 | [diff] [blame] | 237 | pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 238 | if( pParser ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 239 | pParser->yyidx = -1; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 240 | } |
| 241 | return pParser; |
| 242 | } |
| 243 | |
| 244 | /* The following function deletes the value associated with a |
| 245 | ** symbol. The symbol can be either a terminal or nonterminal. |
| 246 | ** "yymajor" is the symbol code, and "yypminor" is a pointer to |
| 247 | ** the value. |
| 248 | */ |
| 249 | static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ |
| 250 | switch( yymajor ){ |
| 251 | /* Here is inserted the actions which take place when a |
| 252 | ** terminal or non-terminal is destroyed. This can happen |
| 253 | ** when the symbol is popped from the stack during a |
| 254 | ** reduce or during error processing or when a parser is |
| 255 | ** being destroyed before it is finished parsing. |
| 256 | ** |
| 257 | ** Note: during a reduce, the only symbols destroyed are those |
| 258 | ** which appear on the RHS of the rule, but which are not used |
| 259 | ** inside the C code. |
| 260 | */ |
| 261 | %% |
| 262 | default: break; /* If no destructor action specified: do nothing */ |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /* |
| 267 | ** Pop the parser's stack once. |
| 268 | ** |
| 269 | ** If there is a destructor routine associated with the token which |
| 270 | ** is popped from the stack, then call it. |
| 271 | ** |
| 272 | ** Return the major token number for the symbol popped. |
| 273 | */ |
| 274 | static int yy_pop_parser_stack(yyParser *pParser){ |
| 275 | YYCODETYPE yymajor; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 276 | yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 277 | |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 278 | if( pParser->yyidx<0 ) return 0; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 279 | #ifndef NDEBUG |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 280 | if( yyTraceFILE && pParser->yyidx>=0 ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 281 | fprintf(yyTraceFILE,"%sPopping %s\n", |
| 282 | yyTracePrompt, |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 283 | yyTokenName[yytos->major]); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 284 | } |
| 285 | #endif |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 286 | yymajor = yytos->major; |
| 287 | yy_destructor( yymajor, &yytos->minor); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 288 | pParser->yyidx--; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 289 | return yymajor; |
| 290 | } |
| 291 | |
| 292 | /* |
| 293 | ** Deallocate and destroy a parser. Destructors are all called for |
| 294 | ** all stack elements before shutting the parser down. |
| 295 | ** |
| 296 | ** Inputs: |
| 297 | ** <ul> |
| 298 | ** <li> A pointer to the parser. This should be a pointer |
| 299 | ** obtained from ParseAlloc. |
| 300 | ** <li> A pointer to a function used to reclaim memory obtained |
| 301 | ** from malloc. |
| 302 | ** </ul> |
| 303 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 304 | void ParseFree( |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 305 | void *p, /* The parser to be deleted */ |
| 306 | void (*freeProc)(void*) /* Function used to reclaim memory */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 307 | ){ |
| 308 | yyParser *pParser = (yyParser*)p; |
| 309 | if( pParser==0 ) return; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 310 | while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); |
drh | 960e8c6 | 2001-04-03 16:53:21 +0000 | [diff] [blame] | 311 | (*freeProc)((void*)pParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /* |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 315 | ** Find the appropriate action for a parser given the terminal |
| 316 | ** look-ahead token iLookAhead. |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 317 | ** |
| 318 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
| 319 | ** independent of the look-ahead. If it is, return the action, otherwise |
| 320 | ** return YY_NO_ACTION. |
| 321 | */ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 322 | static int yy_find_shift_action( |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 323 | yyParser *pParser, /* The parser */ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 324 | int iLookAhead /* The look-ahead token */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 325 | ){ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 326 | int i; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 327 | int stateno = pParser->yystack[pParser->yyidx].stateno; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 328 | |
drh | ada354d | 2005-11-05 15:03:59 +0000 | [diff] [blame] | 329 | if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 330 | return yy_default[stateno]; |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 331 | } |
| 332 | if( iLookAhead==YYNOCODE ){ |
| 333 | return YY_NO_ACTION; |
| 334 | } |
| 335 | i += iLookAhead; |
| 336 | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 337 | #ifdef YYFALLBACK |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 338 | int iFallback; /* Fallback token */ |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 339 | if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |
| 340 | && (iFallback = yyFallback[iLookAhead])!=0 ){ |
| 341 | #ifndef NDEBUG |
| 342 | if( yyTraceFILE ){ |
| 343 | fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
| 344 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
| 345 | } |
| 346 | #endif |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 347 | return yy_find_shift_action(pParser, iFallback); |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 348 | } |
| 349 | #endif |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 350 | return yy_default[stateno]; |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 351 | }else{ |
| 352 | return yy_action[i]; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | ** Find the appropriate action for a parser given the non-terminal |
| 358 | ** look-ahead token iLookAhead. |
| 359 | ** |
| 360 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
| 361 | ** independent of the look-ahead. If it is, return the action, otherwise |
| 362 | ** return YY_NO_ACTION. |
| 363 | */ |
| 364 | static int yy_find_reduce_action( |
drh | 161aba3 | 2005-02-01 04:09:36 +0000 | [diff] [blame] | 365 | int stateno, /* Current state number */ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 366 | int iLookAhead /* The look-ahead token */ |
| 367 | ){ |
| 368 | int i; |
drh | 161aba3 | 2005-02-01 04:09:36 +0000 | [diff] [blame] | 369 | /* int stateno = pParser->yystack[pParser->yyidx].stateno; */ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 370 | |
drh | ada354d | 2005-11-05 15:03:59 +0000 | [diff] [blame] | 371 | if( stateno>YY_REDUCE_MAX || |
| 372 | (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 373 | return yy_default[stateno]; |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 374 | } |
| 375 | if( iLookAhead==YYNOCODE ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 376 | return YY_NO_ACTION; |
| 377 | } |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 378 | i += iLookAhead; |
| 379 | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 380 | return yy_default[stateno]; |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 381 | }else{ |
| 382 | return yy_action[i]; |
| 383 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /* |
| 387 | ** Perform a shift action. |
| 388 | */ |
| 389 | static void yy_shift( |
| 390 | yyParser *yypParser, /* The parser to be shifted */ |
| 391 | int yyNewState, /* The new state to shift in */ |
| 392 | int yyMajor, /* The major token to shift in */ |
| 393 | YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ |
| 394 | ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 395 | yyStackEntry *yytos; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 396 | yypParser->yyidx++; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 397 | if( yypParser->yyidx>=YYSTACKDEPTH ){ |
| 398 | ParseARG_FETCH; |
| 399 | yypParser->yyidx--; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 400 | #ifndef NDEBUG |
| 401 | if( yyTraceFILE ){ |
| 402 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
| 403 | } |
| 404 | #endif |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 405 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 406 | /* Here code is inserted which will execute if the parser |
| 407 | ** stack every overflows */ |
| 408 | %% |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 409 | ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 410 | return; |
| 411 | } |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 412 | yytos = &yypParser->yystack[yypParser->yyidx]; |
| 413 | yytos->stateno = yyNewState; |
| 414 | yytos->major = yyMajor; |
| 415 | yytos->minor = *yypMinor; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 416 | #ifndef NDEBUG |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 417 | if( yyTraceFILE && yypParser->yyidx>0 ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 418 | int i; |
| 419 | fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
| 420 | fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 421 | for(i=1; i<=yypParser->yyidx; i++) |
| 422 | fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 423 | fprintf(yyTraceFILE,"\n"); |
| 424 | } |
| 425 | #endif |
| 426 | } |
| 427 | |
| 428 | /* The following table contains information about every rule that |
| 429 | ** is used during the reduce. |
| 430 | */ |
drh | 5719628 | 2004-10-06 15:41:16 +0000 | [diff] [blame] | 431 | static const struct { |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 432 | YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
| 433 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
| 434 | } yyRuleInfo[] = { |
| 435 | %% |
| 436 | }; |
| 437 | |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 438 | static void yy_accept(yyParser*); /* Forward Declaration */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 439 | |
| 440 | /* |
| 441 | ** Perform a reduce action and the shift that must immediately |
| 442 | ** follow the reduce. |
| 443 | */ |
| 444 | static void yy_reduce( |
| 445 | yyParser *yypParser, /* The parser */ |
| 446 | int yyruleno /* Number of the rule by which to reduce */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 447 | ){ |
| 448 | int yygoto; /* The next state */ |
| 449 | int yyact; /* The next action */ |
| 450 | YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 451 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 452 | int yysize; /* Amount to pop the stack */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 453 | ParseARG_FETCH; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 454 | yymsp = &yypParser->yystack[yypParser->yyidx]; |
drh | 0bd1f4e | 2002-06-06 18:54:39 +0000 | [diff] [blame] | 455 | #ifndef NDEBUG |
| 456 | if( yyTraceFILE && yyruleno>=0 |
| 457 | && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ |
| 458 | fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
| 459 | yyRuleName[yyruleno]); |
| 460 | } |
| 461 | #endif /* NDEBUG */ |
| 462 | |
drh | 7bec505 | 2005-02-06 02:45:41 +0000 | [diff] [blame] | 463 | #ifndef NDEBUG |
| 464 | /* Silence complaints from purify about yygotominor being uninitialized |
| 465 | ** in some cases when it is copied into the stack after the following |
| 466 | ** switch. yygotominor is uninitialized when a rule reduces that does |
| 467 | ** not set the value of its left-hand side nonterminal. Leaving the |
| 468 | ** value of the nonterminal uninitialized is utterly harmless as long |
| 469 | ** as the value is never used. So really the only thing this code |
| 470 | ** accomplishes is to quieten purify. |
| 471 | */ |
| 472 | memset(&yygotominor, 0, sizeof(yygotominor)); |
| 473 | #endif |
| 474 | |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 475 | switch( yyruleno ){ |
| 476 | /* Beginning here are the reduction cases. A typical example |
| 477 | ** follows: |
| 478 | ** case 0: |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 479 | ** #line <lineno> <grammarfile> |
| 480 | ** { ... } // User supplied code |
| 481 | ** #line <lineno> <thisfile> |
| 482 | ** break; |
| 483 | */ |
| 484 | %% |
| 485 | }; |
| 486 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 487 | yysize = yyRuleInfo[yyruleno].nrhs; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 488 | yypParser->yyidx -= yysize; |
drh | 161aba3 | 2005-02-01 04:09:36 +0000 | [diff] [blame] | 489 | yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 490 | if( yyact < YYNSTATE ){ |
drh | 490a73b | 2005-02-01 03:20:00 +0000 | [diff] [blame] | 491 | #ifdef NDEBUG |
| 492 | /* If we are not debugging and the reduce action popped at least |
| 493 | ** one element off the stack, then we can push the new element back |
| 494 | ** onto the stack here, and skip the stack overflow test in yy_shift(). |
| 495 | ** That gives a significant speed improvement. */ |
| 496 | if( yysize ){ |
| 497 | yypParser->yyidx++; |
| 498 | yymsp -= yysize-1; |
| 499 | yymsp->stateno = yyact; |
| 500 | yymsp->major = yygoto; |
| 501 | yymsp->minor = yygotominor; |
| 502 | }else |
| 503 | #endif |
| 504 | { |
| 505 | yy_shift(yypParser,yyact,yygoto,&yygotominor); |
| 506 | } |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 507 | }else if( yyact == YYNSTATE + YYNRULE + 1 ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 508 | yy_accept(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | |
| 512 | /* |
| 513 | ** The following code executes when the parse fails |
| 514 | */ |
| 515 | static void yy_parse_failed( |
| 516 | yyParser *yypParser /* The parser */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 517 | ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 518 | ParseARG_FETCH; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 519 | #ifndef NDEBUG |
| 520 | if( yyTraceFILE ){ |
| 521 | fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
| 522 | } |
| 523 | #endif |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 524 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 525 | /* Here code is inserted which will be executed whenever the |
| 526 | ** parser fails */ |
| 527 | %% |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 528 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | /* |
| 532 | ** The following code executes when a syntax error first occurs. |
| 533 | */ |
| 534 | static void yy_syntax_error( |
| 535 | yyParser *yypParser, /* The parser */ |
| 536 | int yymajor, /* The major type of the error token */ |
| 537 | YYMINORTYPE yyminor /* The minor type of the error token */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 538 | ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 539 | ParseARG_FETCH; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 540 | #define TOKEN (yyminor.yy0) |
| 541 | %% |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 542 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | /* |
| 546 | ** The following is executed when the parser accepts |
| 547 | */ |
| 548 | static void yy_accept( |
| 549 | yyParser *yypParser /* The parser */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 550 | ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 551 | ParseARG_FETCH; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 552 | #ifndef NDEBUG |
| 553 | if( yyTraceFILE ){ |
| 554 | fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
| 555 | } |
| 556 | #endif |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 557 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 558 | /* Here code is inserted which will be executed whenever the |
| 559 | ** parser accepts */ |
| 560 | %% |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 561 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | /* The main parser program. |
| 565 | ** The first argument is a pointer to a structure obtained from |
| 566 | ** "ParseAlloc" which describes the current state of the parser. |
| 567 | ** The second argument is the major token number. The third is |
| 568 | ** the minor token. The fourth optional argument is whatever the |
| 569 | ** user wants (and specified in the grammar) and is available for |
| 570 | ** use by the action routines. |
| 571 | ** |
| 572 | ** Inputs: |
| 573 | ** <ul> |
| 574 | ** <li> A pointer to the parser (an opaque structure.) |
| 575 | ** <li> The major token number. |
| 576 | ** <li> The minor token number. |
| 577 | ** <li> An option argument of a grammar-specified type. |
| 578 | ** </ul> |
| 579 | ** |
| 580 | ** Outputs: |
| 581 | ** None. |
| 582 | */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 583 | void Parse( |
| 584 | void *yyp, /* The parser */ |
| 585 | int yymajor, /* The major token code number */ |
| 586 | ParseTOKENTYPE yyminor /* The value for the token */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 587 | ParseARG_PDECL /* Optional %extra_argument parameter */ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 588 | ){ |
| 589 | YYMINORTYPE yyminorunion; |
| 590 | int yyact; /* The parser action. */ |
| 591 | int yyendofinput; /* True if we are at the end of input */ |
| 592 | int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
| 593 | yyParser *yypParser; /* The parser */ |
| 594 | |
| 595 | /* (re)initialize the parser, if necessary */ |
| 596 | yypParser = (yyParser*)yyp; |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 597 | if( yypParser->yyidx<0 ){ |
drh | 29f214b | 2005-05-11 14:28:14 +0000 | [diff] [blame] | 598 | /* if( yymajor==0 ) return; // not sure why this was here... */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 599 | yypParser->yyidx = 0; |
| 600 | yypParser->yyerrcnt = -1; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 601 | yypParser->yystack[0].stateno = 0; |
| 602 | yypParser->yystack[0].major = 0; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 603 | } |
| 604 | yyminorunion.yy0 = yyminor; |
| 605 | yyendofinput = (yymajor==0); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 606 | ParseARG_STORE; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 607 | |
| 608 | #ifndef NDEBUG |
| 609 | if( yyTraceFILE ){ |
| 610 | fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); |
| 611 | } |
| 612 | #endif |
| 613 | |
| 614 | do{ |
drh | 8b58201 | 2003-10-21 13:16:03 +0000 | [diff] [blame] | 615 | yyact = yy_find_shift_action(yypParser,yymajor); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 616 | if( yyact<YYNSTATE ){ |
| 617 | yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 618 | yypParser->yyerrcnt--; |
| 619 | if( yyendofinput && yypParser->yyidx>=0 ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 620 | yymajor = 0; |
| 621 | }else{ |
| 622 | yymajor = YYNOCODE; |
| 623 | } |
| 624 | }else if( yyact < YYNSTATE + YYNRULE ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 625 | yy_reduce(yypParser,yyact-YYNSTATE); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 626 | }else if( yyact == YY_ERROR_ACTION ){ |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 627 | int yymx; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 628 | #ifndef NDEBUG |
| 629 | if( yyTraceFILE ){ |
| 630 | fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); |
| 631 | } |
| 632 | #endif |
| 633 | #ifdef YYERRORSYMBOL |
| 634 | /* A syntax error has occurred. |
| 635 | ** The response to an error depends upon whether or not the |
| 636 | ** grammar defines an error token "ERROR". |
| 637 | ** |
| 638 | ** This is what we do if the grammar does define ERROR: |
| 639 | ** |
| 640 | ** * Call the %syntax_error function. |
| 641 | ** |
| 642 | ** * Begin popping the stack until we enter a state where |
| 643 | ** it is legal to shift the error symbol, then shift |
| 644 | ** the error symbol. |
| 645 | ** |
| 646 | ** * Set the error count to three. |
| 647 | ** |
| 648 | ** * Begin accepting and shifting new tokens. No new error |
| 649 | ** processing will occur until three tokens have been |
| 650 | ** shifted successfully. |
| 651 | ** |
| 652 | */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 653 | if( yypParser->yyerrcnt<0 ){ |
| 654 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 655 | } |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 656 | yymx = yypParser->yystack[yypParser->yyidx].major; |
| 657 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 658 | #ifndef NDEBUG |
| 659 | if( yyTraceFILE ){ |
| 660 | fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
| 661 | yyTracePrompt,yyTokenName[yymajor]); |
| 662 | } |
| 663 | #endif |
| 664 | yy_destructor(yymajor,&yyminorunion); |
| 665 | yymajor = YYNOCODE; |
| 666 | }else{ |
| 667 | while( |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 668 | yypParser->yyidx >= 0 && |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 669 | yymx != YYERRORSYMBOL && |
drh | f3a5888 | 2006-05-08 15:14:19 +0000 | [diff] [blame^] | 670 | (yyact = yy_find_reduce_action( |
| 671 | yypParser->yystack[yypParser->yyidx].stateno, |
| 672 | YYERRORSYMBOL)) >= YYNSTATE |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 673 | ){ |
| 674 | yy_pop_parser_stack(yypParser); |
| 675 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 676 | if( yypParser->yyidx < 0 || yymajor==0 ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 677 | yy_destructor(yymajor,&yyminorunion); |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 678 | yy_parse_failed(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 679 | yymajor = YYNOCODE; |
drh | 3ddfdf7 | 2003-12-22 14:53:19 +0000 | [diff] [blame] | 680 | }else if( yymx!=YYERRORSYMBOL ){ |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 681 | YYMINORTYPE u2; |
| 682 | u2.YYERRSYMDT = 0; |
| 683 | yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); |
| 684 | } |
| 685 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 686 | yypParser->yyerrcnt = 3; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 687 | yyerrorhit = 1; |
| 688 | #else /* YYERRORSYMBOL is not defined */ |
| 689 | /* This is what we do if the grammar does not define ERROR: |
| 690 | ** |
| 691 | ** * Report an error message, and throw away the input token. |
| 692 | ** |
| 693 | ** * If the input token is $, then fail the parse. |
| 694 | ** |
| 695 | ** As before, subsequent error messages are suppressed until |
| 696 | ** three input tokens have been successfully shifted. |
| 697 | */ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 698 | if( yypParser->yyerrcnt<=0 ){ |
| 699 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 700 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 701 | yypParser->yyerrcnt = 3; |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 702 | yy_destructor(yymajor,&yyminorunion); |
| 703 | if( yyendofinput ){ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 704 | yy_parse_failed(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 705 | } |
| 706 | yymajor = YYNOCODE; |
| 707 | #endif |
| 708 | }else{ |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 709 | yy_accept(yypParser); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 710 | yymajor = YYNOCODE; |
| 711 | } |
drh | 1f245e4 | 2002-03-11 13:55:50 +0000 | [diff] [blame] | 712 | }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
drh | 7589723 | 2000-05-29 14:26:00 +0000 | [diff] [blame] | 713 | return; |
| 714 | } |