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