blob: e31390408200f3f6e278b25dd35e30536e2e00b0 [file] [log] [blame]
drh82415f22015-11-09 19:33:42 +00001/*
2** 2000-05-29
drh75897232000-05-29 14:26:00 +00003**
drh82415f22015-11-09 19:33:42 +00004** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
6**
7** May you do good and not evil.
8** May you find forgiveness for yourself and forgive others.
9** May you share freely, never taking more than you give.
10**
11*************************************************************************
12** Driver template for the LEMON parser generator.
13**
14** The "lemon" program processes an LALR(1) input grammar file, then uses
15** this template to construct a parser. The "lemon" program inserts text
16** at each "%%" line. Also, any "P-a-r-s-e" identifer prefix (without the
17** interstitial "-" characters) contained in this template is changed into
18** the value of the %name directive from the grammar. Otherwise, the content
19** of this template is copied straight through into the generate parser
20** source file.
21**
22** The following is the concatenation of all %include directives from the
23** input grammar file:
drh75897232000-05-29 14:26:00 +000024*/
drh82415f22015-11-09 19:33:42 +000025#include <stdio.h>
26/************ Begin %include sections from the grammar ************************/
drh75897232000-05-29 14:26:00 +000027%%
drh82415f22015-11-09 19:33:42 +000028/**************** End of %include directives **********************************/
29/* These constants specify the various numeric values for terminal symbols
30** in a format understandable to "makeheaders". This section is blank unless
31** "lemon" is run with the "-m" command-line option.
32***************** Begin makeheaders token definitions *************************/
33%%
34/**************** End makeheaders token definitions ***************************/
drh822a62f2015-11-09 19:35:18 +000035
36/* The next sections is a series of control #defines.
drh75897232000-05-29 14:26:00 +000037** various aspects of the generated parser.
drh82415f22015-11-09 19:33:42 +000038** YYCODETYPE is the data type used to store the integer codes
39** that represent terminal and non-terminal symbols.
40** "unsigned char" is used if there are fewer than
41** 256 symbols. Larger types otherwise.
42** YYNOCODE is a number of type YYCODETYPE that is not used for
43** any terminal or nonterminal symbol.
drh0bd1f4e2002-06-06 18:54:39 +000044** YYFALLBACK If defined, this indicates that one or more tokens
drh82415f22015-11-09 19:33:42 +000045** (also known as: "terminal symbols") have fall-back
46** values which should be used if the original symbol
47** would not parse. This permits keywords to sometimes
48** be used as identifiers, for example.
49** YYACTIONTYPE is the data type used for "action codes" - numbers
50** that indicate what to do in response to the next
51** token.
52** ParseTOKENTYPE is the data type used for minor type for terminal
53** symbols. Background: A "minor type" is a semantic
54** value associated with a terminal or non-terminal
55** symbols. For example, for an "ID" terminal symbol,
56** the minor type might be the name of the identifier.
57** Each non-terminal can have a different minor type.
58** Terminal symbols all have the same minor type, though.
59** This macros defines the minor type for terminal
60** symbols.
61** YYMINORTYPE is the data type used for all minor types.
drh75897232000-05-29 14:26:00 +000062** This is typically a union of many types, one of
63** which is ParseTOKENTYPE. The entry in the union
drh82415f22015-11-09 19:33:42 +000064** for terminal symbols is called "yy0".
drhb19fd012007-03-29 01:44:45 +000065** YYSTACKDEPTH is the maximum depth of the parser's stack. If
66** zero the stack is dynamically sized using realloc()
drh1f245e42002-03-11 13:55:50 +000067** ParseARG_SDECL A static variable declaration for the %extra_argument
68** ParseARG_PDECL A parameter declaration for the %extra_argument
69** ParseARG_STORE Code to store %extra_argument into yypParser
70** ParseARG_FETCH Code to extract %extra_argument from yypParser
drh75897232000-05-29 14:26:00 +000071** YYERRORSYMBOL is the code number of the error symbol. If not
72** defined, then do no error processing.
drh3bd48ab2015-09-07 18:23:37 +000073** YYNSTATE the combined number of states.
74** YYNRULE the number of rules in the grammar
75** YY_MAX_SHIFT Maximum value for shift actions
76** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
77** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
78** YY_MIN_REDUCE Maximum value for reduce actions
79** YY_ERROR_ACTION The yy_action[] code for syntax error
80** YY_ACCEPT_ACTION The yy_action[] code for accept
81** YY_NO_ACTION The yy_action[] code for no-op
drh75897232000-05-29 14:26:00 +000082*/
drh82415f22015-11-09 19:33:42 +000083#ifndef INTERFACE
84# define INTERFACE 1
85#endif
86/************* Begin control #defines *****************************************/
drh75897232000-05-29 14:26:00 +000087%%
drh82415f22015-11-09 19:33:42 +000088/************* End control #defines *******************************************/
drh75897232000-05-29 14:26:00 +000089
drh8a415d32009-06-12 13:53:51 +000090/* Define the yytestcase() macro to be a no-op if is not already defined
91** otherwise.
92**
93** Applications can choose to define yytestcase() in the %include section
94** to a macro that can assist in verifying code coverage. For production
95** code the yytestcase() macro should be turned off. But it is useful
96** for testing.
97*/
98#ifndef yytestcase
99# define yytestcase(X)
100#endif
101
drh26c9b5e2008-04-11 14:56:53 +0000102
drh34ff57b2008-07-14 12:27:51 +0000103/* Next are the tables used to determine what action to take based on the
drh8b582012003-10-21 13:16:03 +0000104** current state and lookahead token. These tables are used to implement
105** functions that take a state number and lookahead value and return an
106** action integer.
drh75897232000-05-29 14:26:00 +0000107**
drh8548a052003-10-22 22:15:27 +0000108** Suppose the action integer is N. Then the action is determined as
109** follows
drh75897232000-05-29 14:26:00 +0000110**
drh3bd48ab2015-09-07 18:23:37 +0000111** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
drh8548a052003-10-22 22:15:27 +0000112** token onto the stack and goto state N.
113**
drh3bd48ab2015-09-07 18:23:37 +0000114** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
115** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
drh8548a052003-10-22 22:15:27 +0000116**
drh3bd48ab2015-09-07 18:23:37 +0000117** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
118** and YY_MAX_REDUCE
119
120** N == YY_ERROR_ACTION A syntax error has occurred.
drh8548a052003-10-22 22:15:27 +0000121**
drh3bd48ab2015-09-07 18:23:37 +0000122** N == YY_ACCEPT_ACTION The parser accepts its input.
drh8548a052003-10-22 22:15:27 +0000123**
drh3bd48ab2015-09-07 18:23:37 +0000124** N == YY_NO_ACTION No such action. Denotes unused
drh8548a052003-10-22 22:15:27 +0000125** slots in the yy_action[] table.
126**
127** The action table is constructed as a single large table named yy_action[].
128** Given state S and lookahead X, the action is computed as
drh75897232000-05-29 14:26:00 +0000129**
drh8b582012003-10-21 13:16:03 +0000130** yy_action[ yy_shift_ofst[S] + X ]
131**
drh8548a052003-10-22 22:15:27 +0000132** If the index value yy_shift_ofst[S]+X is out of range or if the value
drh8b582012003-10-21 13:16:03 +0000133** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
134** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
135** and that yy_default[S] should be used instead.
136**
137** The formula above is for computing the action when the lookahead is
138** a terminal symbol. If the lookahead is a non-terminal (as occurs after
139** a reduce action) then the yy_reduce_ofst[] array is used in place of
140** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
141** YY_SHIFT_USE_DFLT.
142**
143** The following are the tables generated in this section:
144**
145** yy_action[] A single table containing all actions.
146** yy_lookahead[] A table containing the lookahead for each entry in
147** yy_action. Used to detect hash collisions.
148** yy_shift_ofst[] For each state, the offset into yy_action for
149** shifting terminals.
150** yy_reduce_ofst[] For each state, the offset into yy_action for
151** shifting non-terminals after a reduce.
152** yy_default[] Default action for each state.
drh82415f22015-11-09 19:33:42 +0000153**
154*********** Begin parsing tables **********************************************/
drh75897232000-05-29 14:26:00 +0000155%%
drh82415f22015-11-09 19:33:42 +0000156/********** End of lemon-generated parsing tables *****************************/
drh75897232000-05-29 14:26:00 +0000157
drh82415f22015-11-09 19:33:42 +0000158/* The next table maps tokens (terminal symbols) into fallback tokens.
159** If a construct like the following:
drh0bd1f4e2002-06-06 18:54:39 +0000160**
161** %fallback ID X Y Z.
162**
drh34ff57b2008-07-14 12:27:51 +0000163** appears in the grammar, then ID becomes a fallback token for X, Y,
drh0bd1f4e2002-06-06 18:54:39 +0000164** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
165** but it does not parse, the type of the token is changed to ID and
166** the parse is retried before an error is thrown.
drh82415f22015-11-09 19:33:42 +0000167**
168** This feature can be used, for example, to cause some keywords in a language
169** to revert to identifiers if they keyword does not apply in the context where
170** it appears.
drh0bd1f4e2002-06-06 18:54:39 +0000171*/
172#ifdef YYFALLBACK
173static const YYCODETYPE yyFallback[] = {
174%%
175};
176#endif /* YYFALLBACK */
177
drh75897232000-05-29 14:26:00 +0000178/* The following structure represents a single element of the
179** parser's stack. Information stored includes:
180**
181** + The state number for the parser at this level of the stack.
182**
183** + The value of the token stored at this level of the stack.
184** (In other words, the "major" token.)
185**
186** + The semantic value stored at this level of the stack. This is
187** the information used by the action routines in the grammar.
188** It is sometimes called the "minor" token.
drha248a722015-09-07 19:52:55 +0000189**
190** After the "shift" half of a SHIFTREDUCE action, the stateno field
191** actually contains the reduce action for the second half of the
192** SHIFTREDUCE.
drh75897232000-05-29 14:26:00 +0000193*/
194struct yyStackEntry {
drha248a722015-09-07 19:52:55 +0000195 YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
drh2abcd582008-07-24 23:34:07 +0000196 YYCODETYPE major; /* The major token value. This is the code
197 ** number for the token at this stack level */
198 YYMINORTYPE minor; /* The user-supplied minor token value. This
199 ** is the value of the token */
drh75897232000-05-29 14:26:00 +0000200};
drh1f245e42002-03-11 13:55:50 +0000201typedef struct yyStackEntry yyStackEntry;
drh75897232000-05-29 14:26:00 +0000202
203/* The state of the parser is completely contained in an instance of
204** the following structure */
205struct yyParser {
drh1f245e42002-03-11 13:55:50 +0000206 int yyidx; /* Index of top element in stack */
drhec424a52008-07-25 15:39:03 +0000207#ifdef YYTRACKMAXSTACKDEPTH
208 int yyidxMax; /* Maximum value of yyidx */
209#endif
drhdab943c2016-02-16 01:01:43 +0000210#ifndef YYNOERRORRECOVERY
drh1f245e42002-03-11 13:55:50 +0000211 int yyerrcnt; /* Shifts left before out of the error */
drhdab943c2016-02-16 01:01:43 +0000212#endif
drh1f245e42002-03-11 13:55:50 +0000213 ParseARG_SDECL /* A place to hold %extra_argument */
drhb19fd012007-03-29 01:44:45 +0000214#if YYSTACKDEPTH<=0
215 int yystksz; /* Current side of the stack */
216 yyStackEntry *yystack; /* The parser's stack */
217#else
drh1f245e42002-03-11 13:55:50 +0000218 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
drhb19fd012007-03-29 01:44:45 +0000219#endif
drh75897232000-05-29 14:26:00 +0000220};
221typedef struct yyParser yyParser;
222
223#ifndef NDEBUG
224#include <stdio.h>
225static FILE *yyTraceFILE = 0;
226static char *yyTracePrompt = 0;
drh0bd1f4e2002-06-06 18:54:39 +0000227#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000228
drh0bd1f4e2002-06-06 18:54:39 +0000229#ifndef NDEBUG
drh75897232000-05-29 14:26:00 +0000230/*
231** Turn parser tracing on by giving a stream to which to write the trace
232** and a prompt to preface each trace message. Tracing is turned off
233** by making either argument NULL
234**
235** Inputs:
236** <ul>
237** <li> A FILE* to which trace output should be written.
238** If NULL, then tracing is turned off.
239** <li> A prefix string written at the beginning of every
240** line of trace output. If NULL, then tracing is
241** turned off.
242** </ul>
243**
244** Outputs:
245** None.
246*/
drh75897232000-05-29 14:26:00 +0000247void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
248 yyTraceFILE = TraceFILE;
249 yyTracePrompt = zTracePrompt;
250 if( yyTraceFILE==0 ) yyTracePrompt = 0;
251 else if( yyTracePrompt==0 ) yyTraceFILE = 0;
252}
drh0bd1f4e2002-06-06 18:54:39 +0000253#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000254
drh0bd1f4e2002-06-06 18:54:39 +0000255#ifndef NDEBUG
drh75897232000-05-29 14:26:00 +0000256/* For tracing shifts, the names of all terminals and nonterminals
257** are required. The following table supplies these names */
drh57196282004-10-06 15:41:16 +0000258static const char *const yyTokenName[] = {
drh75897232000-05-29 14:26:00 +0000259%%
260};
drh0bd1f4e2002-06-06 18:54:39 +0000261#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000262
drh0bd1f4e2002-06-06 18:54:39 +0000263#ifndef NDEBUG
264/* For tracing reduce actions, the names of all rules are required.
265*/
drh57196282004-10-06 15:41:16 +0000266static const char *const yyRuleName[] = {
drh0bd1f4e2002-06-06 18:54:39 +0000267%%
268};
269#endif /* NDEBUG */
drha1b351a2001-09-14 16:42:12 +0000270
drh960e8c62001-04-03 16:53:21 +0000271
drhb19fd012007-03-29 01:44:45 +0000272#if YYSTACKDEPTH<=0
273/*
274** Try to increase the size of the parser stack.
275*/
276static void yyGrowStack(yyParser *p){
277 int newSize;
278 yyStackEntry *pNew;
279
280 newSize = p->yystksz*2 + 100;
281 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
282 if( pNew ){
283 p->yystack = pNew;
284 p->yystksz = newSize;
285#ifndef NDEBUG
286 if( yyTraceFILE ){
287 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
288 yyTracePrompt, p->yystksz);
289 }
290#endif
291 }
292}
293#endif
294
drh82415f22015-11-09 19:33:42 +0000295/* Datatype of the argument to the memory allocated passed as the
296** second argument to ParseAlloc() below. This can be changed by
297** putting an appropriate #define in the %include section of the input
298** grammar.
299*/
300#ifndef YYMALLOCARGTYPE
301# define YYMALLOCARGTYPE size_t
302#endif
303
drh75897232000-05-29 14:26:00 +0000304/*
305** This function allocates a new parser.
306** The only argument is a pointer to a function which works like
307** malloc.
308**
309** Inputs:
310** A pointer to the function used to allocate memory.
311**
312** Outputs:
313** A pointer to a parser. This pointer is used in subsequent calls
314** to Parse and ParseFree.
315*/
drh82415f22015-11-09 19:33:42 +0000316void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
drh75897232000-05-29 14:26:00 +0000317 yyParser *pParser;
drh82415f22015-11-09 19:33:42 +0000318 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
drh75897232000-05-29 14:26:00 +0000319 if( pParser ){
drh1f245e42002-03-11 13:55:50 +0000320 pParser->yyidx = -1;
drhec424a52008-07-25 15:39:03 +0000321#ifdef YYTRACKMAXSTACKDEPTH
322 pParser->yyidxMax = 0;
323#endif
drhb19fd012007-03-29 01:44:45 +0000324#if YYSTACKDEPTH<=0
drh4c651782008-11-18 23:25:54 +0000325 pParser->yystack = NULL;
326 pParser->yystksz = 0;
drhb19fd012007-03-29 01:44:45 +0000327 yyGrowStack(pParser);
328#endif
drh75897232000-05-29 14:26:00 +0000329 }
330 return pParser;
331}
332
drh82415f22015-11-09 19:33:42 +0000333/* The following function deletes the "minor type" or semantic value
334** associated with a symbol. The symbol can be either a terminal
335** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
336** a pointer to the value to be deleted. The code used to do the
337** deletions is derived from the %destructor and/or %token_destructor
338** directives of the input grammar.
drh75897232000-05-29 14:26:00 +0000339*/
drh633e6d52008-07-28 19:34:53 +0000340static void yy_destructor(
341 yyParser *yypParser, /* The parser */
342 YYCODETYPE yymajor, /* Type code for object to destroy */
343 YYMINORTYPE *yypminor /* The object to be destroyed */
344){
345 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000346 switch( yymajor ){
347 /* Here is inserted the actions which take place when a
348 ** terminal or non-terminal is destroyed. This can happen
349 ** when the symbol is popped from the stack during a
350 ** reduce or during error processing or when a parser is
351 ** being destroyed before it is finished parsing.
352 **
353 ** Note: during a reduce, the only symbols destroyed are those
drh82415f22015-11-09 19:33:42 +0000354 ** which appear on the RHS of the rule, but which are *not* used
drh75897232000-05-29 14:26:00 +0000355 ** inside the C code.
356 */
drh82415f22015-11-09 19:33:42 +0000357/********* Begin destructor definitions ***************************************/
drh75897232000-05-29 14:26:00 +0000358%%
drh82415f22015-11-09 19:33:42 +0000359/********* End destructor definitions *****************************************/
drh75897232000-05-29 14:26:00 +0000360 default: break; /* If no destructor action specified: do nothing */
361 }
362}
363
364/*
365** Pop the parser's stack once.
366**
367** If there is a destructor routine associated with the token which
368** is popped from the stack, then call it.
drh75897232000-05-29 14:26:00 +0000369*/
drh3781f012015-11-09 14:11:37 +0000370static void yy_pop_parser_stack(yyParser *pParser){
371 yyStackEntry *yytos;
372 assert( pParser->yyidx>=0 );
373 yytos = &pParser->yystack[pParser->yyidx--];
drh75897232000-05-29 14:26:00 +0000374#ifndef NDEBUG
drh3781f012015-11-09 14:11:37 +0000375 if( yyTraceFILE ){
drh75897232000-05-29 14:26:00 +0000376 fprintf(yyTraceFILE,"%sPopping %s\n",
377 yyTracePrompt,
drh3ddfdf72003-12-22 14:53:19 +0000378 yyTokenName[yytos->major]);
drh75897232000-05-29 14:26:00 +0000379 }
380#endif
drh3781f012015-11-09 14:11:37 +0000381 yy_destructor(pParser, yytos->major, &yytos->minor);
drh75897232000-05-29 14:26:00 +0000382}
383
384/*
drh82415f22015-11-09 19:33:42 +0000385** Deallocate and destroy a parser. Destructors are called for
drh75897232000-05-29 14:26:00 +0000386** all stack elements before shutting the parser down.
387**
drh82415f22015-11-09 19:33:42 +0000388** If the YYPARSEFREENEVERNULL macro exists (for example because it
389** is defined in a %include section of the input grammar) then it is
390** assumed that the input pointer is never NULL.
drh75897232000-05-29 14:26:00 +0000391*/
drh75897232000-05-29 14:26:00 +0000392void ParseFree(
drh960e8c62001-04-03 16:53:21 +0000393 void *p, /* The parser to be deleted */
394 void (*freeProc)(void*) /* Function used to reclaim memory */
drh75897232000-05-29 14:26:00 +0000395){
396 yyParser *pParser = (yyParser*)p;
drh82415f22015-11-09 19:33:42 +0000397#ifndef YYPARSEFREENEVERNULL
drh75897232000-05-29 14:26:00 +0000398 if( pParser==0 ) return;
drh82415f22015-11-09 19:33:42 +0000399#endif
drh1f245e42002-03-11 13:55:50 +0000400 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
drhb19fd012007-03-29 01:44:45 +0000401#if YYSTACKDEPTH<=0
402 free(pParser->yystack);
403#endif
drh960e8c62001-04-03 16:53:21 +0000404 (*freeProc)((void*)pParser);
drh75897232000-05-29 14:26:00 +0000405}
406
407/*
drhec424a52008-07-25 15:39:03 +0000408** Return the peak depth of the stack for a parser.
409*/
410#ifdef YYTRACKMAXSTACKDEPTH
411int ParseStackPeak(void *p){
412 yyParser *pParser = (yyParser*)p;
413 return pParser->yyidxMax;
414}
415#endif
416
417/*
drh8b582012003-10-21 13:16:03 +0000418** Find the appropriate action for a parser given the terminal
419** look-ahead token iLookAhead.
drh75897232000-05-29 14:26:00 +0000420*/
drh4ef07702016-03-16 19:45:54 +0000421static unsigned int yy_find_shift_action(
drh75897232000-05-29 14:26:00 +0000422 yyParser *pParser, /* The parser */
drhd9f291e2006-06-13 11:15:47 +0000423 YYCODETYPE iLookAhead /* The look-ahead token */
drh75897232000-05-29 14:26:00 +0000424){
drh8b582012003-10-21 13:16:03 +0000425 int i;
drh3ddfdf72003-12-22 14:53:19 +0000426 int stateno = pParser->yystack[pParser->yyidx].stateno;
drha4414042015-11-09 15:06:26 +0000427
428 if( stateno>=YY_MIN_REDUCE ) return stateno;
drhae2a4082015-09-07 20:02:39 +0000429 assert( stateno <= YY_SHIFT_COUNT );
drha4414042015-11-09 15:06:26 +0000430 do{
431 i = yy_shift_ofst[stateno];
432 if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
433 assert( iLookAhead!=YYNOCODE );
434 i += iLookAhead;
435 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
436 if( iLookAhead>0 ){
drh4767d972006-06-14 15:03:49 +0000437#ifdef YYFALLBACK
drha4414042015-11-09 15:06:26 +0000438 YYCODETYPE iFallback; /* Fallback token */
439 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
440 && (iFallback = yyFallback[iLookAhead])!=0 ){
drh4767d972006-06-14 15:03:49 +0000441#ifndef NDEBUG
442 if( yyTraceFILE ){
drha4414042015-11-09 15:06:26 +0000443 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
444 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
drh4767d972006-06-14 15:03:49 +0000445 }
drha4414042015-11-09 15:06:26 +0000446#endif
447 assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
448 iLookAhead = iFallback;
449 continue;
drhe09daa92006-06-10 13:29:31 +0000450 }
drha4414042015-11-09 15:06:26 +0000451#endif
452#ifdef YYWILDCARD
453 {
454 int j = i - iLookAhead + YYWILDCARD;
455 if(
456#if YY_SHIFT_MIN+YYWILDCARD<0
457 j>=0 &&
458#endif
459#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
460 j<YY_ACTTAB_COUNT &&
461#endif
462 yy_lookahead[j]==YYWILDCARD
463 ){
464#ifndef NDEBUG
465 if( yyTraceFILE ){
466 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
467 yyTracePrompt, yyTokenName[iLookAhead],
468 yyTokenName[YYWILDCARD]);
469 }
470#endif /* NDEBUG */
471 return yy_action[j];
472 }
473 }
drh4767d972006-06-14 15:03:49 +0000474#endif /* YYWILDCARD */
drha4414042015-11-09 15:06:26 +0000475 }
476 return yy_default[stateno];
477 }else{
478 return yy_action[i];
drh0bd1f4e2002-06-06 18:54:39 +0000479 }
drha4414042015-11-09 15:06:26 +0000480 }while(1);
drh8b582012003-10-21 13:16:03 +0000481}
482
483/*
484** Find the appropriate action for a parser given the non-terminal
485** look-ahead token iLookAhead.
drh8b582012003-10-21 13:16:03 +0000486*/
487static int yy_find_reduce_action(
drh161aba32005-02-01 04:09:36 +0000488 int stateno, /* Current state number */
drhd9f291e2006-06-13 11:15:47 +0000489 YYCODETYPE iLookAhead /* The look-ahead token */
drh8b582012003-10-21 13:16:03 +0000490){
491 int i;
drh7f7c2572008-04-27 18:45:10 +0000492#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000493 if( stateno>YY_REDUCE_COUNT ){
drh7f7c2572008-04-27 18:45:10 +0000494 return yy_default[stateno];
495 }
496#else
drhf16371d2009-11-03 19:18:31 +0000497 assert( stateno<=YY_REDUCE_COUNT );
drh7f7c2572008-04-27 18:45:10 +0000498#endif
drh01495b92008-01-23 12:52:40 +0000499 i = yy_reduce_ofst[stateno];
500 assert( i!=YY_REDUCE_USE_DFLT );
501 assert( iLookAhead!=YYNOCODE );
drh8b582012003-10-21 13:16:03 +0000502 i += iLookAhead;
drh7f7c2572008-04-27 18:45:10 +0000503#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000504 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
drh7f7c2572008-04-27 18:45:10 +0000505 return yy_default[stateno];
506 }
507#else
drhf16371d2009-11-03 19:18:31 +0000508 assert( i>=0 && i<YY_ACTTAB_COUNT );
drh01495b92008-01-23 12:52:40 +0000509 assert( yy_lookahead[i]==iLookAhead );
drh7f7c2572008-04-27 18:45:10 +0000510#endif
drh01495b92008-01-23 12:52:40 +0000511 return yy_action[i];
drh75897232000-05-29 14:26:00 +0000512}
513
514/*
drhb19fd012007-03-29 01:44:45 +0000515** The following routine is called if the stack overflows.
516*/
drh45f31be2016-02-16 21:19:49 +0000517static void yyStackOverflow(yyParser *yypParser){
drhb19fd012007-03-29 01:44:45 +0000518 ParseARG_FETCH;
519 yypParser->yyidx--;
520#ifndef NDEBUG
521 if( yyTraceFILE ){
522 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
523 }
524#endif
525 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
526 /* Here code is inserted which will execute if the parser
527 ** stack every overflows */
drh82415f22015-11-09 19:33:42 +0000528/******** Begin %stack_overflow code ******************************************/
drhb19fd012007-03-29 01:44:45 +0000529%%
drh82415f22015-11-09 19:33:42 +0000530/******** End %stack_overflow code ********************************************/
drhb19fd012007-03-29 01:44:45 +0000531 ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
532}
533
534/*
drha248a722015-09-07 19:52:55 +0000535** Print tracing information for a SHIFT action
536*/
537#ifndef NDEBUG
538static void yyTraceShift(yyParser *yypParser, int yyNewState){
539 if( yyTraceFILE ){
drha248a722015-09-07 19:52:55 +0000540 if( yyNewState<YYNSTATE ){
drh0c4105e2015-11-10 14:51:22 +0000541 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
542 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
543 yyNewState);
drha248a722015-09-07 19:52:55 +0000544 }else{
drh0c4105e2015-11-10 14:51:22 +0000545 fprintf(yyTraceFILE,"%sShift '%s'\n",
546 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
drha248a722015-09-07 19:52:55 +0000547 }
548 }
549}
550#else
551# define yyTraceShift(X,Y)
552#endif
553
554/*
drh82415f22015-11-09 19:33:42 +0000555** Perform a shift action.
drh75897232000-05-29 14:26:00 +0000556*/
drha248a722015-09-07 19:52:55 +0000557static void yy_shift(
drh75897232000-05-29 14:26:00 +0000558 yyParser *yypParser, /* The parser to be shifted */
559 int yyNewState, /* The new state to shift in */
560 int yyMajor, /* The major token to shift in */
drh45f31be2016-02-16 21:19:49 +0000561 ParseTOKENTYPE yyMinor /* The minor token to shift in */
drh75897232000-05-29 14:26:00 +0000562){
drh3ddfdf72003-12-22 14:53:19 +0000563 yyStackEntry *yytos;
drh1f245e42002-03-11 13:55:50 +0000564 yypParser->yyidx++;
drhec424a52008-07-25 15:39:03 +0000565#ifdef YYTRACKMAXSTACKDEPTH
566 if( yypParser->yyidx>yypParser->yyidxMax ){
567 yypParser->yyidxMax = yypParser->yyidx;
568 }
569#endif
drhb19fd012007-03-29 01:44:45 +0000570#if YYSTACKDEPTH>0
drh1f245e42002-03-11 13:55:50 +0000571 if( yypParser->yyidx>=YYSTACKDEPTH ){
drh45f31be2016-02-16 21:19:49 +0000572 yyStackOverflow(yypParser);
drha248a722015-09-07 19:52:55 +0000573 return;
drh75897232000-05-29 14:26:00 +0000574 }
drhb19fd012007-03-29 01:44:45 +0000575#else
576 if( yypParser->yyidx>=yypParser->yystksz ){
577 yyGrowStack(yypParser);
578 if( yypParser->yyidx>=yypParser->yystksz ){
drh45f31be2016-02-16 21:19:49 +0000579 yyStackOverflow(yypParser);
drha248a722015-09-07 19:52:55 +0000580 return;
drhb19fd012007-03-29 01:44:45 +0000581 }
582 }
583#endif
drh3ddfdf72003-12-22 14:53:19 +0000584 yytos = &yypParser->yystack[yypParser->yyidx];
drhb27b7f52008-12-10 18:03:45 +0000585 yytos->stateno = (YYACTIONTYPE)yyNewState;
586 yytos->major = (YYCODETYPE)yyMajor;
drh45f31be2016-02-16 21:19:49 +0000587 yytos->minor.yy0 = yyMinor;
drha248a722015-09-07 19:52:55 +0000588 yyTraceShift(yypParser, yyNewState);
drh75897232000-05-29 14:26:00 +0000589}
590
591/* The following table contains information about every rule that
592** is used during the reduce.
593*/
drh57196282004-10-06 15:41:16 +0000594static const struct {
drh75897232000-05-29 14:26:00 +0000595 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
596 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
597} yyRuleInfo[] = {
598%%
599};
600
drh1f245e42002-03-11 13:55:50 +0000601static void yy_accept(yyParser*); /* Forward Declaration */
drh75897232000-05-29 14:26:00 +0000602
603/*
604** Perform a reduce action and the shift that must immediately
605** follow the reduce.
606*/
607static void yy_reduce(
608 yyParser *yypParser, /* The parser */
drh4ef07702016-03-16 19:45:54 +0000609 unsigned int yyruleno /* Number of the rule by which to reduce */
drh75897232000-05-29 14:26:00 +0000610){
611 int yygoto; /* The next state */
612 int yyact; /* The next action */
drh1f245e42002-03-11 13:55:50 +0000613 yyStackEntry *yymsp; /* The top of the parser's stack */
drh75897232000-05-29 14:26:00 +0000614 int yysize; /* Amount to pop the stack */
drh1f245e42002-03-11 13:55:50 +0000615 ParseARG_FETCH;
drh3ddfdf72003-12-22 14:53:19 +0000616 yymsp = &yypParser->yystack[yypParser->yyidx];
drh0bd1f4e2002-06-06 18:54:39 +0000617#ifndef NDEBUG
drh4ef07702016-03-16 19:45:54 +0000618 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
drh3bd48ab2015-09-07 18:23:37 +0000619 yysize = yyRuleInfo[yyruleno].nrhs;
drh0c4105e2015-11-10 14:51:22 +0000620 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
drh3bd48ab2015-09-07 18:23:37 +0000621 yyRuleName[yyruleno], yymsp[-yysize].stateno);
drh0bd1f4e2002-06-06 18:54:39 +0000622 }
623#endif /* NDEBUG */
drh45f31be2016-02-16 21:19:49 +0000624
625 /* Check that the stack is large enough to grow by a single entry
626 ** if the RHS of the rule is empty. This ensures that there is room
627 ** enough on the stack to push the LHS value */
628 if( yyRuleInfo[yyruleno].nrhs==0 ){
629#ifdef YYTRACKMAXSTACKDEPTH
630 if( yypParser->yyidx>yypParser->yyidxMax ){
631 yypParser->yyidxMax = yypParser->yyidx;
632 }
633#endif
634#if YYSTACKDEPTH>0
drh43303de2016-02-17 12:34:03 +0000635 if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
drh45f31be2016-02-16 21:19:49 +0000636 yyStackOverflow(yypParser);
637 return;
638 }
639#else
drh43303de2016-02-17 12:34:03 +0000640 if( yypParser->yyidx>=yypParser->yystksz-1 ){
drh45f31be2016-02-16 21:19:49 +0000641 yyGrowStack(yypParser);
drh43303de2016-02-17 12:34:03 +0000642 if( yypParser->yyidx>=yypParser->yystksz-1 ){
drh45f31be2016-02-16 21:19:49 +0000643 yyStackOverflow(yypParser);
644 return;
645 }
646 }
647#endif
648 }
drhcb6c5652007-01-16 18:19:12 +0000649
drh75897232000-05-29 14:26:00 +0000650 switch( yyruleno ){
651 /* Beginning here are the reduction cases. A typical example
652 ** follows:
653 ** case 0:
drh75897232000-05-29 14:26:00 +0000654 ** #line <lineno> <grammarfile>
655 ** { ... } // User supplied code
656 ** #line <lineno> <thisfile>
657 ** break;
658 */
drh82415f22015-11-09 19:33:42 +0000659/********** Begin reduce actions **********************************************/
drh75897232000-05-29 14:26:00 +0000660%%
drh82415f22015-11-09 19:33:42 +0000661/********** End reduce actions ************************************************/
drh75897232000-05-29 14:26:00 +0000662 };
drh4ef07702016-03-16 19:45:54 +0000663 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
drh75897232000-05-29 14:26:00 +0000664 yygoto = yyRuleInfo[yyruleno].lhs;
665 yysize = yyRuleInfo[yyruleno].nrhs;
drh3abbd392008-12-10 23:04:13 +0000666 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
drha248a722015-09-07 19:52:55 +0000667 if( yyact <= YY_MAX_SHIFTREDUCE ){
668 if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
drh45f31be2016-02-16 21:19:49 +0000669 yypParser->yyidx -= yysize - 1;
670 yymsp -= yysize-1;
671 yymsp->stateno = (YYACTIONTYPE)yyact;
672 yymsp->major = (YYCODETYPE)yygoto;
drh45f31be2016-02-16 21:19:49 +0000673 yyTraceShift(yypParser, yyact);
drh4b2f9362008-01-22 23:37:09 +0000674 }else{
drh3bd48ab2015-09-07 18:23:37 +0000675 assert( yyact == YY_ACCEPT_ACTION );
drh45f31be2016-02-16 21:19:49 +0000676 yypParser->yyidx -= yysize;
drh1f245e42002-03-11 13:55:50 +0000677 yy_accept(yypParser);
drh75897232000-05-29 14:26:00 +0000678 }
679}
680
681/*
682** The following code executes when the parse fails
683*/
drhd3ec02d2009-06-12 02:27:14 +0000684#ifndef YYNOERRORRECOVERY
drh75897232000-05-29 14:26:00 +0000685static void yy_parse_failed(
686 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000687){
drh1f245e42002-03-11 13:55:50 +0000688 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000689#ifndef NDEBUG
690 if( yyTraceFILE ){
691 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
692 }
693#endif
drh1f245e42002-03-11 13:55:50 +0000694 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000695 /* Here code is inserted which will be executed whenever the
696 ** parser fails */
drh82415f22015-11-09 19:33:42 +0000697/************ Begin %parse_failure code ***************************************/
drh75897232000-05-29 14:26:00 +0000698%%
drh82415f22015-11-09 19:33:42 +0000699/************ End %parse_failure code *****************************************/
drh1f245e42002-03-11 13:55:50 +0000700 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000701}
drhd3ec02d2009-06-12 02:27:14 +0000702#endif /* YYNOERRORRECOVERY */
drh75897232000-05-29 14:26:00 +0000703
704/*
705** The following code executes when a syntax error first occurs.
706*/
707static void yy_syntax_error(
708 yyParser *yypParser, /* The parser */
709 int yymajor, /* The major type of the error token */
drh45f31be2016-02-16 21:19:49 +0000710 ParseTOKENTYPE yyminor /* The minor type of the error token */
drh75897232000-05-29 14:26:00 +0000711){
drh1f245e42002-03-11 13:55:50 +0000712 ParseARG_FETCH;
drh45f31be2016-02-16 21:19:49 +0000713#define TOKEN yyminor
drh82415f22015-11-09 19:33:42 +0000714/************ Begin %syntax_error code ****************************************/
drh75897232000-05-29 14:26:00 +0000715%%
drh82415f22015-11-09 19:33:42 +0000716/************ End %syntax_error code ******************************************/
drh1f245e42002-03-11 13:55:50 +0000717 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000718}
719
720/*
721** The following is executed when the parser accepts
722*/
723static void yy_accept(
724 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000725){
drh1f245e42002-03-11 13:55:50 +0000726 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000727#ifndef NDEBUG
728 if( yyTraceFILE ){
729 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
730 }
731#endif
drh1f245e42002-03-11 13:55:50 +0000732 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000733 /* Here code is inserted which will be executed whenever the
734 ** parser accepts */
drh82415f22015-11-09 19:33:42 +0000735/*********** Begin %parse_accept code *****************************************/
drh75897232000-05-29 14:26:00 +0000736%%
drh82415f22015-11-09 19:33:42 +0000737/*********** End %parse_accept code *******************************************/
drh1f245e42002-03-11 13:55:50 +0000738 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000739}
740
741/* The main parser program.
742** The first argument is a pointer to a structure obtained from
743** "ParseAlloc" which describes the current state of the parser.
744** The second argument is the major token number. The third is
745** the minor token. The fourth optional argument is whatever the
746** user wants (and specified in the grammar) and is available for
747** use by the action routines.
748**
749** Inputs:
750** <ul>
751** <li> A pointer to the parser (an opaque structure.)
752** <li> The major token number.
753** <li> The minor token number.
754** <li> An option argument of a grammar-specified type.
755** </ul>
756**
757** Outputs:
758** None.
759*/
drh75897232000-05-29 14:26:00 +0000760void Parse(
761 void *yyp, /* The parser */
762 int yymajor, /* The major token code number */
763 ParseTOKENTYPE yyminor /* The value for the token */
drh1f245e42002-03-11 13:55:50 +0000764 ParseARG_PDECL /* Optional %extra_argument parameter */
drh75897232000-05-29 14:26:00 +0000765){
766 YYMINORTYPE yyminorunion;
drh4ef07702016-03-16 19:45:54 +0000767 unsigned int yyact; /* The parser action. */
drha4414042015-11-09 15:06:26 +0000768#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000769 int yyendofinput; /* True if we are at the end of input */
drha4414042015-11-09 15:06:26 +0000770#endif
drhc4dd3fd2008-01-22 01:48:05 +0000771#ifdef YYERRORSYMBOL
drh75897232000-05-29 14:26:00 +0000772 int yyerrorhit = 0; /* True if yymajor has invoked an error */
drhc4dd3fd2008-01-22 01:48:05 +0000773#endif
drh75897232000-05-29 14:26:00 +0000774 yyParser *yypParser; /* The parser */
775
776 /* (re)initialize the parser, if necessary */
777 yypParser = (yyParser*)yyp;
drh1f245e42002-03-11 13:55:50 +0000778 if( yypParser->yyidx<0 ){
drhb7bac722007-03-29 02:26:45 +0000779#if YYSTACKDEPTH<=0
drhb19fd012007-03-29 01:44:45 +0000780 if( yypParser->yystksz <=0 ){
drh45f31be2016-02-16 21:19:49 +0000781 yyStackOverflow(yypParser);
drhb19fd012007-03-29 01:44:45 +0000782 return;
783 }
drhb7bac722007-03-29 02:26:45 +0000784#endif
drh1f245e42002-03-11 13:55:50 +0000785 yypParser->yyidx = 0;
drhdab943c2016-02-16 01:01:43 +0000786#ifndef YYNOERRORRECOVERY
drh1f245e42002-03-11 13:55:50 +0000787 yypParser->yyerrcnt = -1;
drhdab943c2016-02-16 01:01:43 +0000788#endif
drh3ddfdf72003-12-22 14:53:19 +0000789 yypParser->yystack[0].stateno = 0;
790 yypParser->yystack[0].major = 0;
drh0c4105e2015-11-10 14:51:22 +0000791#ifndef NDEBUG
792 if( yyTraceFILE ){
793 fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
794 yyTracePrompt);
795 }
796#endif
drh75897232000-05-29 14:26:00 +0000797 }
drha4414042015-11-09 15:06:26 +0000798#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000799 yyendofinput = (yymajor==0);
drha4414042015-11-09 15:06:26 +0000800#endif
drh1f245e42002-03-11 13:55:50 +0000801 ParseARG_STORE;
drh75897232000-05-29 14:26:00 +0000802
803#ifndef NDEBUG
804 if( yyTraceFILE ){
drh0c4105e2015-11-10 14:51:22 +0000805 fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
drh75897232000-05-29 14:26:00 +0000806 }
807#endif
808
809 do{
drh3abbd392008-12-10 23:04:13 +0000810 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
drh3bd48ab2015-09-07 18:23:37 +0000811 if( yyact <= YY_MAX_SHIFTREDUCE ){
drha248a722015-09-07 19:52:55 +0000812 if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
drh45f31be2016-02-16 21:19:49 +0000813 yy_shift(yypParser,yyact,yymajor,yyminor);
drhdab943c2016-02-16 01:01:43 +0000814#ifndef YYNOERRORRECOVERY
drha248a722015-09-07 19:52:55 +0000815 yypParser->yyerrcnt--;
drhdab943c2016-02-16 01:01:43 +0000816#endif
drha248a722015-09-07 19:52:55 +0000817 yymajor = YYNOCODE;
drh3bd48ab2015-09-07 18:23:37 +0000818 }else if( yyact <= YY_MAX_REDUCE ){
819 yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
drhc4dd3fd2008-01-22 01:48:05 +0000820 }else{
821 assert( yyact == YY_ERROR_ACTION );
drh45f31be2016-02-16 21:19:49 +0000822 yyminorunion.yy0 = yyminor;
drhc4dd3fd2008-01-22 01:48:05 +0000823#ifdef YYERRORSYMBOL
drh3ddfdf72003-12-22 14:53:19 +0000824 int yymx;
drhc4dd3fd2008-01-22 01:48:05 +0000825#endif
drh75897232000-05-29 14:26:00 +0000826#ifndef NDEBUG
827 if( yyTraceFILE ){
828 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
829 }
830#endif
831#ifdef YYERRORSYMBOL
832 /* A syntax error has occurred.
833 ** The response to an error depends upon whether or not the
834 ** grammar defines an error token "ERROR".
835 **
836 ** This is what we do if the grammar does define ERROR:
837 **
838 ** * Call the %syntax_error function.
839 **
840 ** * Begin popping the stack until we enter a state where
841 ** it is legal to shift the error symbol, then shift
842 ** the error symbol.
843 **
844 ** * Set the error count to three.
845 **
846 ** * Begin accepting and shifting new tokens. No new error
847 ** processing will occur until three tokens have been
848 ** shifted successfully.
849 **
850 */
drh1f245e42002-03-11 13:55:50 +0000851 if( yypParser->yyerrcnt<0 ){
drh45f31be2016-02-16 21:19:49 +0000852 yy_syntax_error(yypParser,yymajor,yyminor);
drh75897232000-05-29 14:26:00 +0000853 }
drh3ddfdf72003-12-22 14:53:19 +0000854 yymx = yypParser->yystack[yypParser->yyidx].major;
855 if( yymx==YYERRORSYMBOL || yyerrorhit ){
drh75897232000-05-29 14:26:00 +0000856#ifndef NDEBUG
857 if( yyTraceFILE ){
858 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
859 yyTracePrompt,yyTokenName[yymajor]);
860 }
861#endif
drh45f31be2016-02-16 21:19:49 +0000862 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
drh75897232000-05-29 14:26:00 +0000863 yymajor = YYNOCODE;
864 }else{
drh45f31be2016-02-16 21:19:49 +0000865 while(
drh1f245e42002-03-11 13:55:50 +0000866 yypParser->yyidx >= 0 &&
drh3ddfdf72003-12-22 14:53:19 +0000867 yymx != YYERRORSYMBOL &&
drhf3a58882006-05-08 15:14:19 +0000868 (yyact = yy_find_reduce_action(
869 yypParser->yystack[yypParser->yyidx].stateno,
drh3bd48ab2015-09-07 18:23:37 +0000870 YYERRORSYMBOL)) >= YY_MIN_REDUCE
drh75897232000-05-29 14:26:00 +0000871 ){
872 yy_pop_parser_stack(yypParser);
873 }
drh1f245e42002-03-11 13:55:50 +0000874 if( yypParser->yyidx < 0 || yymajor==0 ){
drhb27b7f52008-12-10 18:03:45 +0000875 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh1f245e42002-03-11 13:55:50 +0000876 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000877 yymajor = YYNOCODE;
drh3ddfdf72003-12-22 14:53:19 +0000878 }else if( yymx!=YYERRORSYMBOL ){
drh45f31be2016-02-16 21:19:49 +0000879 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
drh75897232000-05-29 14:26:00 +0000880 }
881 }
drh1f245e42002-03-11 13:55:50 +0000882 yypParser->yyerrcnt = 3;
drh75897232000-05-29 14:26:00 +0000883 yyerrorhit = 1;
drhd3ec02d2009-06-12 02:27:14 +0000884#elif defined(YYNOERRORRECOVERY)
885 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
886 ** do any kind of error recovery. Instead, simply invoke the syntax
887 ** error routine and continue going as if nothing had happened.
888 **
889 ** Applications can set this macro (for example inside %include) if
890 ** they intend to abandon the parse upon the first syntax error seen.
891 */
drh45f31be2016-02-16 21:19:49 +0000892 yy_syntax_error(yypParser,yymajor, yyminor);
drhd3ec02d2009-06-12 02:27:14 +0000893 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
894 yymajor = YYNOCODE;
895
drh75897232000-05-29 14:26:00 +0000896#else /* YYERRORSYMBOL is not defined */
897 /* This is what we do if the grammar does not define ERROR:
898 **
899 ** * Report an error message, and throw away the input token.
900 **
901 ** * If the input token is $, then fail the parse.
902 **
903 ** As before, subsequent error messages are suppressed until
904 ** three input tokens have been successfully shifted.
905 */
drh1f245e42002-03-11 13:55:50 +0000906 if( yypParser->yyerrcnt<=0 ){
drh45f31be2016-02-16 21:19:49 +0000907 yy_syntax_error(yypParser,yymajor, yyminor);
drh75897232000-05-29 14:26:00 +0000908 }
drh1f245e42002-03-11 13:55:50 +0000909 yypParser->yyerrcnt = 3;
drhb27b7f52008-12-10 18:03:45 +0000910 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh75897232000-05-29 14:26:00 +0000911 if( yyendofinput ){
drh1f245e42002-03-11 13:55:50 +0000912 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000913 }
914 yymajor = YYNOCODE;
915#endif
drh75897232000-05-29 14:26:00 +0000916 }
drh1f245e42002-03-11 13:55:50 +0000917 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
drh3bd48ab2015-09-07 18:23:37 +0000918#ifndef NDEBUG
919 if( yyTraceFILE ){
drh0c4105e2015-11-10 14:51:22 +0000920 int i;
921 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
922 for(i=1; i<=yypParser->yyidx; i++)
923 fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
924 yyTokenName[yypParser->yystack[i].major]);
925 fprintf(yyTraceFILE,"]\n");
drh3bd48ab2015-09-07 18:23:37 +0000926 }
927#endif
drh75897232000-05-29 14:26:00 +0000928 return;
929}