1 /* Driver template for the LEMON parser generator.
2 ** The author disclaims copyright to this source code.
4 /* First off, code is included that follows the "include" declaration
5 ** in the input grammar file. */
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.
12 ** These constants (all generated automatically by the parser generator)
13 ** specify the various kinds of tokens (terminals) that the parser
16 ** Each symbol here is a terminal symbol in the grammar.
19 /* Make sure the INTERFACE macro is defined.
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
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.
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. If
48 ** zero the stack is dynamically sized using realloc()
49 ** ParseARG_SDECL A static variable declaration for the %extra_argument
50 ** ParseARG_PDECL A parameter declaration for the %extra_argument
51 ** ParseARG_STORE Code to store %extra_argument into yypParser
52 ** ParseARG_FETCH Code to extract %extra_argument from yypParser
53 ** YYNSTATE the combined number of states.
54 ** YYNRULE the number of rules in the grammar
55 ** YYERRORSYMBOL is the code number of the error symbol. If not
56 ** defined, then do no error processing.
59 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
60 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
61 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
63 /* The yyzerominor constant is used to initialize instances of
64 ** YYMINORTYPE objects to zero. */
65 static const YYMINORTYPE yyzerominor
= { 0 };
67 /* Define the yytestcase() macro to be a no-op if is not already defined
70 ** Applications can choose to define yytestcase() in the %include section
71 ** to a macro that can assist in verifying code coverage. For production
72 ** code the yytestcase() macro should be turned off. But it is useful
76 # define yytestcase(X)
80 /* Next are the tables used to determine what action to take based on the
81 ** current state and lookahead token. These tables are used to implement
82 ** functions that take a state number and lookahead value and return an
85 ** Suppose the action integer is N. Then the action is determined as
88 ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
89 ** token onto the stack and goto state N.
91 ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
93 ** N == YYNSTATE+YYNRULE A syntax error has occurred.
95 ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
97 ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
98 ** slots in the yy_action[] table.
100 ** The action table is constructed as a single large table named yy_action[].
101 ** Given state S and lookahead X, the action is computed as
103 ** yy_action[ yy_shift_ofst[S] + X ]
105 ** If the index value yy_shift_ofst[S]+X is out of range or if the value
106 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
107 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
108 ** and that yy_default[S] should be used instead.
110 ** The formula above is for computing the action when the lookahead is
111 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
112 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
113 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
114 ** YY_SHIFT_USE_DFLT.
116 ** The following are the tables generated in this section:
118 ** yy_action[] A single table containing all actions.
119 ** yy_lookahead[] A table containing the lookahead for each entry in
120 ** yy_action. Used to detect hash collisions.
121 ** yy_shift_ofst[] For each state, the offset into yy_action for
122 ** shifting terminals.
123 ** yy_reduce_ofst[] For each state, the offset into yy_action for
124 ** shifting non-terminals after a reduce.
125 ** yy_default[] Default action for each state.
129 /* The next table maps tokens into fallback tokens. If a construct
130 ** like the following:
132 ** %fallback ID X Y Z.
134 ** appears in the grammar, then ID becomes a fallback token for X, Y,
135 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
136 ** but it does not parse, the type of the token is changed to ID and
137 ** the parse is retried before an error is thrown.
140 static const YYCODETYPE yyFallback
[] = {
143 #endif /* YYFALLBACK */
145 /* The following structure represents a single element of the
146 ** parser's stack. Information stored includes:
148 ** + The state number for the parser at this level of the stack.
150 ** + The value of the token stored at this level of the stack.
151 ** (In other words, the "major" token.)
153 ** + The semantic value stored at this level of the stack. This is
154 ** the information used by the action routines in the grammar.
155 ** It is sometimes called the "minor" token.
157 struct yyStackEntry
{
158 YYACTIONTYPE stateno
; /* The state-number */
159 YYCODETYPE major
; /* The major token value. This is the code
160 ** number for the token at this stack level */
161 YYMINORTYPE minor
; /* The user-supplied minor token value. This
162 ** is the value of the token */
164 typedef struct yyStackEntry yyStackEntry
;
166 /* The state of the parser is completely contained in an instance of
167 ** the following structure */
169 int yyidx
; /* Index of top element in stack */
170 #ifdef YYTRACKMAXSTACKDEPTH
171 int yyidxMax
; /* Maximum value of yyidx */
173 int yyerrcnt
; /* Shifts left before out of the error */
174 ParseARG_SDECL
/* A place to hold %extra_argument */
176 int yystksz
; /* Current side of the stack */
177 yyStackEntry
*yystack
; /* The parser's stack */
179 yyStackEntry yystack
[YYSTACKDEPTH
]; /* The parser's stack */
182 typedef struct yyParser yyParser
;
186 static FILE *yyTraceFILE
= 0;
187 static char *yyTracePrompt
= 0;
192 ** Turn parser tracing on by giving a stream to which to write the trace
193 ** and a prompt to preface each trace message. Tracing is turned off
194 ** by making either argument NULL
198 ** <li> A FILE* to which trace output should be written.
199 ** If NULL, then tracing is turned off.
200 ** <li> A prefix string written at the beginning of every
201 ** line of trace output. If NULL, then tracing is
208 void ParseTrace(FILE *TraceFILE
, char *zTracePrompt
);
209 void ParseTrace(FILE *TraceFILE
, char *zTracePrompt
){
210 yyTraceFILE
= TraceFILE
;
211 yyTracePrompt
= zTracePrompt
;
212 if( yyTraceFILE
==0 ) yyTracePrompt
= 0;
213 else if( yyTracePrompt
==0 ) yyTraceFILE
= 0;
218 /* For tracing shifts, the names of all terminals and nonterminals
219 ** are required. The following table supplies these names */
220 static const char *const yyTokenName
[] = {
226 /* For tracing reduce actions, the names of all rules are required.
228 static const char *const yyRuleName
[] = {
236 ** Try to increase the size of the parser stack.
238 static void yyGrowStack(yyParser
*p
){
242 newSize
= p
->yystksz
*2 + 100;
243 pNew
= realloc(p
->yystack
, newSize
*sizeof(pNew
[0]));
246 p
->yystksz
= newSize
;
249 fprintf(yyTraceFILE
,"%sStack grows to %d entries!\n",
250 yyTracePrompt
, p
->yystksz
);
258 ** This function allocates a new parser.
259 ** The only argument is a pointer to a function which works like
263 ** A pointer to the function used to allocate memory.
266 ** A pointer to a parser. This pointer is used in subsequent calls
267 ** to Parse and ParseFree.
269 void *ParseAlloc(void *(*mallocProc
)(size_t)){
271 pParser
= (yyParser
*)(*mallocProc
)( (size_t)sizeof(yyParser
) );
274 #ifdef YYTRACKMAXSTACKDEPTH
275 pParser
->yyidxMax
= 0;
278 pParser
->yystack
= NULL
;
279 pParser
->yystksz
= 0;
280 yyGrowStack(pParser
);
286 /* The following function deletes the value associated with a
287 ** symbol. The symbol can be either a terminal or nonterminal.
288 ** "yymajor" is the symbol code, and "yypminor" is a pointer to
291 static void yy_destructor(
292 yyParser
*yypParser
, /* The parser */
293 YYCODETYPE yymajor
, /* Type code for object to destroy */
294 YYMINORTYPE
*yypminor
/* The object to be destroyed */
298 /* Here is inserted the actions which take place when a
299 ** terminal or non-terminal is destroyed. This can happen
300 ** when the symbol is popped from the stack during a
301 ** reduce or during error processing or when a parser is
302 ** being destroyed before it is finished parsing.
304 ** Note: during a reduce, the only symbols destroyed are those
305 ** which appear on the RHS of the rule, but which are not used
306 ** inside the C code.
309 default: break; /* If no destructor action specified: do nothing */
314 ** Pop the parser's stack once.
316 ** If there is a destructor routine associated with the token which
317 ** is popped from the stack, then call it.
319 ** Return the major token number for the symbol popped.
321 static int yy_pop_parser_stack(yyParser
*pParser
){
323 yyStackEntry
*yytos
= &pParser
->yystack
[pParser
->yyidx
];
325 if( pParser
->yyidx
<0 ) return 0;
327 if( yyTraceFILE
&& pParser
->yyidx
>=0 ){
328 fprintf(yyTraceFILE
,"%sPopping %s\n",
330 yyTokenName
[yytos
->major
]);
333 yymajor
= yytos
->major
;
334 yy_destructor(pParser
, yymajor
, &yytos
->minor
);
340 ** Deallocate and destroy a parser. Destructors are all called for
341 ** all stack elements before shutting the parser down.
345 ** <li> A pointer to the parser. This should be a pointer
346 ** obtained from ParseAlloc.
347 ** <li> A pointer to a function used to reclaim memory obtained
352 void *p
, /* The parser to be deleted */
353 void (*freeProc
)(void*) /* Function used to reclaim memory */
355 yyParser
*pParser
= (yyParser
*)p
;
356 if( pParser
==0 ) return;
357 while( pParser
->yyidx
>=0 ) yy_pop_parser_stack(pParser
);
359 free(pParser
->yystack
);
361 (*freeProc
)((void*)pParser
);
365 ** Return the peak depth of the stack for a parser.
367 #ifdef YYTRACKMAXSTACKDEPTH
368 int ParseStackPeak(void *p
){
369 yyParser
*pParser
= (yyParser
*)p
;
370 return pParser
->yyidxMax
;
375 ** Find the appropriate action for a parser given the terminal
376 ** look-ahead token iLookAhead.
378 ** If the look-ahead token is YYNOCODE, then check to see if the action is
379 ** independent of the look-ahead. If it is, return the action, otherwise
380 ** return YY_NO_ACTION.
382 static int yy_find_shift_action(
383 yyParser
*pParser
, /* The parser */
384 YYCODETYPE iLookAhead
/* The look-ahead token */
387 int stateno
= pParser
->yystack
[pParser
->yyidx
].stateno
;
389 if( stateno
>YY_SHIFT_COUNT
390 || (i
= yy_shift_ofst
[stateno
])==YY_SHIFT_USE_DFLT
){
391 return yy_default
[stateno
];
393 assert( iLookAhead
!=YYNOCODE
);
395 if( i
<0 || i
>=YY_ACTTAB_COUNT
|| yy_lookahead
[i
]!=iLookAhead
){
398 YYCODETYPE iFallback
; /* Fallback token */
399 if( iLookAhead
<sizeof(yyFallback
)/sizeof(yyFallback
[0])
400 && (iFallback
= yyFallback
[iLookAhead
])!=0 ){
403 fprintf(yyTraceFILE
, "%sFALLBACK %s => %s\n",
404 yyTracePrompt
, yyTokenName
[iLookAhead
], yyTokenName
[iFallback
]);
407 return yy_find_shift_action(pParser
, iFallback
);
412 int j
= i
- iLookAhead
+ YYWILDCARD
;
414 #if YY_SHIFT_MIN+YYWILDCARD<0
417 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
420 yy_lookahead
[j
]==YYWILDCARD
424 fprintf(yyTraceFILE
, "%sWILDCARD %s => %s\n",
425 yyTracePrompt
, yyTokenName
[iLookAhead
], yyTokenName
[YYWILDCARD
]);
431 #endif /* YYWILDCARD */
433 return yy_default
[stateno
];
440 ** Find the appropriate action for a parser given the non-terminal
441 ** look-ahead token iLookAhead.
443 ** If the look-ahead token is YYNOCODE, then check to see if the action is
444 ** independent of the look-ahead. If it is, return the action, otherwise
445 ** return YY_NO_ACTION.
447 static int yy_find_reduce_action(
448 int stateno
, /* Current state number */
449 YYCODETYPE iLookAhead
/* The look-ahead token */
453 if( stateno
>YY_REDUCE_COUNT
){
454 return yy_default
[stateno
];
457 assert( stateno
<=YY_REDUCE_COUNT
);
459 i
= yy_reduce_ofst
[stateno
];
460 assert( i
!=YY_REDUCE_USE_DFLT
);
461 assert( iLookAhead
!=YYNOCODE
);
464 if( i
<0 || i
>=YY_ACTTAB_COUNT
|| yy_lookahead
[i
]!=iLookAhead
){
465 return yy_default
[stateno
];
468 assert( i
>=0 && i
<YY_ACTTAB_COUNT
);
469 assert( yy_lookahead
[i
]==iLookAhead
);
475 ** The following routine is called if the stack overflows.
477 static void yyStackOverflow(yyParser
*yypParser
, YYMINORTYPE
*yypMinor
){
482 fprintf(yyTraceFILE
,"%sStack Overflow!\n",yyTracePrompt
);
485 while( yypParser
->yyidx
>=0 ) yy_pop_parser_stack(yypParser
);
486 /* Here code is inserted which will execute if the parser
487 ** stack every overflows */
489 ParseARG_STORE
; /* Suppress warning about unused %extra_argument var */
493 ** Perform a shift action.
495 static void yy_shift(
496 yyParser
*yypParser
, /* The parser to be shifted */
497 int yyNewState
, /* The new state to shift in */
498 int yyMajor
, /* The major token to shift in */
499 YYMINORTYPE
*yypMinor
/* Pointer to the minor token to shift in */
503 #ifdef YYTRACKMAXSTACKDEPTH
504 if( yypParser
->yyidx
>yypParser
->yyidxMax
){
505 yypParser
->yyidxMax
= yypParser
->yyidx
;
509 if( yypParser
->yyidx
>=YYSTACKDEPTH
){
510 yyStackOverflow(yypParser
, yypMinor
);
514 if( yypParser
->yyidx
>=yypParser
->yystksz
){
515 yyGrowStack(yypParser
);
516 if( yypParser
->yyidx
>=yypParser
->yystksz
){
517 yyStackOverflow(yypParser
, yypMinor
);
522 yytos
= &yypParser
->yystack
[yypParser
->yyidx
];
523 yytos
->stateno
= (YYACTIONTYPE
)yyNewState
;
524 yytos
->major
= (YYCODETYPE
)yyMajor
;
525 yytos
->minor
= *yypMinor
;
527 if( yyTraceFILE
&& yypParser
->yyidx
>0 ){
529 fprintf(yyTraceFILE
,"%sShift %d\n",yyTracePrompt
,yyNewState
);
530 fprintf(yyTraceFILE
,"%sStack:",yyTracePrompt
);
531 for(i
=1; i
<=yypParser
->yyidx
; i
++)
532 fprintf(yyTraceFILE
," %s",yyTokenName
[yypParser
->yystack
[i
].major
]);
533 fprintf(yyTraceFILE
,"\n");
538 /* The following table contains information about every rule that
539 ** is used during the reduce.
541 static const struct {
542 YYCODETYPE lhs
; /* Symbol on the left-hand side of the rule */
543 unsigned char nrhs
; /* Number of right-hand side symbols in the rule */
548 static void yy_accept(yyParser
*); /* Forward Declaration */
551 ** Perform a reduce action and the shift that must immediately
552 ** follow the reduce.
554 static void yy_reduce(
555 yyParser
*yypParser
, /* The parser */
556 int yyruleno
/* Number of the rule by which to reduce */
558 int yygoto
; /* The next state */
559 int yyact
; /* The next action */
560 YYMINORTYPE yygotominor
; /* The LHS of the rule reduced */
561 yyStackEntry
*yymsp
; /* The top of the parser's stack */
562 int yysize
; /* Amount to pop the stack */
564 yymsp
= &yypParser
->yystack
[yypParser
->yyidx
];
566 if( yyTraceFILE
&& yyruleno
>=0
567 && yyruleno
<(int)(sizeof(yyRuleName
)/sizeof(yyRuleName
[0])) ){
568 fprintf(yyTraceFILE
, "%sReduce [%s].\n", yyTracePrompt
,
569 yyRuleName
[yyruleno
]);
573 /* Silence complaints from purify about yygotominor being uninitialized
574 ** in some cases when it is copied into the stack after the following
575 ** switch. yygotominor is uninitialized when a rule reduces that does
576 ** not set the value of its left-hand side nonterminal. Leaving the
577 ** value of the nonterminal uninitialized is utterly harmless as long
578 ** as the value is never used. So really the only thing this code
579 ** accomplishes is to quieten purify.
581 ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
582 ** without this code, their parser segfaults. I'm not sure what there
583 ** parser is doing to make this happen. This is the second bug report
584 ** from wireshark this week. Clearly they are stressing Lemon in ways
585 ** that it has not been previously stressed... (SQLite ticket #2172)
587 /*memset(&yygotominor, 0, sizeof(yygotominor));*/
588 yygotominor
= yyzerominor
;
592 /* Beginning here are the reduction cases. A typical example
595 ** #line <lineno> <grammarfile>
596 ** { ... } // User supplied code
597 ** #line <lineno> <thisfile>
602 yygoto
= yyRuleInfo
[yyruleno
].lhs
;
603 yysize
= yyRuleInfo
[yyruleno
].nrhs
;
604 yypParser
->yyidx
-= yysize
;
605 yyact
= yy_find_reduce_action(yymsp
[-yysize
].stateno
,(YYCODETYPE
)yygoto
);
606 if( yyact
< YYNSTATE
){
608 /* If we are not debugging and the reduce action popped at least
609 ** one element off the stack, then we can push the new element back
610 ** onto the stack here, and skip the stack overflow test in yy_shift().
611 ** That gives a significant speed improvement. */
615 yymsp
->stateno
= (YYACTIONTYPE
)yyact
;
616 yymsp
->major
= (YYCODETYPE
)yygoto
;
617 yymsp
->minor
= yygotominor
;
621 yy_shift(yypParser
,yyact
,yygoto
,&yygotominor
);
624 assert( yyact
== YYNSTATE
+ YYNRULE
+ 1 );
625 yy_accept(yypParser
);
630 ** The following code executes when the parse fails
632 #ifndef YYNOERRORRECOVERY
633 static void yy_parse_failed(
634 yyParser
*yypParser
/* The parser */
639 fprintf(yyTraceFILE
,"%sFail!\n",yyTracePrompt
);
642 while( yypParser
->yyidx
>=0 ) yy_pop_parser_stack(yypParser
);
643 /* Here code is inserted which will be executed whenever the
646 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
648 #endif /* YYNOERRORRECOVERY */
651 ** The following code executes when a syntax error first occurs.
653 static void yy_syntax_error(
654 yyParser
*yypParser
, /* The parser */
655 int yymajor
, /* The major type of the error token */
656 YYMINORTYPE yyminor
/* The minor type of the error token */
659 #define TOKEN (yyminor.yy0)
661 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
665 ** The following is executed when the parser accepts
667 static void yy_accept(
668 yyParser
*yypParser
/* The parser */
673 fprintf(yyTraceFILE
,"%sAccept!\n",yyTracePrompt
);
676 while( yypParser
->yyidx
>=0 ) yy_pop_parser_stack(yypParser
);
677 /* Here code is inserted which will be executed whenever the
680 ParseARG_STORE
; /* Suppress warning about unused %extra_argument variable */
683 /* The main parser program.
684 ** The first argument is a pointer to a structure obtained from
685 ** "ParseAlloc" which describes the current state of the parser.
686 ** The second argument is the major token number. The third is
687 ** the minor token. The fourth optional argument is whatever the
688 ** user wants (and specified in the grammar) and is available for
689 ** use by the action routines.
693 ** <li> A pointer to the parser (an opaque structure.)
694 ** <li> The major token number.
695 ** <li> The minor token number.
696 ** <li> An option argument of a grammar-specified type.
703 void *yyp
, /* The parser */
704 int yymajor
, /* The major token code number */
705 ParseTOKENTYPE yyminor
/* The value for the token */
706 ParseARG_PDECL
/* Optional %extra_argument parameter */
708 YYMINORTYPE yyminorunion
;
709 int yyact
; /* The parser action. */
710 int yyendofinput
; /* True if we are at the end of input */
712 int yyerrorhit
= 0; /* True if yymajor has invoked an error */
714 yyParser
*yypParser
; /* The parser */
716 /* (re)initialize the parser, if necessary */
717 yypParser
= (yyParser
*)yyp
;
718 if( yypParser
->yyidx
<0 ){
720 if( yypParser
->yystksz
<=0 ){
721 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
722 yyminorunion
= yyzerominor
;
723 yyStackOverflow(yypParser
, &yyminorunion
);
727 yypParser
->yyidx
= 0;
728 yypParser
->yyerrcnt
= -1;
729 yypParser
->yystack
[0].stateno
= 0;
730 yypParser
->yystack
[0].major
= 0;
732 yyminorunion
.yy0
= yyminor
;
733 yyendofinput
= (yymajor
==0);
738 fprintf(yyTraceFILE
,"%sInput %s\n",yyTracePrompt
,yyTokenName
[yymajor
]);
743 yyact
= yy_find_shift_action(yypParser
,(YYCODETYPE
)yymajor
);
744 if( yyact
<YYNSTATE
){
745 assert( !yyendofinput
); /* Impossible to shift the $ token */
746 yy_shift(yypParser
,yyact
,yymajor
,&yyminorunion
);
747 yypParser
->yyerrcnt
--;
749 }else if( yyact
< YYNSTATE
+ YYNRULE
){
750 yy_reduce(yypParser
,yyact
-YYNSTATE
);
752 assert( yyact
== YY_ERROR_ACTION
);
758 fprintf(yyTraceFILE
,"%sSyntax Error!\n",yyTracePrompt
);
762 /* A syntax error has occurred.
763 ** The response to an error depends upon whether or not the
764 ** grammar defines an error token "ERROR".
766 ** This is what we do if the grammar does define ERROR:
768 ** * Call the %syntax_error function.
770 ** * Begin popping the stack until we enter a state where
771 ** it is legal to shift the error symbol, then shift
774 ** * Set the error count to three.
776 ** * Begin accepting and shifting new tokens. No new error
777 ** processing will occur until three tokens have been
778 ** shifted successfully.
781 if( yypParser
->yyerrcnt
<0 ){
782 yy_syntax_error(yypParser
,yymajor
,yyminorunion
);
784 yymx
= yypParser
->yystack
[yypParser
->yyidx
].major
;
785 if( yymx
==YYERRORSYMBOL
|| yyerrorhit
){
788 fprintf(yyTraceFILE
,"%sDiscard input token %s\n",
789 yyTracePrompt
,yyTokenName
[yymajor
]);
792 yy_destructor(yypParser
, (YYCODETYPE
)yymajor
,&yyminorunion
);
796 yypParser
->yyidx
>= 0 &&
797 yymx
!= YYERRORSYMBOL
&&
798 (yyact
= yy_find_reduce_action(
799 yypParser
->yystack
[yypParser
->yyidx
].stateno
,
800 YYERRORSYMBOL
)) >= YYNSTATE
802 yy_pop_parser_stack(yypParser
);
804 if( yypParser
->yyidx
< 0 || yymajor
==0 ){
805 yy_destructor(yypParser
,(YYCODETYPE
)yymajor
,&yyminorunion
);
806 yy_parse_failed(yypParser
);
808 }else if( yymx
!=YYERRORSYMBOL
){
811 yy_shift(yypParser
,yyact
,YYERRORSYMBOL
,&u2
);
814 yypParser
->yyerrcnt
= 3;
816 #elif defined(YYNOERRORRECOVERY)
817 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
818 ** do any kind of error recovery. Instead, simply invoke the syntax
819 ** error routine and continue going as if nothing had happened.
821 ** Applications can set this macro (for example inside %include) if
822 ** they intend to abandon the parse upon the first syntax error seen.
824 yy_syntax_error(yypParser
,yymajor
,yyminorunion
);
825 yy_destructor(yypParser
,(YYCODETYPE
)yymajor
,&yyminorunion
);
828 #else /* YYERRORSYMBOL is not defined */
829 /* This is what we do if the grammar does not define ERROR:
831 ** * Report an error message, and throw away the input token.
833 ** * If the input token is $, then fail the parse.
835 ** As before, subsequent error messages are suppressed until
836 ** three input tokens have been successfully shifted.
838 if( yypParser
->yyerrcnt
<=0 ){
839 yy_syntax_error(yypParser
,yymajor
,yyminorunion
);
841 yypParser
->yyerrcnt
= 3;
842 yy_destructor(yypParser
,(YYCODETYPE
)yymajor
,&yyminorunion
);
844 yy_parse_failed(yypParser
);
849 }while( yymajor
!=YYNOCODE
&& yypParser
->yyidx
>=0 );