1 /* Driver template for the LEMON parser generator.
4 ** Copyright 1991-1995 by D. Richard Hipp.
6 ** This library is free software; you can redistribute it and/or
7 ** modify it under the terms of the GNU Library General Public
8 ** License as published by the Free Software Foundation; either
9 ** version 2 of the License, or (at your option) any later version.
11 ** This library is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** Library General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ** Modified 1997 to make it suitable for use with makeheaders.
21 * Updated to sqlite lemon version 1.36
23 /* First off, code is included that follows the "include" declaration
24 ** in the input grammar file. */
27 /* Next is all token values, in a form suitable for use by makeheaders.
28 ** This section will be null unless lemon is run with the -m switch.
31 ** These constants (all generated automatically by the parser generator)
32 ** specify the various kinds of tokens (terminals) that the parser
35 ** Each symbol here is a terminal symbol in the grammar.
38 /* Make sure the INTERFACE macro is defined.
43 /* The next thing included is series of defines which control
44 ** various aspects of the generated parser.
45 ** YYCODETYPE is the data type used for storing terminal
46 ** and nonterminal numbers. "unsigned char" is
47 ** used if there are fewer than 250 terminals
48 ** and nonterminals. "int" is used otherwise.
49 ** YYNOCODE is a number of type YYCODETYPE which corresponds
50 ** to no legal terminal or nonterminal number. This
51 ** number is used to fill in empty slots of the hash
53 ** YYFALLBACK If defined, this indicates that one or more tokens
54 ** have fall-back values which should be used if the
55 ** original value of the token will not parse.
56 ** YYACTIONTYPE is the data type used for storing terminal
57 ** and nonterminal numbers. "unsigned char" is
58 ** used if there are fewer than 250 rules and
59 ** states combined. "int" is used otherwise.
60 ** ParseTOKENTYPE is the data type used for minor tokens given
61 ** directly to the parser from the tokenizer.
62 ** YYMINORTYPE is the data type used for all minor tokens.
63 ** This is typically a union of many types, one of
64 ** which is ParseTOKENTYPE. The entry in the union
65 ** for base tokens is called "yy0".
66 ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
67 ** zero the stack is dynamically sized using realloc()
68 ** ParseARG_SDECL A static variable declaration for the %extra_argument
69 ** ParseARG_PDECL A parameter declaration for the %extra_argument
70 ** ParseARG_STORE Code to store %extra_argument into yypParser
71 ** ParseARG_FETCH Code to extract %extra_argument from yypParser
72 ** YYNSTATE the combined number of states.
73 ** YYNRULE the number of rules in the grammar
74 ** YYERRORSYMBOL is the code number of the error symbol. If not
75 ** defined, then do no error processing.
78 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
79 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
80 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
82 /* The yyzerominor constant is used to initialize instances of
83 ** YYMINORTYPE objects to zero. */
84 static const YYMINORTYPE yyzerominor
= { 0 };
86 /* Define the yytestcase() macro to be a no-op if is not already defined
89 ** Applications can choose to define yytestcase() in the %include section
90 ** to a macro that can assist in verifying code coverage. For production
91 ** code the yytestcase() macro should be turned off. But it is useful
95 # define yytestcase(X)
98 /* Next are the tables used to determine what action to take based on the
99 ** current state and lookahead token. These tables are used to implement
100 ** functions that take a state number and lookahead value and return an
103 ** Suppose the action integer is N. Then the action is determined as
106 ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
107 ** token onto the stack and goto state N.
109 ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
111 ** N == YYNSTATE+YYNRULE A syntax error has occurred.
113 ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
115 ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
116 ** slots in the yy_action[] table.
118 ** The action table is constructed as a single large table named yy_action[].
119 ** Given state S and lookahead X, the action is computed as
121 ** yy_action[ yy_shift_ofst[S] + X ]
123 ** If the index value yy_shift_ofst[S]+X is out of range or if the value
124 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
125 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
126 ** and that yy_default[S] should be used instead.
128 ** The formula above is for computing the action when the lookahead is
129 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
130 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
131 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
132 ** YY_SHIFT_USE_DFLT.
134 ** The following are the tables generated in this section:
136 ** yy_action[] A single table containing all actions.
137 ** yy_lookahead[] A table containing the lookahead for each entry in
138 ** yy_action. Used to detect hash collisions.
139 ** yy_shift_ofst[] For each state, the offset into yy_action for
140 ** shifting terminals.
141 ** yy_reduce_ofst[] For each state, the offset into yy_action for
142 ** shifting non-terminals after a reduce.
143 ** yy_default[] Default action for each state.
146 #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
148 /* The next table maps tokens into fallback tokens. If a construct
149 ** like the following:
151 ** %fallback ID X Y Z.
153 ** appears in the grammar, then ID becomes a fallback token for X, Y,
154 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
155 ** but it does not parse, the type of the token is changed to ID and
156 ** the parse is retried before an error is thrown.
159 static const YYCODETYPE yyFallback
[] = {
162 #endif /* YYFALLBACK */
164 /* The following structure represents a single element of the
165 ** parser's stack. Information stored includes:
167 ** + The state number for the parser at this level of the stack.
169 ** + The value of the token stored at this level of the stack.
170 ** (In other words, the "major" token.)
172 ** + The semantic value stored at this level of the stack. This is
173 ** the information used by the action routines in the grammar.
174 ** It is sometimes called the "minor" token.
176 struct yyStackEntry
{
177 YYACTIONTYPE stateno
; /* The state-number */
178 YYCODETYPE major
; /* The major token value. This is the code
179 ** number for the token at this stack level */
180 YYMINORTYPE minor
; /* The user-supplied minor token value. This
181 ** is the value of the token */
183 typedef struct yyStackEntry yyStackEntry
;
185 /* The state of the parser is completely contained in an instance of
186 ** the following structure */
188 int yyidx
; /* Index of top element in stack */
189 #ifdef YYTRACKMAXSTACKDEPTH
190 int yyidxMax
; /* Maximum value of yyidx */
192 int yyerrcnt
; /* Shifts left before out of the error */
193 ParseARG_SDECL
/* A place to hold %extra_argument */
195 int yystksz
; /* Current side of the stack */
196 yyStackEntry
*yystack
; /* The parser's stack */
198 yyStackEntry yystack
[YYSTACKDEPTH
]; /* The parser's stack */
201 typedef struct yyParser yyParser
;
205 static FILE *yyTraceFILE
= 0;
206 static char *yyTracePrompt
= 0;
211 ** Turn parser tracing on by giving a stream to which to write the trace
212 ** and a prompt to preface each trace message. Tracing is turned off
213 ** by making either argument NULL
217 ** <li> A FILE* to which trace output should be written.
218 ** If NULL, then tracing is turned off.
219 ** <li> A prefix string written at the beginning of every
220 ** line of trace output. If NULL, then tracing is
227 void ParseTrace(FILE *TraceFILE
, char *zTracePrompt
){
228 yyTraceFILE
= TraceFILE
;
229 yyTracePrompt
= zTracePrompt
;
230 if( yyTraceFILE
==0 ){
232 }else if( yyTracePrompt
==0 ){
239 /* For tracing shifts, the names of all terminals and nonterminals
240 ** are required. The following table supplies these names */
241 static const char *const yyTokenName
[] = {
247 /* For tracing reduce actions, the names of all rules are required.
249 static const char *const yyRuleName
[] = {
257 ** Try to increase the size of the parser stack.
259 static void yyGrowStack(yyParser
*p
){
263 newSize
= p
->yystksz
*2 + 100;
264 pNew
= realloc(p
->yystack
, newSize
*sizeof(pNew
[0]));
267 p
->yystksz
= newSize
;
270 fprintf(yyTraceFILE
,"%sStack grows to %d entries!\n",
271 yyTracePrompt
, p
->yystksz
);
279 ** This function allocates a new parser.
280 ** The only argument is a pointer to a function which works like
284 ** A pointer to the function used to allocate memory.
287 ** A pointer to a parser. This pointer is used in subsequent calls
288 ** to Parse and ParseFree.
290 void *ParseAlloc(void *(*mallocProc
)(gsize
)){
292 pParser
= (yyParser
*)(*mallocProc
)( (gsize
)sizeof(yyParser
) );
295 #ifdef YYTRACKMAXSTACKDEPTH
296 pParser
->yyidxMax
= 0;
299 pParser
->yystack
= NULL
;
300 pParser
->yystksz
= 0;
301 yyGrowStack(pParser
);
307 /* The following function deletes the value associated with a
308 ** symbol. The symbol can be either a terminal or nonterminal.
309 ** "yymajor" is the symbol code, and "yypminor" is a pointer to
312 static void yy_destructor(yyParser
*yypParser
, YYCODETYPE yymajor
, YYMINORTYPE
*yypminor
){
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.
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.
326 default: break; /* If no destructor action specified: do nothing */
331 ** Pop the parser's stack once.
333 ** If there is a destructor routine associated with the token which
334 ** is popped from the stack, then call it.
336 ** Return the major token number for the symbol popped.
338 static int yy_pop_parser_stack(yyParser
*pParser
){
342 if( pParser
->yyidx
<0 ){
345 yytos
= &pParser
->yystack
[pParser
->yyidx
];
347 if( yyTraceFILE
&& pParser
->yyidx
>=0 ){
348 fprintf(yyTraceFILE
,"%sPopping %s\n",
350 yyTokenName
[yytos
->major
]);
353 yymajor
= yytos
->major
;
354 yy_destructor(pParser
, yymajor
, &yytos
->minor
);
360 ** Deallocate and destroy a parser. Destructors are all called for
361 ** all stack elements before shutting the parser down.
365 ** <li> A pointer to the parser. This should be a pointer
366 ** obtained from ParseAlloc.
367 ** <li> A pointer to a function used to reclaim memory obtained
372 void *p
, /* The parser to be deleted */
373 void (*freeProc
)(void*) /* Function used to reclaim memory */
375 yyParser
*pParser
= (yyParser
*)p
;
379 while( pParser
->yyidx
>=0 ){
380 yy_pop_parser_stack(pParser
);
383 free(pParser
->yystack
);
385 (*freeProc
)((void*)pParser
);
389 ** Return the peak depth of the stack for a parser.
391 #ifdef YYTRACKMAXSTACKDEPTH
392 int ParseStackPeak(void *p
){
393 yyParser
*pParser
= (yyParser
*)p
;
394 return pParser
->yyidxMax
;
399 ** Find the appropriate action for a parser given the terminal
400 ** look-ahead token iLookAhead.
402 ** If the look-ahead token is YYNOCODE, then check to see if the action is
403 ** independent of the look-ahead. If it is, return the action, otherwise
404 ** return YY_NO_ACTION.
406 static int yy_find_shift_action(
407 yyParser
*pParser
, /* The parser */
408 YYCODETYPE iLookAhead
/* The look-ahead token */
411 int stateno
= pParser
->yystack
[pParser
->yyidx
].stateno
;
413 if( stateno
>YY_SHIFT_MAX
414 || (i
= yy_shift_ofst
[stateno
])==YY_SHIFT_USE_DFLT
){
415 return yy_default
[stateno
];
417 assert( iLookAhead
!=YYNOCODE
);
419 if( i
<0 || i
>=YY_SZ_ACTTAB
|| yy_lookahead
[i
]!=iLookAhead
){
422 YYCODETYPE iFallback
; /* Fallback token */
423 if( iLookAhead
<sizeof(yyFallback
)/sizeof(yyFallback
[0])
424 && (iFallback
= yyFallback
[iLookAhead
])!=0 ){
427 fprintf(yyTraceFILE
, "%sFALLBACK %s => %s\n",
428 yyTracePrompt
, yyTokenName
[iLookAhead
], yyTokenName
[iFallback
]);
431 return yy_find_shift_action(pParser
, iFallback
);
436 int j
= i
- iLookAhead
+ YYWILDCARD
;
437 if( j
>=0 && j
<YY_SZ_ACTTAB
&& yy_lookahead
[j
]==YYWILDCARD
){
440 fprintf(yyTraceFILE
, "%sWILDCARD %s => %s\n",
441 yyTracePrompt
, yyTokenName
[iLookAhead
], yyTokenName
[YYWILDCARD
]);
447 #endif /* YYWILDCARD */
449 return yy_default
[stateno
];
456 ** Find the appropriate action for a parser given the non-terminal
457 ** look-ahead token iLookAhead.
459 ** If the look-ahead token is YYNOCODE, then check to see if the action is
460 ** independent of the look-ahead. If it is, return the action, otherwise
461 ** return YY_NO_ACTION.
463 static int yy_find_reduce_action(
464 int stateno
, /* Current state number */
465 YYCODETYPE iLookAhead
/* The look-ahead token */
469 if( stateno
>YY_REDUCE_MAX
){
470 return yy_default
[stateno
];
473 assert( stateno
<=YY_REDUCE_MAX
);
475 i
= yy_reduce_ofst
[stateno
];
476 assert( i
!=YY_REDUCE_USE_DFLT
);
477 assert( iLookAhead
!=YYNOCODE
);
480 if( i
<0 || i
>=YY_SZ_ACTTAB
|| yy_lookahead
[i
]!=iLookAhead
){
481 return yy_default
[stateno
];
484 assert( i
>=0 && i
<YY_SZ_ACTTAB
);
485 assert( yy_lookahead
[i
]==iLookAhead
);
491 ** The following routine is called if the stack overflows.
493 static void yyStackOverflow(yyParser
*yypParser
, YYMINORTYPE
*yypMinor _U_
){
498 fprintf(yyTraceFILE
,"%sStack Overflow!\n",yyTracePrompt
);
501 while( yypParser
->yyidx
>=0 ) {
502 yy_pop_parser_stack(yypParser
);
504 /* Here code is inserted which will execute if the parser
505 ** stack every overflows */
507 ParseARG_STORE
; /* Suppress warning about unused %extra_argument var */
511 ** Perform a shift action.
513 static void yy_shift(
514 yyParser
*yypParser
, /* The parser to be shifted */
515 int yyNewState
, /* The new state to shift in */
516 int yyMajor
, /* The major token to shift in */
517 YYMINORTYPE
*yypMinor
/* Pointer to the minor token to shift in */
521 #ifdef YYTRACKMAXSTACKDEPTH
522 if( yypParser
->yyidx
>yypParser
->yyidxMax
){
523 yypParser
->yyidxMax
= yypParser
->yyidx
;
527 if( yypParser
->yyidx
>=YYSTACKDEPTH
){
528 yyStackOverflow(yypParser
, yypMinor
);
532 if( yypParser
->yyidx
>=yypParser
->yystksz
){
533 yyGrowStack(yypParser
);
534 if( yypParser
->yyidx
>=yypParser
->yystksz
){
535 yyStackOverflow(yypParser
, yypMinor
);
540 yytos
= &yypParser
->yystack
[yypParser
->yyidx
];
541 yytos
->stateno
= (YYACTIONTYPE
)yyNewState
;
542 yytos
->major
= (YYCODETYPE
)yyMajor
;
543 yytos
->minor
= *yypMinor
;
545 if( yyTraceFILE
&& yypParser
->yyidx
>0 ){
547 fprintf(yyTraceFILE
,"%sShift %d\n",yyTracePrompt
,yyNewState
);
548 fprintf(yyTraceFILE
,"%sStack:",yyTracePrompt
);
549 for(i
=1; i
<=yypParser
->yyidx
; i
++)
550 fprintf(yyTraceFILE
," %s",yyTokenName
[yypParser
->yystack
[i
].major
]);
551 fprintf(yyTraceFILE
,"\n");
556 /* The following table contains information about every rule that
557 ** is used during the reduce.
559 static const struct {
560 YYCODETYPE lhs
; /* Symbol on the left-hand side of the rule */
561 unsigned char nrhs
; /* Number of right-hand side symbols in the rule */
566 static void yy_accept(yyParser
*yypParser
); /* Forward declaration */
569 ** Perform a reduce action and the shift that must immediately
570 ** follow the reduce.
572 static void yy_reduce(
573 yyParser
*yypParser
, /* The parser */
574 int yyruleno
/* Number of the rule by which to reduce */
576 int yygoto
; /* The next state */
577 int yyact
; /* The next action */
578 YYMINORTYPE yygotominor
; /* The LHS of the rule reduced */
579 yyStackEntry
*yymsp
; /* The top of the parser's stack */
580 int yysize
; /* Amount to pop the stack */
582 yymsp
= &yypParser
->yystack
[yypParser
->yyidx
];
584 if( yyTraceFILE
&& yyruleno
>=0
585 && yyruleno
<(int)(sizeof(yyRuleName
)/sizeof(yyRuleName
[0])) ){
586 fprintf(yyTraceFILE
, "%sReduce [%s].\n", yyTracePrompt
,
587 yyRuleName
[yyruleno
]);
591 /* Silence complaints from purify about yygotominor being uninitialized
592 ** in some cases when it is copied into the stack after the following
593 ** switch. yygotominor is uninitialized when a rule reduces that does
594 ** not set the value of its left-hand side nonterminal. Leaving the
595 ** value of the nonterminal uninitialized is utterly harmless as long
596 ** as the value is never used. So really the only thing this code
597 ** accomplishes is to quieten purify.
599 ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
600 ** without this code, their parser segfaults. I'm not sure what there
601 ** parser is doing to make this happen. This is the second bug report
602 ** from wireshark this week. Clearly they are stressing Lemon in ways
603 ** that it has not been previously stressed... (SQLite ticket #2172)
605 /*memset(&yygotominor, 0, sizeof(yygotominor));*/
606 yygotominor
= yyzerominor
;
608 /* Beginning here are the reduction cases. A typical example
611 ** #line <lineno> <grammarfile>
612 ** { ... } // User supplied code
613 ** #line <lineno> <thisfile>
618 yygoto
= yyRuleInfo
[yyruleno
].lhs
;
619 yysize
= yyRuleInfo
[yyruleno
].nrhs
;
620 yypParser
->yyidx
-= yysize
;
621 yyact
= yy_find_reduce_action(yymsp
[-yysize
].stateno
,(YYCODETYPE
)yygoto
);
622 if( yyact
< YYNSTATE
){
624 /* If we are not debugging and the reduce action popped at least
625 ** one element off the stack, then we can push the new element back
626 ** onto the stack here, and skip the stack overflow test in yy_shift().
627 ** That gives a significant speed improvement. */
631 yymsp
->stateno
= (YYACTIONTYPE
)yyact
;
632 yymsp
->major
= (YYCODETYPE
)yygoto
;
633 yymsp
->minor
= yygotominor
;
637 yy_shift(yypParser
,yyact
,yygoto
,&yygotominor
);
640 assert( yyact
== YYNSTATE
+ YYNRULE
+ 1 );
641 yy_accept(yypParser
);
646 ** The following code executes when the parse fails
648 static void yy_parse_failed(
649 yyParser
*yypParser
/* The parser */
654 fprintf(yyTraceFILE
,"%sFail!\n",yyTracePrompt
);
657 while( yypParser
->yyidx
>=0 ) {
658 yy_pop_parser_stack(yypParser
);
660 /* Here code is inserted which will be executed whenever the
663 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
667 ** The following code executes when a syntax error first occurs.
669 static void yy_syntax_error(
670 yyParser
*yypParser _U_
, /* The parser */
671 int yymajor _U_
, /* The major type of the error token */
672 YYMINORTYPE yyminor
/* The minor type of the error token */
675 #define TOKEN (yyminor.yy0)
677 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
681 ** The following is executed when the parser accepts
683 static void yy_accept(
684 yyParser
*yypParser
/* The parser */
689 fprintf(yyTraceFILE
,"%sAccept!\n",yyTracePrompt
);
692 while( yypParser
->yyidx
>=0 ){
693 yy_pop_parser_stack(yypParser
);
695 /* Here code is inserted which will be executed whenever the
698 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
701 /* The main parser program.
702 ** The first argument is a pointer to a structure obtained from
703 ** "ParseAlloc" which describes the current state of the parser.
704 ** The second argument is the major token number. The third is
705 ** the minor token. The fourth optional argument is whatever the
706 ** user wants (and specified in the grammar) and is available for
707 ** use by the action routines.
711 ** <li> A pointer to the parser (an opaque structure.)
712 ** <li> The major token number.
713 ** <li> The minor token number.
714 ** <li> An option argument of a grammar-specified type.
721 void *yyp
, /* The parser */
722 int yymajor
, /* The major token code number */
723 ParseTOKENTYPE yyminor
/* The value for the token */
724 ParseARG_PDECL
/* Optional %extra_argument parameter */
726 YYMINORTYPE yyminorunion
;
727 int yyact
; /* The parser action. */
728 int yyendofinput
; /* True if we are at the end of input */
730 int yyerrorhit
= 0; /* True if yymajor has invoked an error */
732 yyParser
*yypParser
; /* The parser */
734 /* (re)initialize the parser, if necessary */
735 yypParser
= (yyParser
*)yyp
;
736 if( yypParser
->yyidx
<0 ){
738 if( yypParser
->yystksz
<=0 ){
739 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
740 yyminorunion
= yyzerominor
;
741 yyStackOverflow(yypParser
, &yyminorunion
);
745 yypParser
->yyidx
= 0;
746 yypParser
->yyerrcnt
= -1;
747 yypParser
->yystack
[0].stateno
= 0;
748 yypParser
->yystack
[0].major
= 0;
750 yyminorunion
.yy0
= yyminor
;
751 yyendofinput
= (yymajor
==0);
756 fprintf(yyTraceFILE
,"%sInput %s\n",yyTracePrompt
,yyTokenName
[yymajor
]);
761 yyact
= yy_find_shift_action(yypParser
,(YYCODETYPE
)yymajor
);
762 if( yyact
<YYNSTATE
){
763 assert( !yyendofinput
); /* Impossible to shift the $ token */
764 yy_shift(yypParser
,yyact
,yymajor
,&yyminorunion
);
765 yypParser
->yyerrcnt
--;
767 }else if( yyact
< YYNSTATE
+ YYNRULE
){
768 yy_reduce(yypParser
,yyact
-YYNSTATE
);
773 assert( yyact
== YY_ERROR_ACTION
);
776 fprintf(yyTraceFILE
,"%sSyntax Error!\n",yyTracePrompt
);
780 /* A syntax error has occurred.
781 ** The response to an error depends upon whether or not the
782 ** grammar defines an error token "ERROR".
784 ** This is what we do if the grammar does define ERROR:
786 ** * Call the %syntax_error function.
788 ** * Begin popping the stack until we enter a state where
789 ** it is legal to shift the error symbol, then shift
792 ** * Set the error count to three.
794 ** * Begin accepting and shifting new tokens. No new error
795 ** processing will occur until three tokens have been
796 ** shifted successfully.
799 if( yypParser
->yyerrcnt
<0 ){
800 yy_syntax_error(yypParser
,yymajor
,yyminorunion
);
802 yymx
= yypParser
->yystack
[yypParser
->yyidx
].major
;
803 if( yymx
==YYERRORSYMBOL
|| yyerrorhit
){
806 fprintf(yyTraceFILE
,"%sDiscard input token %s\n",
807 yyTracePrompt
,yyTokenName
[yymajor
]);
810 yy_destructor(yypParser
,(YYCODETYPE
)yymajor
,&yyminorunion
);
814 yypParser
->yyidx
>= 0 &&
815 yymx
!= YYERRORSYMBOL
&&
816 (yyact
= yy_find_reduce_action(
817 yypParser
->yystack
[yypParser
->yyidx
].stateno
,
818 YYERRORSYMBOL
)) >= YYNSTATE
820 yy_pop_parser_stack(yypParser
);
822 if( yypParser
->yyidx
< 0 || yymajor
==0 ){
823 yy_destructor(yypParser
, (YYCODETYPE
)yymajor
,&yyminorunion
);
824 yy_parse_failed(yypParser
);
826 }else if( yymx
!=YYERRORSYMBOL
){
829 yy_shift(yypParser
,yyact
,YYERRORSYMBOL
,&u2
);
832 yypParser
->yyerrcnt
= 3;
834 #else /* YYERRORSYMBOL is not defined */
835 /* This is what we do if the grammar does not define ERROR:
837 ** * Report an error message, and throw away the input token.
839 ** * If the input token is $, then fail the parse.
841 ** As before, subsequent error messages are suppressed until
842 ** three input tokens have been successfully shifted.
844 if( yypParser
->yyerrcnt
<=0 ){
845 yy_syntax_error(yypParser
,yymajor
,yyminorunion
);
847 yypParser
->yyerrcnt
= 3;
848 yy_destructor(yypParser
, (YYCODETYPE
)yymajor
,&yyminorunion
);
850 yy_parse_failed(yypParser
);
855 }while( yymajor
!=YYNOCODE
&& yypParser
->yyidx
>=0 );