blob: 7fb5fe2d0c3c2809d1144e9948c705dbc7e4990d [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 {
drh118ab652016-05-23 21:56:24 +0000206 yyStackEntry *yytos; /* Pointer to top element of the stack */
drhec424a52008-07-25 15:39:03 +0000207#ifdef YYTRACKMAXSTACKDEPTH
drh118ab652016-05-23 21:56:24 +0000208 int yyhwm; /* High-water mark of the stack */
drhec424a52008-07-25 15:39:03 +0000209#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;
drhabecc0b2016-05-24 00:40:54 +0000278 int idx;
drhb19fd012007-03-29 01:44:45 +0000279 yyStackEntry *pNew;
280
281 newSize = p->yystksz*2 + 100;
drhabecc0b2016-05-24 00:40:54 +0000282 idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
drhb19fd012007-03-29 01:44:45 +0000283 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
284 if( pNew ){
285 p->yystack = pNew;
drhabecc0b2016-05-24 00:40:54 +0000286 p->yytos = &p->yystack[idx];
drhb19fd012007-03-29 01:44:45 +0000287 p->yystksz = newSize;
288#ifndef NDEBUG
289 if( yyTraceFILE ){
290 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
291 yyTracePrompt, p->yystksz);
292 }
293#endif
294 }
295}
296#endif
297
drh82415f22015-11-09 19:33:42 +0000298/* Datatype of the argument to the memory allocated passed as the
299** second argument to ParseAlloc() below. This can be changed by
300** putting an appropriate #define in the %include section of the input
301** grammar.
302*/
303#ifndef YYMALLOCARGTYPE
304# define YYMALLOCARGTYPE size_t
305#endif
306
drh75897232000-05-29 14:26:00 +0000307/*
308** This function allocates a new parser.
309** The only argument is a pointer to a function which works like
310** malloc.
311**
312** Inputs:
313** A pointer to the function used to allocate memory.
314**
315** Outputs:
316** A pointer to a parser. This pointer is used in subsequent calls
317** to Parse and ParseFree.
318*/
drh82415f22015-11-09 19:33:42 +0000319void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
drh75897232000-05-29 14:26:00 +0000320 yyParser *pParser;
drh82415f22015-11-09 19:33:42 +0000321 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
drh75897232000-05-29 14:26:00 +0000322 if( pParser ){
drhec424a52008-07-25 15:39:03 +0000323#ifdef YYTRACKMAXSTACKDEPTH
drh118ab652016-05-23 21:56:24 +0000324 pParser->yyhwm = 0;
drhec424a52008-07-25 15:39:03 +0000325#endif
drhb19fd012007-03-29 01:44:45 +0000326#if YYSTACKDEPTH<=0
drhabecc0b2016-05-24 00:40:54 +0000327 pParser->yytos = NULL;
drh4c651782008-11-18 23:25:54 +0000328 pParser->yystack = NULL;
329 pParser->yystksz = 0;
drhb19fd012007-03-29 01:44:45 +0000330 yyGrowStack(pParser);
331#endif
drhabecc0b2016-05-24 00:40:54 +0000332 pParser->yytos = pParser->yystack;
333 pParser->yystack[0].stateno = 0;
334 pParser->yystack[0].major = 0;
drh75897232000-05-29 14:26:00 +0000335 }
336 return pParser;
337}
338
drh82415f22015-11-09 19:33:42 +0000339/* The following function deletes the "minor type" or semantic value
340** associated with a symbol. The symbol can be either a terminal
341** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
342** a pointer to the value to be deleted. The code used to do the
343** deletions is derived from the %destructor and/or %token_destructor
344** directives of the input grammar.
drh75897232000-05-29 14:26:00 +0000345*/
drh633e6d52008-07-28 19:34:53 +0000346static void yy_destructor(
347 yyParser *yypParser, /* The parser */
348 YYCODETYPE yymajor, /* Type code for object to destroy */
349 YYMINORTYPE *yypminor /* The object to be destroyed */
350){
351 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000352 switch( yymajor ){
353 /* Here is inserted the actions which take place when a
354 ** terminal or non-terminal is destroyed. This can happen
355 ** when the symbol is popped from the stack during a
356 ** reduce or during error processing or when a parser is
357 ** being destroyed before it is finished parsing.
358 **
359 ** Note: during a reduce, the only symbols destroyed are those
drh82415f22015-11-09 19:33:42 +0000360 ** which appear on the RHS of the rule, but which are *not* used
drh75897232000-05-29 14:26:00 +0000361 ** inside the C code.
362 */
drh82415f22015-11-09 19:33:42 +0000363/********* Begin destructor definitions ***************************************/
drh75897232000-05-29 14:26:00 +0000364%%
drh82415f22015-11-09 19:33:42 +0000365/********* End destructor definitions *****************************************/
drh75897232000-05-29 14:26:00 +0000366 default: break; /* If no destructor action specified: do nothing */
367 }
368}
369
370/*
371** Pop the parser's stack once.
372**
373** If there is a destructor routine associated with the token which
374** is popped from the stack, then call it.
drh75897232000-05-29 14:26:00 +0000375*/
drh3781f012015-11-09 14:11:37 +0000376static void yy_pop_parser_stack(yyParser *pParser){
377 yyStackEntry *yytos;
drh118ab652016-05-23 21:56:24 +0000378 assert( pParser->yytos!=0 );
379 yytos = pParser->yytos--;
drh75897232000-05-29 14:26:00 +0000380#ifndef NDEBUG
drh3781f012015-11-09 14:11:37 +0000381 if( yyTraceFILE ){
drh75897232000-05-29 14:26:00 +0000382 fprintf(yyTraceFILE,"%sPopping %s\n",
383 yyTracePrompt,
drh3ddfdf72003-12-22 14:53:19 +0000384 yyTokenName[yytos->major]);
drh75897232000-05-29 14:26:00 +0000385 }
386#endif
drh3781f012015-11-09 14:11:37 +0000387 yy_destructor(pParser, yytos->major, &yytos->minor);
drh75897232000-05-29 14:26:00 +0000388}
389
390/*
drh82415f22015-11-09 19:33:42 +0000391** Deallocate and destroy a parser. Destructors are called for
drh75897232000-05-29 14:26:00 +0000392** all stack elements before shutting the parser down.
393**
drh82415f22015-11-09 19:33:42 +0000394** If the YYPARSEFREENEVERNULL macro exists (for example because it
395** is defined in a %include section of the input grammar) then it is
396** assumed that the input pointer is never NULL.
drh75897232000-05-29 14:26:00 +0000397*/
drh75897232000-05-29 14:26:00 +0000398void ParseFree(
drh960e8c62001-04-03 16:53:21 +0000399 void *p, /* The parser to be deleted */
400 void (*freeProc)(void*) /* Function used to reclaim memory */
drh75897232000-05-29 14:26:00 +0000401){
402 yyParser *pParser = (yyParser*)p;
drh82415f22015-11-09 19:33:42 +0000403#ifndef YYPARSEFREENEVERNULL
drh75897232000-05-29 14:26:00 +0000404 if( pParser==0 ) return;
drh82415f22015-11-09 19:33:42 +0000405#endif
drhabecc0b2016-05-24 00:40:54 +0000406 while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
drhb19fd012007-03-29 01:44:45 +0000407#if YYSTACKDEPTH<=0
408 free(pParser->yystack);
409#endif
drh960e8c62001-04-03 16:53:21 +0000410 (*freeProc)((void*)pParser);
drh75897232000-05-29 14:26:00 +0000411}
412
413/*
drhec424a52008-07-25 15:39:03 +0000414** Return the peak depth of the stack for a parser.
415*/
416#ifdef YYTRACKMAXSTACKDEPTH
417int ParseStackPeak(void *p){
418 yyParser *pParser = (yyParser*)p;
drh118ab652016-05-23 21:56:24 +0000419 return pParser->yyhwm;
drhec424a52008-07-25 15:39:03 +0000420}
421#endif
422
423/*
drh8b582012003-10-21 13:16:03 +0000424** Find the appropriate action for a parser given the terminal
425** look-ahead token iLookAhead.
drh75897232000-05-29 14:26:00 +0000426*/
drh4ef07702016-03-16 19:45:54 +0000427static unsigned int yy_find_shift_action(
drh75897232000-05-29 14:26:00 +0000428 yyParser *pParser, /* The parser */
drhd9f291e2006-06-13 11:15:47 +0000429 YYCODETYPE iLookAhead /* The look-ahead token */
drh75897232000-05-29 14:26:00 +0000430){
drh8b582012003-10-21 13:16:03 +0000431 int i;
drh118ab652016-05-23 21:56:24 +0000432 int stateno = pParser->yytos->stateno;
drha4414042015-11-09 15:06:26 +0000433
434 if( stateno>=YY_MIN_REDUCE ) return stateno;
drhae2a4082015-09-07 20:02:39 +0000435 assert( stateno <= YY_SHIFT_COUNT );
drha4414042015-11-09 15:06:26 +0000436 do{
437 i = yy_shift_ofst[stateno];
438 if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
439 assert( iLookAhead!=YYNOCODE );
440 i += iLookAhead;
441 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
442 if( iLookAhead>0 ){
drh4767d972006-06-14 15:03:49 +0000443#ifdef YYFALLBACK
drha4414042015-11-09 15:06:26 +0000444 YYCODETYPE iFallback; /* Fallback token */
445 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
446 && (iFallback = yyFallback[iLookAhead])!=0 ){
drh4767d972006-06-14 15:03:49 +0000447#ifndef NDEBUG
448 if( yyTraceFILE ){
drha4414042015-11-09 15:06:26 +0000449 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
450 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
drh4767d972006-06-14 15:03:49 +0000451 }
drha4414042015-11-09 15:06:26 +0000452#endif
453 assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
454 iLookAhead = iFallback;
455 continue;
drhe09daa92006-06-10 13:29:31 +0000456 }
drha4414042015-11-09 15:06:26 +0000457#endif
458#ifdef YYWILDCARD
459 {
460 int j = i - iLookAhead + YYWILDCARD;
461 if(
462#if YY_SHIFT_MIN+YYWILDCARD<0
463 j>=0 &&
464#endif
465#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
466 j<YY_ACTTAB_COUNT &&
467#endif
468 yy_lookahead[j]==YYWILDCARD
469 ){
470#ifndef NDEBUG
471 if( yyTraceFILE ){
472 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
473 yyTracePrompt, yyTokenName[iLookAhead],
474 yyTokenName[YYWILDCARD]);
475 }
476#endif /* NDEBUG */
477 return yy_action[j];
478 }
479 }
drh4767d972006-06-14 15:03:49 +0000480#endif /* YYWILDCARD */
drha4414042015-11-09 15:06:26 +0000481 }
482 return yy_default[stateno];
483 }else{
484 return yy_action[i];
drh0bd1f4e2002-06-06 18:54:39 +0000485 }
drha4414042015-11-09 15:06:26 +0000486 }while(1);
drh8b582012003-10-21 13:16:03 +0000487}
488
489/*
490** Find the appropriate action for a parser given the non-terminal
491** look-ahead token iLookAhead.
drh8b582012003-10-21 13:16:03 +0000492*/
493static int yy_find_reduce_action(
drh161aba32005-02-01 04:09:36 +0000494 int stateno, /* Current state number */
drhd9f291e2006-06-13 11:15:47 +0000495 YYCODETYPE iLookAhead /* The look-ahead token */
drh8b582012003-10-21 13:16:03 +0000496){
497 int i;
drh7f7c2572008-04-27 18:45:10 +0000498#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000499 if( stateno>YY_REDUCE_COUNT ){
drh7f7c2572008-04-27 18:45:10 +0000500 return yy_default[stateno];
501 }
502#else
drhf16371d2009-11-03 19:18:31 +0000503 assert( stateno<=YY_REDUCE_COUNT );
drh7f7c2572008-04-27 18:45:10 +0000504#endif
drh01495b92008-01-23 12:52:40 +0000505 i = yy_reduce_ofst[stateno];
506 assert( i!=YY_REDUCE_USE_DFLT );
507 assert( iLookAhead!=YYNOCODE );
drh8b582012003-10-21 13:16:03 +0000508 i += iLookAhead;
drh7f7c2572008-04-27 18:45:10 +0000509#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000510 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
drh7f7c2572008-04-27 18:45:10 +0000511 return yy_default[stateno];
512 }
513#else
drhf16371d2009-11-03 19:18:31 +0000514 assert( i>=0 && i<YY_ACTTAB_COUNT );
drh01495b92008-01-23 12:52:40 +0000515 assert( yy_lookahead[i]==iLookAhead );
drh7f7c2572008-04-27 18:45:10 +0000516#endif
drh01495b92008-01-23 12:52:40 +0000517 return yy_action[i];
drh75897232000-05-29 14:26:00 +0000518}
519
520/*
drhb19fd012007-03-29 01:44:45 +0000521** The following routine is called if the stack overflows.
522*/
drh45f31be2016-02-16 21:19:49 +0000523static void yyStackOverflow(yyParser *yypParser){
drhb19fd012007-03-29 01:44:45 +0000524 ParseARG_FETCH;
drh118ab652016-05-23 21:56:24 +0000525 yypParser->yytos--;
drhb19fd012007-03-29 01:44:45 +0000526#ifndef NDEBUG
527 if( yyTraceFILE ){
528 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
529 }
530#endif
drhabecc0b2016-05-24 00:40:54 +0000531 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
drhb19fd012007-03-29 01:44:45 +0000532 /* Here code is inserted which will execute if the parser
533 ** stack every overflows */
drh82415f22015-11-09 19:33:42 +0000534/******** Begin %stack_overflow code ******************************************/
drhb19fd012007-03-29 01:44:45 +0000535%%
drh82415f22015-11-09 19:33:42 +0000536/******** End %stack_overflow code ********************************************/
drhb19fd012007-03-29 01:44:45 +0000537 ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
538}
539
540/*
drha248a722015-09-07 19:52:55 +0000541** Print tracing information for a SHIFT action
542*/
543#ifndef NDEBUG
544static void yyTraceShift(yyParser *yypParser, int yyNewState){
545 if( yyTraceFILE ){
drha248a722015-09-07 19:52:55 +0000546 if( yyNewState<YYNSTATE ){
drh0c4105e2015-11-10 14:51:22 +0000547 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
drh118ab652016-05-23 21:56:24 +0000548 yyTracePrompt,yyTokenName[yypParser->yytos->major],
drh0c4105e2015-11-10 14:51:22 +0000549 yyNewState);
drha248a722015-09-07 19:52:55 +0000550 }else{
drh0c4105e2015-11-10 14:51:22 +0000551 fprintf(yyTraceFILE,"%sShift '%s'\n",
drh118ab652016-05-23 21:56:24 +0000552 yyTracePrompt,yyTokenName[yypParser->yytos->major]);
drha248a722015-09-07 19:52:55 +0000553 }
554 }
555}
556#else
557# define yyTraceShift(X,Y)
558#endif
559
560/*
drh82415f22015-11-09 19:33:42 +0000561** Perform a shift action.
drh75897232000-05-29 14:26:00 +0000562*/
drha248a722015-09-07 19:52:55 +0000563static void yy_shift(
drh75897232000-05-29 14:26:00 +0000564 yyParser *yypParser, /* The parser to be shifted */
565 int yyNewState, /* The new state to shift in */
566 int yyMajor, /* The major token to shift in */
drh45f31be2016-02-16 21:19:49 +0000567 ParseTOKENTYPE yyMinor /* The minor token to shift in */
drh75897232000-05-29 14:26:00 +0000568){
drh3ddfdf72003-12-22 14:53:19 +0000569 yyStackEntry *yytos;
drh118ab652016-05-23 21:56:24 +0000570 yypParser->yytos++;
drhec424a52008-07-25 15:39:03 +0000571#ifdef YYTRACKMAXSTACKDEPTH
drh118ab652016-05-23 21:56:24 +0000572 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
573 yypParser->yyhwm++;
574 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
drhec424a52008-07-25 15:39:03 +0000575 }
576#endif
drhb19fd012007-03-29 01:44:45 +0000577#if YYSTACKDEPTH>0
drh118ab652016-05-23 21:56:24 +0000578 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
drh45f31be2016-02-16 21:19:49 +0000579 yyStackOverflow(yypParser);
drha248a722015-09-07 19:52:55 +0000580 return;
drh75897232000-05-29 14:26:00 +0000581 }
drhb19fd012007-03-29 01:44:45 +0000582#else
drh118ab652016-05-23 21:56:24 +0000583 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
drhb19fd012007-03-29 01:44:45 +0000584 yyGrowStack(yypParser);
drh118ab652016-05-23 21:56:24 +0000585 if( yypParser->yytos>=&yypParser->yystach[yypParser->yystksz] ){
drh45f31be2016-02-16 21:19:49 +0000586 yyStackOverflow(yypParser);
drha248a722015-09-07 19:52:55 +0000587 return;
drhb19fd012007-03-29 01:44:45 +0000588 }
589 }
590#endif
drh118ab652016-05-23 21:56:24 +0000591 yytos = yypParser->yytos;
drhb27b7f52008-12-10 18:03:45 +0000592 yytos->stateno = (YYACTIONTYPE)yyNewState;
593 yytos->major = (YYCODETYPE)yyMajor;
drh45f31be2016-02-16 21:19:49 +0000594 yytos->minor.yy0 = yyMinor;
drha248a722015-09-07 19:52:55 +0000595 yyTraceShift(yypParser, yyNewState);
drh75897232000-05-29 14:26:00 +0000596}
597
598/* The following table contains information about every rule that
599** is used during the reduce.
600*/
drh57196282004-10-06 15:41:16 +0000601static const struct {
drh75897232000-05-29 14:26:00 +0000602 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
603 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
604} yyRuleInfo[] = {
605%%
606};
607
drh1f245e42002-03-11 13:55:50 +0000608static void yy_accept(yyParser*); /* Forward Declaration */
drh75897232000-05-29 14:26:00 +0000609
610/*
611** Perform a reduce action and the shift that must immediately
612** follow the reduce.
613*/
614static void yy_reduce(
615 yyParser *yypParser, /* The parser */
drh4ef07702016-03-16 19:45:54 +0000616 unsigned int yyruleno /* Number of the rule by which to reduce */
drh75897232000-05-29 14:26:00 +0000617){
618 int yygoto; /* The next state */
619 int yyact; /* The next action */
drh1f245e42002-03-11 13:55:50 +0000620 yyStackEntry *yymsp; /* The top of the parser's stack */
drh75897232000-05-29 14:26:00 +0000621 int yysize; /* Amount to pop the stack */
drh1f245e42002-03-11 13:55:50 +0000622 ParseARG_FETCH;
drh118ab652016-05-23 21:56:24 +0000623 yymsp = yypParser->yytos;
drh0bd1f4e2002-06-06 18:54:39 +0000624#ifndef NDEBUG
drh4ef07702016-03-16 19:45:54 +0000625 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
drh3bd48ab2015-09-07 18:23:37 +0000626 yysize = yyRuleInfo[yyruleno].nrhs;
drh0c4105e2015-11-10 14:51:22 +0000627 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
drh3bd48ab2015-09-07 18:23:37 +0000628 yyRuleName[yyruleno], yymsp[-yysize].stateno);
drh0bd1f4e2002-06-06 18:54:39 +0000629 }
630#endif /* NDEBUG */
drh45f31be2016-02-16 21:19:49 +0000631
632 /* Check that the stack is large enough to grow by a single entry
633 ** if the RHS of the rule is empty. This ensures that there is room
634 ** enough on the stack to push the LHS value */
635 if( yyRuleInfo[yyruleno].nrhs==0 ){
636#ifdef YYTRACKMAXSTACKDEPTH
drh118ab652016-05-23 21:56:24 +0000637 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
638 yypParser->yyhwm++;
639 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
drh45f31be2016-02-16 21:19:49 +0000640 }
641#endif
642#if YYSTACKDEPTH>0
drh118ab652016-05-23 21:56:24 +0000643 if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
drh45f31be2016-02-16 21:19:49 +0000644 yyStackOverflow(yypParser);
645 return;
646 }
647#else
drh118ab652016-05-23 21:56:24 +0000648 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
drh45f31be2016-02-16 21:19:49 +0000649 yyGrowStack(yypParser);
drh118ab652016-05-23 21:56:24 +0000650 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
drh45f31be2016-02-16 21:19:49 +0000651 yyStackOverflow(yypParser);
652 return;
653 }
654 }
655#endif
656 }
drhcb6c5652007-01-16 18:19:12 +0000657
drh75897232000-05-29 14:26:00 +0000658 switch( yyruleno ){
659 /* Beginning here are the reduction cases. A typical example
660 ** follows:
661 ** case 0:
drh75897232000-05-29 14:26:00 +0000662 ** #line <lineno> <grammarfile>
663 ** { ... } // User supplied code
664 ** #line <lineno> <thisfile>
665 ** break;
666 */
drh82415f22015-11-09 19:33:42 +0000667/********** Begin reduce actions **********************************************/
drh75897232000-05-29 14:26:00 +0000668%%
drh82415f22015-11-09 19:33:42 +0000669/********** End reduce actions ************************************************/
drh75897232000-05-29 14:26:00 +0000670 };
drh4ef07702016-03-16 19:45:54 +0000671 assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
drh75897232000-05-29 14:26:00 +0000672 yygoto = yyRuleInfo[yyruleno].lhs;
673 yysize = yyRuleInfo[yyruleno].nrhs;
drh3abbd392008-12-10 23:04:13 +0000674 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
drha248a722015-09-07 19:52:55 +0000675 if( yyact <= YY_MAX_SHIFTREDUCE ){
drh118ab652016-05-23 21:56:24 +0000676 if( yyact>YY_MAX_SHIFT ){
677 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
678 }
drh45f31be2016-02-16 21:19:49 +0000679 yymsp -= yysize-1;
drh118ab652016-05-23 21:56:24 +0000680 yypParser->yytos = yymsp;
drh45f31be2016-02-16 21:19:49 +0000681 yymsp->stateno = (YYACTIONTYPE)yyact;
682 yymsp->major = (YYCODETYPE)yygoto;
drh45f31be2016-02-16 21:19:49 +0000683 yyTraceShift(yypParser, yyact);
drh4b2f9362008-01-22 23:37:09 +0000684 }else{
drh3bd48ab2015-09-07 18:23:37 +0000685 assert( yyact == YY_ACCEPT_ACTION );
drh118ab652016-05-23 21:56:24 +0000686 yypParser->yytos -= yysize;
drh1f245e42002-03-11 13:55:50 +0000687 yy_accept(yypParser);
drh75897232000-05-29 14:26:00 +0000688 }
689}
690
691/*
692** The following code executes when the parse fails
693*/
drhd3ec02d2009-06-12 02:27:14 +0000694#ifndef YYNOERRORRECOVERY
drh75897232000-05-29 14:26:00 +0000695static void yy_parse_failed(
696 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000697){
drh1f245e42002-03-11 13:55:50 +0000698 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000699#ifndef NDEBUG
700 if( yyTraceFILE ){
701 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
702 }
703#endif
drhabecc0b2016-05-24 00:40:54 +0000704 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000705 /* Here code is inserted which will be executed whenever the
706 ** parser fails */
drh82415f22015-11-09 19:33:42 +0000707/************ Begin %parse_failure code ***************************************/
drh75897232000-05-29 14:26:00 +0000708%%
drh82415f22015-11-09 19:33:42 +0000709/************ End %parse_failure code *****************************************/
drh1f245e42002-03-11 13:55:50 +0000710 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000711}
drhd3ec02d2009-06-12 02:27:14 +0000712#endif /* YYNOERRORRECOVERY */
drh75897232000-05-29 14:26:00 +0000713
714/*
715** The following code executes when a syntax error first occurs.
716*/
717static void yy_syntax_error(
718 yyParser *yypParser, /* The parser */
719 int yymajor, /* The major type of the error token */
drh45f31be2016-02-16 21:19:49 +0000720 ParseTOKENTYPE yyminor /* The minor type of the error token */
drh75897232000-05-29 14:26:00 +0000721){
drh1f245e42002-03-11 13:55:50 +0000722 ParseARG_FETCH;
drh45f31be2016-02-16 21:19:49 +0000723#define TOKEN yyminor
drh82415f22015-11-09 19:33:42 +0000724/************ Begin %syntax_error code ****************************************/
drh75897232000-05-29 14:26:00 +0000725%%
drh82415f22015-11-09 19:33:42 +0000726/************ End %syntax_error code ******************************************/
drh1f245e42002-03-11 13:55:50 +0000727 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000728}
729
730/*
731** The following is executed when the parser accepts
732*/
733static void yy_accept(
734 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000735){
drh1f245e42002-03-11 13:55:50 +0000736 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000737#ifndef NDEBUG
738 if( yyTraceFILE ){
739 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
740 }
741#endif
drhabecc0b2016-05-24 00:40:54 +0000742 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000743 /* Here code is inserted which will be executed whenever the
744 ** parser accepts */
drh82415f22015-11-09 19:33:42 +0000745/*********** Begin %parse_accept code *****************************************/
drh75897232000-05-29 14:26:00 +0000746%%
drh82415f22015-11-09 19:33:42 +0000747/*********** End %parse_accept code *******************************************/
drh1f245e42002-03-11 13:55:50 +0000748 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000749}
750
751/* The main parser program.
752** The first argument is a pointer to a structure obtained from
753** "ParseAlloc" which describes the current state of the parser.
754** The second argument is the major token number. The third is
755** the minor token. The fourth optional argument is whatever the
756** user wants (and specified in the grammar) and is available for
757** use by the action routines.
758**
759** Inputs:
760** <ul>
761** <li> A pointer to the parser (an opaque structure.)
762** <li> The major token number.
763** <li> The minor token number.
764** <li> An option argument of a grammar-specified type.
765** </ul>
766**
767** Outputs:
768** None.
769*/
drh75897232000-05-29 14:26:00 +0000770void Parse(
771 void *yyp, /* The parser */
772 int yymajor, /* The major token code number */
773 ParseTOKENTYPE yyminor /* The value for the token */
drh1f245e42002-03-11 13:55:50 +0000774 ParseARG_PDECL /* Optional %extra_argument parameter */
drh75897232000-05-29 14:26:00 +0000775){
776 YYMINORTYPE yyminorunion;
drh4ef07702016-03-16 19:45:54 +0000777 unsigned int yyact; /* The parser action. */
drha4414042015-11-09 15:06:26 +0000778#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000779 int yyendofinput; /* True if we are at the end of input */
drha4414042015-11-09 15:06:26 +0000780#endif
drhc4dd3fd2008-01-22 01:48:05 +0000781#ifdef YYERRORSYMBOL
drh75897232000-05-29 14:26:00 +0000782 int yyerrorhit = 0; /* True if yymajor has invoked an error */
drhc4dd3fd2008-01-22 01:48:05 +0000783#endif
drh75897232000-05-29 14:26:00 +0000784 yyParser *yypParser; /* The parser */
785
786 /* (re)initialize the parser, if necessary */
787 yypParser = (yyParser*)yyp;
drhabecc0b2016-05-24 00:40:54 +0000788 assert( yypParser->yytos!=0 );
drha4414042015-11-09 15:06:26 +0000789#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000790 yyendofinput = (yymajor==0);
drha4414042015-11-09 15:06:26 +0000791#endif
drh1f245e42002-03-11 13:55:50 +0000792 ParseARG_STORE;
drh75897232000-05-29 14:26:00 +0000793
794#ifndef NDEBUG
795 if( yyTraceFILE ){
drh0c4105e2015-11-10 14:51:22 +0000796 fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
drh75897232000-05-29 14:26:00 +0000797 }
798#endif
799
800 do{
drh3abbd392008-12-10 23:04:13 +0000801 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
drh3bd48ab2015-09-07 18:23:37 +0000802 if( yyact <= YY_MAX_SHIFTREDUCE ){
drh118ab652016-05-23 21:56:24 +0000803 if( yyact > YY_MAX_SHIFT ){
804 yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
805 }
drh45f31be2016-02-16 21:19:49 +0000806 yy_shift(yypParser,yyact,yymajor,yyminor);
drhdab943c2016-02-16 01:01:43 +0000807#ifndef YYNOERRORRECOVERY
drha248a722015-09-07 19:52:55 +0000808 yypParser->yyerrcnt--;
drhdab943c2016-02-16 01:01:43 +0000809#endif
drha248a722015-09-07 19:52:55 +0000810 yymajor = YYNOCODE;
drh3bd48ab2015-09-07 18:23:37 +0000811 }else if( yyact <= YY_MAX_REDUCE ){
812 yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
drhc4dd3fd2008-01-22 01:48:05 +0000813 }else{
814 assert( yyact == YY_ERROR_ACTION );
drh45f31be2016-02-16 21:19:49 +0000815 yyminorunion.yy0 = yyminor;
drhc4dd3fd2008-01-22 01:48:05 +0000816#ifdef YYERRORSYMBOL
drh3ddfdf72003-12-22 14:53:19 +0000817 int yymx;
drhc4dd3fd2008-01-22 01:48:05 +0000818#endif
drh75897232000-05-29 14:26:00 +0000819#ifndef NDEBUG
820 if( yyTraceFILE ){
821 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
822 }
823#endif
824#ifdef YYERRORSYMBOL
825 /* A syntax error has occurred.
826 ** The response to an error depends upon whether or not the
827 ** grammar defines an error token "ERROR".
828 **
829 ** This is what we do if the grammar does define ERROR:
830 **
831 ** * Call the %syntax_error function.
832 **
833 ** * Begin popping the stack until we enter a state where
834 ** it is legal to shift the error symbol, then shift
835 ** the error symbol.
836 **
837 ** * Set the error count to three.
838 **
839 ** * Begin accepting and shifting new tokens. No new error
840 ** processing will occur until three tokens have been
841 ** shifted successfully.
842 **
843 */
drh1f245e42002-03-11 13:55:50 +0000844 if( yypParser->yyerrcnt<0 ){
drh45f31be2016-02-16 21:19:49 +0000845 yy_syntax_error(yypParser,yymajor,yyminor);
drh75897232000-05-29 14:26:00 +0000846 }
drh118ab652016-05-23 21:56:24 +0000847 yymx = yypParser->yytos->major;
drh3ddfdf72003-12-22 14:53:19 +0000848 if( yymx==YYERRORSYMBOL || yyerrorhit ){
drh75897232000-05-29 14:26:00 +0000849#ifndef NDEBUG
850 if( yyTraceFILE ){
851 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
852 yyTracePrompt,yyTokenName[yymajor]);
853 }
854#endif
drh45f31be2016-02-16 21:19:49 +0000855 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
drh75897232000-05-29 14:26:00 +0000856 yymajor = YYNOCODE;
857 }else{
drh118ab652016-05-23 21:56:24 +0000858 while( yypParser->yytos >= &yypParser->yystack
859 && yymx != YYERRORSYMBOL
860 && (yyact = yy_find_reduce_action(
861 yypParser->yytos->stateno,
drh3bd48ab2015-09-07 18:23:37 +0000862 YYERRORSYMBOL)) >= YY_MIN_REDUCE
drh75897232000-05-29 14:26:00 +0000863 ){
864 yy_pop_parser_stack(yypParser);
865 }
drh118ab652016-05-23 21:56:24 +0000866 if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
drhb27b7f52008-12-10 18:03:45 +0000867 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh1f245e42002-03-11 13:55:50 +0000868 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000869 yymajor = YYNOCODE;
drh3ddfdf72003-12-22 14:53:19 +0000870 }else if( yymx!=YYERRORSYMBOL ){
drh45f31be2016-02-16 21:19:49 +0000871 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
drh75897232000-05-29 14:26:00 +0000872 }
873 }
drh1f245e42002-03-11 13:55:50 +0000874 yypParser->yyerrcnt = 3;
drh75897232000-05-29 14:26:00 +0000875 yyerrorhit = 1;
drhd3ec02d2009-06-12 02:27:14 +0000876#elif defined(YYNOERRORRECOVERY)
877 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
878 ** do any kind of error recovery. Instead, simply invoke the syntax
879 ** error routine and continue going as if nothing had happened.
880 **
881 ** Applications can set this macro (for example inside %include) if
882 ** they intend to abandon the parse upon the first syntax error seen.
883 */
drh45f31be2016-02-16 21:19:49 +0000884 yy_syntax_error(yypParser,yymajor, yyminor);
drhd3ec02d2009-06-12 02:27:14 +0000885 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
886 yymajor = YYNOCODE;
887
drh75897232000-05-29 14:26:00 +0000888#else /* YYERRORSYMBOL is not defined */
889 /* This is what we do if the grammar does not define ERROR:
890 **
891 ** * Report an error message, and throw away the input token.
892 **
893 ** * If the input token is $, then fail the parse.
894 **
895 ** As before, subsequent error messages are suppressed until
896 ** three input tokens have been successfully shifted.
897 */
drh1f245e42002-03-11 13:55:50 +0000898 if( yypParser->yyerrcnt<=0 ){
drh45f31be2016-02-16 21:19:49 +0000899 yy_syntax_error(yypParser,yymajor, yyminor);
drh75897232000-05-29 14:26:00 +0000900 }
drh1f245e42002-03-11 13:55:50 +0000901 yypParser->yyerrcnt = 3;
drhb27b7f52008-12-10 18:03:45 +0000902 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh75897232000-05-29 14:26:00 +0000903 if( yyendofinput ){
drh1f245e42002-03-11 13:55:50 +0000904 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000905 }
906 yymajor = YYNOCODE;
907#endif
drh75897232000-05-29 14:26:00 +0000908 }
drhabecc0b2016-05-24 00:40:54 +0000909 }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
drh3bd48ab2015-09-07 18:23:37 +0000910#ifndef NDEBUG
911 if( yyTraceFILE ){
drh118ab652016-05-23 21:56:24 +0000912 yyStackEntry *i;
913 char cDiv = '[';
drh0c4105e2015-11-10 14:51:22 +0000914 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
drh118ab652016-05-23 21:56:24 +0000915 for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
916 fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
917 cDiv = ' ';
918 }
drh0c4105e2015-11-10 14:51:22 +0000919 fprintf(yyTraceFILE,"]\n");
drh3bd48ab2015-09-07 18:23:37 +0000920 }
921#endif
drh75897232000-05-29 14:26:00 +0000922 return;
923}