blob: 312507e5f13d040afff652285c08ac469ae0c5c0 [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
drh26c9b5e2008-04-11 14:56:53 +000090/* The yyzerominor constant is used to initialize instances of
91** YYMINORTYPE objects to zero. */
drh15b024c2008-12-11 02:20:43 +000092static const YYMINORTYPE yyzerominor = { 0 };
93
drh8a415d32009-06-12 13:53:51 +000094/* Define the yytestcase() macro to be a no-op if is not already defined
95** otherwise.
96**
97** Applications can choose to define yytestcase() in the %include section
98** to a macro that can assist in verifying code coverage. For production
99** code the yytestcase() macro should be turned off. But it is useful
100** for testing.
101*/
102#ifndef yytestcase
103# define yytestcase(X)
104#endif
105
drh26c9b5e2008-04-11 14:56:53 +0000106
drh34ff57b2008-07-14 12:27:51 +0000107/* Next are the tables used to determine what action to take based on the
drh8b582012003-10-21 13:16:03 +0000108** current state and lookahead token. These tables are used to implement
109** functions that take a state number and lookahead value and return an
110** action integer.
drh75897232000-05-29 14:26:00 +0000111**
drh8548a052003-10-22 22:15:27 +0000112** Suppose the action integer is N. Then the action is determined as
113** follows
drh75897232000-05-29 14:26:00 +0000114**
drh3bd48ab2015-09-07 18:23:37 +0000115** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
drh8548a052003-10-22 22:15:27 +0000116** token onto the stack and goto state N.
117**
drh3bd48ab2015-09-07 18:23:37 +0000118** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
119** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
drh8548a052003-10-22 22:15:27 +0000120**
drh3bd48ab2015-09-07 18:23:37 +0000121** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
122** and YY_MAX_REDUCE
123
124** N == YY_ERROR_ACTION A syntax error has occurred.
drh8548a052003-10-22 22:15:27 +0000125**
drh3bd48ab2015-09-07 18:23:37 +0000126** N == YY_ACCEPT_ACTION The parser accepts its input.
drh8548a052003-10-22 22:15:27 +0000127**
drh3bd48ab2015-09-07 18:23:37 +0000128** N == YY_NO_ACTION No such action. Denotes unused
drh8548a052003-10-22 22:15:27 +0000129** slots in the yy_action[] table.
130**
131** The action table is constructed as a single large table named yy_action[].
132** Given state S and lookahead X, the action is computed as
drh75897232000-05-29 14:26:00 +0000133**
drh8b582012003-10-21 13:16:03 +0000134** yy_action[ yy_shift_ofst[S] + X ]
135**
drh8548a052003-10-22 22:15:27 +0000136** If the index value yy_shift_ofst[S]+X is out of range or if the value
drh8b582012003-10-21 13:16:03 +0000137** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
138** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
139** and that yy_default[S] should be used instead.
140**
141** The formula above is for computing the action when the lookahead is
142** a terminal symbol. If the lookahead is a non-terminal (as occurs after
143** a reduce action) then the yy_reduce_ofst[] array is used in place of
144** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
145** YY_SHIFT_USE_DFLT.
146**
147** The following are the tables generated in this section:
148**
149** yy_action[] A single table containing all actions.
150** yy_lookahead[] A table containing the lookahead for each entry in
151** yy_action. Used to detect hash collisions.
152** yy_shift_ofst[] For each state, the offset into yy_action for
153** shifting terminals.
154** yy_reduce_ofst[] For each state, the offset into yy_action for
155** shifting non-terminals after a reduce.
156** yy_default[] Default action for each state.
drh82415f22015-11-09 19:33:42 +0000157**
158*********** Begin parsing tables **********************************************/
drh75897232000-05-29 14:26:00 +0000159%%
drh82415f22015-11-09 19:33:42 +0000160/********** End of lemon-generated parsing tables *****************************/
drh75897232000-05-29 14:26:00 +0000161
drh82415f22015-11-09 19:33:42 +0000162/* The next table maps tokens (terminal symbols) into fallback tokens.
163** If a construct like the following:
drh0bd1f4e2002-06-06 18:54:39 +0000164**
165** %fallback ID X Y Z.
166**
drh34ff57b2008-07-14 12:27:51 +0000167** appears in the grammar, then ID becomes a fallback token for X, Y,
drh0bd1f4e2002-06-06 18:54:39 +0000168** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
169** but it does not parse, the type of the token is changed to ID and
170** the parse is retried before an error is thrown.
drh82415f22015-11-09 19:33:42 +0000171**
172** This feature can be used, for example, to cause some keywords in a language
173** to revert to identifiers if they keyword does not apply in the context where
174** it appears.
drh0bd1f4e2002-06-06 18:54:39 +0000175*/
176#ifdef YYFALLBACK
177static const YYCODETYPE yyFallback[] = {
178%%
179};
180#endif /* YYFALLBACK */
181
drh75897232000-05-29 14:26:00 +0000182/* The following structure represents a single element of the
183** parser's stack. Information stored includes:
184**
185** + The state number for the parser at this level of the stack.
186**
187** + The value of the token stored at this level of the stack.
188** (In other words, the "major" token.)
189**
190** + The semantic value stored at this level of the stack. This is
191** the information used by the action routines in the grammar.
192** It is sometimes called the "minor" token.
drha248a722015-09-07 19:52:55 +0000193**
194** After the "shift" half of a SHIFTREDUCE action, the stateno field
195** actually contains the reduce action for the second half of the
196** SHIFTREDUCE.
drh75897232000-05-29 14:26:00 +0000197*/
198struct yyStackEntry {
drha248a722015-09-07 19:52:55 +0000199 YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
drh2abcd582008-07-24 23:34:07 +0000200 YYCODETYPE major; /* The major token value. This is the code
201 ** number for the token at this stack level */
202 YYMINORTYPE minor; /* The user-supplied minor token value. This
203 ** is the value of the token */
drh75897232000-05-29 14:26:00 +0000204};
drh1f245e42002-03-11 13:55:50 +0000205typedef struct yyStackEntry yyStackEntry;
drh75897232000-05-29 14:26:00 +0000206
207/* The state of the parser is completely contained in an instance of
208** the following structure */
209struct yyParser {
drh1f245e42002-03-11 13:55:50 +0000210 int yyidx; /* Index of top element in stack */
drhec424a52008-07-25 15:39:03 +0000211#ifdef YYTRACKMAXSTACKDEPTH
212 int yyidxMax; /* Maximum value of yyidx */
213#endif
drh1f245e42002-03-11 13:55:50 +0000214 int yyerrcnt; /* Shifts left before out of the error */
drh1f245e42002-03-11 13:55:50 +0000215 ParseARG_SDECL /* A place to hold %extra_argument */
drhb19fd012007-03-29 01:44:45 +0000216#if YYSTACKDEPTH<=0
217 int yystksz; /* Current side of the stack */
218 yyStackEntry *yystack; /* The parser's stack */
219#else
drh1f245e42002-03-11 13:55:50 +0000220 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
drhb19fd012007-03-29 01:44:45 +0000221#endif
drh75897232000-05-29 14:26:00 +0000222};
223typedef struct yyParser yyParser;
224
225#ifndef NDEBUG
226#include <stdio.h>
227static FILE *yyTraceFILE = 0;
228static char *yyTracePrompt = 0;
drh0bd1f4e2002-06-06 18:54:39 +0000229#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000230
drh0bd1f4e2002-06-06 18:54:39 +0000231#ifndef NDEBUG
drh75897232000-05-29 14:26:00 +0000232/*
233** Turn parser tracing on by giving a stream to which to write the trace
234** and a prompt to preface each trace message. Tracing is turned off
235** by making either argument NULL
236**
237** Inputs:
238** <ul>
239** <li> A FILE* to which trace output should be written.
240** If NULL, then tracing is turned off.
241** <li> A prefix string written at the beginning of every
242** line of trace output. If NULL, then tracing is
243** turned off.
244** </ul>
245**
246** Outputs:
247** None.
248*/
drh75897232000-05-29 14:26:00 +0000249void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
250 yyTraceFILE = TraceFILE;
251 yyTracePrompt = zTracePrompt;
252 if( yyTraceFILE==0 ) yyTracePrompt = 0;
253 else if( yyTracePrompt==0 ) yyTraceFILE = 0;
254}
drh0bd1f4e2002-06-06 18:54:39 +0000255#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000256
drh0bd1f4e2002-06-06 18:54:39 +0000257#ifndef NDEBUG
drh75897232000-05-29 14:26:00 +0000258/* For tracing shifts, the names of all terminals and nonterminals
259** are required. The following table supplies these names */
drh57196282004-10-06 15:41:16 +0000260static const char *const yyTokenName[] = {
drh75897232000-05-29 14:26:00 +0000261%%
262};
drh0bd1f4e2002-06-06 18:54:39 +0000263#endif /* NDEBUG */
drh75897232000-05-29 14:26:00 +0000264
drh0bd1f4e2002-06-06 18:54:39 +0000265#ifndef NDEBUG
266/* For tracing reduce actions, the names of all rules are required.
267*/
drh57196282004-10-06 15:41:16 +0000268static const char *const yyRuleName[] = {
drh0bd1f4e2002-06-06 18:54:39 +0000269%%
270};
271#endif /* NDEBUG */
drha1b351a2001-09-14 16:42:12 +0000272
drh960e8c62001-04-03 16:53:21 +0000273
drhb19fd012007-03-29 01:44:45 +0000274#if YYSTACKDEPTH<=0
275/*
276** Try to increase the size of the parser stack.
277*/
278static void yyGrowStack(yyParser *p){
279 int newSize;
280 yyStackEntry *pNew;
281
282 newSize = p->yystksz*2 + 100;
283 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
284 if( pNew ){
285 p->yystack = pNew;
286 p->yystksz = newSize;
287#ifndef NDEBUG
288 if( yyTraceFILE ){
289 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
290 yyTracePrompt, p->yystksz);
291 }
292#endif
293 }
294}
295#endif
296
drh82415f22015-11-09 19:33:42 +0000297/* Datatype of the argument to the memory allocated passed as the
298** second argument to ParseAlloc() below. This can be changed by
299** putting an appropriate #define in the %include section of the input
300** grammar.
301*/
302#ifndef YYMALLOCARGTYPE
303# define YYMALLOCARGTYPE size_t
304#endif
305
drh75897232000-05-29 14:26:00 +0000306/*
307** This function allocates a new parser.
308** The only argument is a pointer to a function which works like
309** malloc.
310**
311** Inputs:
312** A pointer to the function used to allocate memory.
313**
314** Outputs:
315** A pointer to a parser. This pointer is used in subsequent calls
316** to Parse and ParseFree.
317*/
drh82415f22015-11-09 19:33:42 +0000318void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
drh75897232000-05-29 14:26:00 +0000319 yyParser *pParser;
drh82415f22015-11-09 19:33:42 +0000320 pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
drh75897232000-05-29 14:26:00 +0000321 if( pParser ){
drh1f245e42002-03-11 13:55:50 +0000322 pParser->yyidx = -1;
drhec424a52008-07-25 15:39:03 +0000323#ifdef YYTRACKMAXSTACKDEPTH
324 pParser->yyidxMax = 0;
325#endif
drhb19fd012007-03-29 01:44:45 +0000326#if YYSTACKDEPTH<=0
drh4c651782008-11-18 23:25:54 +0000327 pParser->yystack = NULL;
328 pParser->yystksz = 0;
drhb19fd012007-03-29 01:44:45 +0000329 yyGrowStack(pParser);
330#endif
drh75897232000-05-29 14:26:00 +0000331 }
332 return pParser;
333}
334
drh82415f22015-11-09 19:33:42 +0000335/* The following function deletes the "minor type" or semantic value
336** associated with a symbol. The symbol can be either a terminal
337** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
338** a pointer to the value to be deleted. The code used to do the
339** deletions is derived from the %destructor and/or %token_destructor
340** directives of the input grammar.
drh75897232000-05-29 14:26:00 +0000341*/
drh633e6d52008-07-28 19:34:53 +0000342static void yy_destructor(
343 yyParser *yypParser, /* The parser */
344 YYCODETYPE yymajor, /* Type code for object to destroy */
345 YYMINORTYPE *yypminor /* The object to be destroyed */
346){
347 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000348 switch( yymajor ){
349 /* Here is inserted the actions which take place when a
350 ** terminal or non-terminal is destroyed. This can happen
351 ** when the symbol is popped from the stack during a
352 ** reduce or during error processing or when a parser is
353 ** being destroyed before it is finished parsing.
354 **
355 ** Note: during a reduce, the only symbols destroyed are those
drh82415f22015-11-09 19:33:42 +0000356 ** which appear on the RHS of the rule, but which are *not* used
drh75897232000-05-29 14:26:00 +0000357 ** inside the C code.
358 */
drh82415f22015-11-09 19:33:42 +0000359/********* Begin destructor definitions ***************************************/
drh75897232000-05-29 14:26:00 +0000360%%
drh82415f22015-11-09 19:33:42 +0000361/********* End destructor definitions *****************************************/
drh75897232000-05-29 14:26:00 +0000362 default: break; /* If no destructor action specified: do nothing */
363 }
364}
365
366/*
367** Pop the parser's stack once.
368**
369** If there is a destructor routine associated with the token which
370** is popped from the stack, then call it.
drh75897232000-05-29 14:26:00 +0000371*/
drh3781f012015-11-09 14:11:37 +0000372static void yy_pop_parser_stack(yyParser *pParser){
373 yyStackEntry *yytos;
374 assert( pParser->yyidx>=0 );
375 yytos = &pParser->yystack[pParser->yyidx--];
drh75897232000-05-29 14:26:00 +0000376#ifndef NDEBUG
drh3781f012015-11-09 14:11:37 +0000377 if( yyTraceFILE ){
drh75897232000-05-29 14:26:00 +0000378 fprintf(yyTraceFILE,"%sPopping %s\n",
379 yyTracePrompt,
drh3ddfdf72003-12-22 14:53:19 +0000380 yyTokenName[yytos->major]);
drh75897232000-05-29 14:26:00 +0000381 }
382#endif
drh3781f012015-11-09 14:11:37 +0000383 yy_destructor(pParser, yytos->major, &yytos->minor);
drh75897232000-05-29 14:26:00 +0000384}
385
386/*
drh82415f22015-11-09 19:33:42 +0000387** Deallocate and destroy a parser. Destructors are called for
drh75897232000-05-29 14:26:00 +0000388** all stack elements before shutting the parser down.
389**
drh82415f22015-11-09 19:33:42 +0000390** If the YYPARSEFREENEVERNULL macro exists (for example because it
391** is defined in a %include section of the input grammar) then it is
392** assumed that the input pointer is never NULL.
drh75897232000-05-29 14:26:00 +0000393*/
drh75897232000-05-29 14:26:00 +0000394void ParseFree(
drh960e8c62001-04-03 16:53:21 +0000395 void *p, /* The parser to be deleted */
396 void (*freeProc)(void*) /* Function used to reclaim memory */
drh75897232000-05-29 14:26:00 +0000397){
398 yyParser *pParser = (yyParser*)p;
drh82415f22015-11-09 19:33:42 +0000399#ifndef YYPARSEFREENEVERNULL
drh75897232000-05-29 14:26:00 +0000400 if( pParser==0 ) return;
drh82415f22015-11-09 19:33:42 +0000401#endif
drh1f245e42002-03-11 13:55:50 +0000402 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
drhb19fd012007-03-29 01:44:45 +0000403#if YYSTACKDEPTH<=0
404 free(pParser->yystack);
405#endif
drh960e8c62001-04-03 16:53:21 +0000406 (*freeProc)((void*)pParser);
drh75897232000-05-29 14:26:00 +0000407}
408
409/*
drhec424a52008-07-25 15:39:03 +0000410** Return the peak depth of the stack for a parser.
411*/
412#ifdef YYTRACKMAXSTACKDEPTH
413int ParseStackPeak(void *p){
414 yyParser *pParser = (yyParser*)p;
415 return pParser->yyidxMax;
416}
417#endif
418
419/*
drh8b582012003-10-21 13:16:03 +0000420** Find the appropriate action for a parser given the terminal
421** look-ahead token iLookAhead.
drh75897232000-05-29 14:26:00 +0000422*/
drh8b582012003-10-21 13:16:03 +0000423static int yy_find_shift_action(
drh75897232000-05-29 14:26:00 +0000424 yyParser *pParser, /* The parser */
drhd9f291e2006-06-13 11:15:47 +0000425 YYCODETYPE iLookAhead /* The look-ahead token */
drh75897232000-05-29 14:26:00 +0000426){
drh8b582012003-10-21 13:16:03 +0000427 int i;
drh3ddfdf72003-12-22 14:53:19 +0000428 int stateno = pParser->yystack[pParser->yyidx].stateno;
drha4414042015-11-09 15:06:26 +0000429
430 if( stateno>=YY_MIN_REDUCE ) return stateno;
drhae2a4082015-09-07 20:02:39 +0000431 assert( stateno <= YY_SHIFT_COUNT );
drha4414042015-11-09 15:06:26 +0000432 do{
433 i = yy_shift_ofst[stateno];
434 if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
435 assert( iLookAhead!=YYNOCODE );
436 i += iLookAhead;
437 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
438 if( iLookAhead>0 ){
drh4767d972006-06-14 15:03:49 +0000439#ifdef YYFALLBACK
drha4414042015-11-09 15:06:26 +0000440 YYCODETYPE iFallback; /* Fallback token */
441 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
442 && (iFallback = yyFallback[iLookAhead])!=0 ){
drh4767d972006-06-14 15:03:49 +0000443#ifndef NDEBUG
444 if( yyTraceFILE ){
drha4414042015-11-09 15:06:26 +0000445 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
446 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
drh4767d972006-06-14 15:03:49 +0000447 }
drha4414042015-11-09 15:06:26 +0000448#endif
449 assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
450 iLookAhead = iFallback;
451 continue;
drhe09daa92006-06-10 13:29:31 +0000452 }
drha4414042015-11-09 15:06:26 +0000453#endif
454#ifdef YYWILDCARD
455 {
456 int j = i - iLookAhead + YYWILDCARD;
457 if(
458#if YY_SHIFT_MIN+YYWILDCARD<0
459 j>=0 &&
460#endif
461#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
462 j<YY_ACTTAB_COUNT &&
463#endif
464 yy_lookahead[j]==YYWILDCARD
465 ){
466#ifndef NDEBUG
467 if( yyTraceFILE ){
468 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
469 yyTracePrompt, yyTokenName[iLookAhead],
470 yyTokenName[YYWILDCARD]);
471 }
472#endif /* NDEBUG */
473 return yy_action[j];
474 }
475 }
drh4767d972006-06-14 15:03:49 +0000476#endif /* YYWILDCARD */
drha4414042015-11-09 15:06:26 +0000477 }
478 return yy_default[stateno];
479 }else{
480 return yy_action[i];
drh0bd1f4e2002-06-06 18:54:39 +0000481 }
drha4414042015-11-09 15:06:26 +0000482 }while(1);
drh8b582012003-10-21 13:16:03 +0000483}
484
485/*
486** Find the appropriate action for a parser given the non-terminal
487** look-ahead token iLookAhead.
drh8b582012003-10-21 13:16:03 +0000488*/
489static int yy_find_reduce_action(
drh161aba32005-02-01 04:09:36 +0000490 int stateno, /* Current state number */
drhd9f291e2006-06-13 11:15:47 +0000491 YYCODETYPE iLookAhead /* The look-ahead token */
drh8b582012003-10-21 13:16:03 +0000492){
493 int i;
drh7f7c2572008-04-27 18:45:10 +0000494#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000495 if( stateno>YY_REDUCE_COUNT ){
drh7f7c2572008-04-27 18:45:10 +0000496 return yy_default[stateno];
497 }
498#else
drhf16371d2009-11-03 19:18:31 +0000499 assert( stateno<=YY_REDUCE_COUNT );
drh7f7c2572008-04-27 18:45:10 +0000500#endif
drh01495b92008-01-23 12:52:40 +0000501 i = yy_reduce_ofst[stateno];
502 assert( i!=YY_REDUCE_USE_DFLT );
503 assert( iLookAhead!=YYNOCODE );
drh8b582012003-10-21 13:16:03 +0000504 i += iLookAhead;
drh7f7c2572008-04-27 18:45:10 +0000505#ifdef YYERRORSYMBOL
drhf16371d2009-11-03 19:18:31 +0000506 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
drh7f7c2572008-04-27 18:45:10 +0000507 return yy_default[stateno];
508 }
509#else
drhf16371d2009-11-03 19:18:31 +0000510 assert( i>=0 && i<YY_ACTTAB_COUNT );
drh01495b92008-01-23 12:52:40 +0000511 assert( yy_lookahead[i]==iLookAhead );
drh7f7c2572008-04-27 18:45:10 +0000512#endif
drh01495b92008-01-23 12:52:40 +0000513 return yy_action[i];
drh75897232000-05-29 14:26:00 +0000514}
515
516/*
drhb19fd012007-03-29 01:44:45 +0000517** The following routine is called if the stack overflows.
518*/
drhb6018612007-03-30 13:35:05 +0000519static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
drhb19fd012007-03-29 01:44:45 +0000520 ParseARG_FETCH;
521 yypParser->yyidx--;
522#ifndef NDEBUG
523 if( yyTraceFILE ){
524 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
525 }
526#endif
527 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
528 /* Here code is inserted which will execute if the parser
529 ** stack every overflows */
drh82415f22015-11-09 19:33:42 +0000530/******** Begin %stack_overflow code ******************************************/
drhb19fd012007-03-29 01:44:45 +0000531%%
drh82415f22015-11-09 19:33:42 +0000532/******** End %stack_overflow code ********************************************/
drhb19fd012007-03-29 01:44:45 +0000533 ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
534}
535
536/*
drha248a722015-09-07 19:52:55 +0000537** Print tracing information for a SHIFT action
538*/
539#ifndef NDEBUG
540static void yyTraceShift(yyParser *yypParser, int yyNewState){
541 if( yyTraceFILE ){
drha248a722015-09-07 19:52:55 +0000542 if( yyNewState<YYNSTATE ){
drh0c4105e2015-11-10 14:51:22 +0000543 fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
544 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major],
545 yyNewState);
drha248a722015-09-07 19:52:55 +0000546 }else{
drh0c4105e2015-11-10 14:51:22 +0000547 fprintf(yyTraceFILE,"%sShift '%s'\n",
548 yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]);
drha248a722015-09-07 19:52:55 +0000549 }
550 }
551}
552#else
553# define yyTraceShift(X,Y)
554#endif
555
556/*
drh82415f22015-11-09 19:33:42 +0000557** Perform a shift action.
drh75897232000-05-29 14:26:00 +0000558*/
drha248a722015-09-07 19:52:55 +0000559static void yy_shift(
drh75897232000-05-29 14:26:00 +0000560 yyParser *yypParser, /* The parser to be shifted */
561 int yyNewState, /* The new state to shift in */
562 int yyMajor, /* The major token to shift in */
drh34ff57b2008-07-14 12:27:51 +0000563 YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */
drh75897232000-05-29 14:26:00 +0000564){
drh3ddfdf72003-12-22 14:53:19 +0000565 yyStackEntry *yytos;
drh1f245e42002-03-11 13:55:50 +0000566 yypParser->yyidx++;
drhec424a52008-07-25 15:39:03 +0000567#ifdef YYTRACKMAXSTACKDEPTH
568 if( yypParser->yyidx>yypParser->yyidxMax ){
569 yypParser->yyidxMax = yypParser->yyidx;
570 }
571#endif
drhb19fd012007-03-29 01:44:45 +0000572#if YYSTACKDEPTH>0
drh1f245e42002-03-11 13:55:50 +0000573 if( yypParser->yyidx>=YYSTACKDEPTH ){
drhb6018612007-03-30 13:35:05 +0000574 yyStackOverflow(yypParser, yypMinor);
drha248a722015-09-07 19:52:55 +0000575 return;
drh75897232000-05-29 14:26:00 +0000576 }
drhb19fd012007-03-29 01:44:45 +0000577#else
578 if( yypParser->yyidx>=yypParser->yystksz ){
579 yyGrowStack(yypParser);
580 if( yypParser->yyidx>=yypParser->yystksz ){
drhb6018612007-03-30 13:35:05 +0000581 yyStackOverflow(yypParser, yypMinor);
drha248a722015-09-07 19:52:55 +0000582 return;
drhb19fd012007-03-29 01:44:45 +0000583 }
584 }
585#endif
drh3ddfdf72003-12-22 14:53:19 +0000586 yytos = &yypParser->yystack[yypParser->yyidx];
drhb27b7f52008-12-10 18:03:45 +0000587 yytos->stateno = (YYACTIONTYPE)yyNewState;
588 yytos->major = (YYCODETYPE)yyMajor;
drh3ddfdf72003-12-22 14:53:19 +0000589 yytos->minor = *yypMinor;
drha248a722015-09-07 19:52:55 +0000590 yyTraceShift(yypParser, yyNewState);
drh75897232000-05-29 14:26:00 +0000591}
592
593/* The following table contains information about every rule that
594** is used during the reduce.
595*/
drh57196282004-10-06 15:41:16 +0000596static const struct {
drh75897232000-05-29 14:26:00 +0000597 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
598 unsigned char nrhs; /* Number of right-hand side symbols in the rule */
599} yyRuleInfo[] = {
600%%
601};
602
drh1f245e42002-03-11 13:55:50 +0000603static void yy_accept(yyParser*); /* Forward Declaration */
drh75897232000-05-29 14:26:00 +0000604
605/*
606** Perform a reduce action and the shift that must immediately
607** follow the reduce.
608*/
609static void yy_reduce(
610 yyParser *yypParser, /* The parser */
611 int yyruleno /* Number of the rule by which to reduce */
drh75897232000-05-29 14:26:00 +0000612){
613 int yygoto; /* The next state */
614 int yyact; /* The next action */
615 YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
drh1f245e42002-03-11 13:55:50 +0000616 yyStackEntry *yymsp; /* The top of the parser's stack */
drh75897232000-05-29 14:26:00 +0000617 int yysize; /* Amount to pop the stack */
drh1f245e42002-03-11 13:55:50 +0000618 ParseARG_FETCH;
drh3ddfdf72003-12-22 14:53:19 +0000619 yymsp = &yypParser->yystack[yypParser->yyidx];
drh0bd1f4e2002-06-06 18:54:39 +0000620#ifndef NDEBUG
621 if( yyTraceFILE && yyruleno>=0
drhd9f291e2006-06-13 11:15:47 +0000622 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
drh3bd48ab2015-09-07 18:23:37 +0000623 yysize = yyRuleInfo[yyruleno].nrhs;
drh0c4105e2015-11-10 14:51:22 +0000624 fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
drh3bd48ab2015-09-07 18:23:37 +0000625 yyRuleName[yyruleno], yymsp[-yysize].stateno);
drh0bd1f4e2002-06-06 18:54:39 +0000626 }
627#endif /* NDEBUG */
drh26c9b5e2008-04-11 14:56:53 +0000628 yygotominor = yyzerominor;
drhcb6c5652007-01-16 18:19:12 +0000629
drh75897232000-05-29 14:26:00 +0000630 switch( yyruleno ){
631 /* Beginning here are the reduction cases. A typical example
632 ** follows:
633 ** case 0:
drh75897232000-05-29 14:26:00 +0000634 ** #line <lineno> <grammarfile>
635 ** { ... } // User supplied code
636 ** #line <lineno> <thisfile>
637 ** break;
638 */
drh82415f22015-11-09 19:33:42 +0000639/********** Begin reduce actions **********************************************/
drh75897232000-05-29 14:26:00 +0000640%%
drh82415f22015-11-09 19:33:42 +0000641/********** End reduce actions ************************************************/
drh75897232000-05-29 14:26:00 +0000642 };
drha4414042015-11-09 15:06:26 +0000643 assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
drh75897232000-05-29 14:26:00 +0000644 yygoto = yyRuleInfo[yyruleno].lhs;
645 yysize = yyRuleInfo[yyruleno].nrhs;
drh1f245e42002-03-11 13:55:50 +0000646 yypParser->yyidx -= yysize;
drh3abbd392008-12-10 23:04:13 +0000647 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
drha248a722015-09-07 19:52:55 +0000648 if( yyact <= YY_MAX_SHIFTREDUCE ){
649 if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
drh3bd48ab2015-09-07 18:23:37 +0000650 /* If the reduce action popped at least
drh490a73b2005-02-01 03:20:00 +0000651 ** one element off the stack, then we can push the new element back
652 ** onto the stack here, and skip the stack overflow test in yy_shift().
653 ** That gives a significant speed improvement. */
654 if( yysize ){
655 yypParser->yyidx++;
656 yymsp -= yysize-1;
shaned87897d2009-01-30 05:40:27 +0000657 yymsp->stateno = (YYACTIONTYPE)yyact;
658 yymsp->major = (YYCODETYPE)yygoto;
drh490a73b2005-02-01 03:20:00 +0000659 yymsp->minor = yygotominor;
drha248a722015-09-07 19:52:55 +0000660 yyTraceShift(yypParser, yyact);
drh3bd48ab2015-09-07 18:23:37 +0000661 }else{
drha248a722015-09-07 19:52:55 +0000662 yy_shift(yypParser,yyact,yygoto,&yygotominor);
drh490a73b2005-02-01 03:20:00 +0000663 }
drh4b2f9362008-01-22 23:37:09 +0000664 }else{
drh3bd48ab2015-09-07 18:23:37 +0000665 assert( yyact == YY_ACCEPT_ACTION );
drh1f245e42002-03-11 13:55:50 +0000666 yy_accept(yypParser);
drh75897232000-05-29 14:26:00 +0000667 }
668}
669
670/*
671** The following code executes when the parse fails
672*/
drhd3ec02d2009-06-12 02:27:14 +0000673#ifndef YYNOERRORRECOVERY
drh75897232000-05-29 14:26:00 +0000674static void yy_parse_failed(
675 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000676){
drh1f245e42002-03-11 13:55:50 +0000677 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000678#ifndef NDEBUG
679 if( yyTraceFILE ){
680 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
681 }
682#endif
drh1f245e42002-03-11 13:55:50 +0000683 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000684 /* Here code is inserted which will be executed whenever the
685 ** parser fails */
drh82415f22015-11-09 19:33:42 +0000686/************ Begin %parse_failure code ***************************************/
drh75897232000-05-29 14:26:00 +0000687%%
drh82415f22015-11-09 19:33:42 +0000688/************ End %parse_failure code *****************************************/
drh1f245e42002-03-11 13:55:50 +0000689 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000690}
drhd3ec02d2009-06-12 02:27:14 +0000691#endif /* YYNOERRORRECOVERY */
drh75897232000-05-29 14:26:00 +0000692
693/*
694** The following code executes when a syntax error first occurs.
695*/
696static void yy_syntax_error(
697 yyParser *yypParser, /* The parser */
698 int yymajor, /* The major type of the error token */
699 YYMINORTYPE yyminor /* The minor type of the error token */
drh75897232000-05-29 14:26:00 +0000700){
drh1f245e42002-03-11 13:55:50 +0000701 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000702#define TOKEN (yyminor.yy0)
drh82415f22015-11-09 19:33:42 +0000703/************ Begin %syntax_error code ****************************************/
drh75897232000-05-29 14:26:00 +0000704%%
drh82415f22015-11-09 19:33:42 +0000705/************ End %syntax_error code ******************************************/
drh1f245e42002-03-11 13:55:50 +0000706 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
drh75897232000-05-29 14:26:00 +0000707}
708
709/*
710** The following is executed when the parser accepts
711*/
712static void yy_accept(
713 yyParser *yypParser /* The parser */
drh75897232000-05-29 14:26:00 +0000714){
drh1f245e42002-03-11 13:55:50 +0000715 ParseARG_FETCH;
drh75897232000-05-29 14:26:00 +0000716#ifndef NDEBUG
717 if( yyTraceFILE ){
718 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
719 }
720#endif
drh1f245e42002-03-11 13:55:50 +0000721 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
drh75897232000-05-29 14:26:00 +0000722 /* Here code is inserted which will be executed whenever the
723 ** parser accepts */
drh82415f22015-11-09 19:33:42 +0000724/*********** Begin %parse_accept code *****************************************/
drh75897232000-05-29 14:26:00 +0000725%%
drh82415f22015-11-09 19:33:42 +0000726/*********** End %parse_accept 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/* The main parser program.
731** The first argument is a pointer to a structure obtained from
732** "ParseAlloc" which describes the current state of the parser.
733** The second argument is the major token number. The third is
734** the minor token. The fourth optional argument is whatever the
735** user wants (and specified in the grammar) and is available for
736** use by the action routines.
737**
738** Inputs:
739** <ul>
740** <li> A pointer to the parser (an opaque structure.)
741** <li> The major token number.
742** <li> The minor token number.
743** <li> An option argument of a grammar-specified type.
744** </ul>
745**
746** Outputs:
747** None.
748*/
drh75897232000-05-29 14:26:00 +0000749void Parse(
750 void *yyp, /* The parser */
751 int yymajor, /* The major token code number */
752 ParseTOKENTYPE yyminor /* The value for the token */
drh1f245e42002-03-11 13:55:50 +0000753 ParseARG_PDECL /* Optional %extra_argument parameter */
drh75897232000-05-29 14:26:00 +0000754){
755 YYMINORTYPE yyminorunion;
756 int yyact; /* The parser action. */
drha4414042015-11-09 15:06:26 +0000757#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000758 int yyendofinput; /* True if we are at the end of input */
drha4414042015-11-09 15:06:26 +0000759#endif
drhc4dd3fd2008-01-22 01:48:05 +0000760#ifdef YYERRORSYMBOL
drh75897232000-05-29 14:26:00 +0000761 int yyerrorhit = 0; /* True if yymajor has invoked an error */
drhc4dd3fd2008-01-22 01:48:05 +0000762#endif
drh75897232000-05-29 14:26:00 +0000763 yyParser *yypParser; /* The parser */
764
765 /* (re)initialize the parser, if necessary */
766 yypParser = (yyParser*)yyp;
drh1f245e42002-03-11 13:55:50 +0000767 if( yypParser->yyidx<0 ){
drhb7bac722007-03-29 02:26:45 +0000768#if YYSTACKDEPTH<=0
drhb19fd012007-03-29 01:44:45 +0000769 if( yypParser->yystksz <=0 ){
drh26c9b5e2008-04-11 14:56:53 +0000770 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/
771 yyminorunion = yyzerominor;
drhb6018612007-03-30 13:35:05 +0000772 yyStackOverflow(yypParser, &yyminorunion);
drhb19fd012007-03-29 01:44:45 +0000773 return;
774 }
drhb7bac722007-03-29 02:26:45 +0000775#endif
drh1f245e42002-03-11 13:55:50 +0000776 yypParser->yyidx = 0;
777 yypParser->yyerrcnt = -1;
drh3ddfdf72003-12-22 14:53:19 +0000778 yypParser->yystack[0].stateno = 0;
779 yypParser->yystack[0].major = 0;
drh0c4105e2015-11-10 14:51:22 +0000780#ifndef NDEBUG
781 if( yyTraceFILE ){
782 fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
783 yyTracePrompt);
784 }
785#endif
drh75897232000-05-29 14:26:00 +0000786 }
787 yyminorunion.yy0 = yyminor;
drha4414042015-11-09 15:06:26 +0000788#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
drh75897232000-05-29 14:26:00 +0000789 yyendofinput = (yymajor==0);
drha4414042015-11-09 15:06:26 +0000790#endif
drh1f245e42002-03-11 13:55:50 +0000791 ParseARG_STORE;
drh75897232000-05-29 14:26:00 +0000792
793#ifndef NDEBUG
794 if( yyTraceFILE ){
drh0c4105e2015-11-10 14:51:22 +0000795 fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
drh75897232000-05-29 14:26:00 +0000796 }
797#endif
798
799 do{
drh3abbd392008-12-10 23:04:13 +0000800 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
drh3bd48ab2015-09-07 18:23:37 +0000801 if( yyact <= YY_MAX_SHIFTREDUCE ){
drha248a722015-09-07 19:52:55 +0000802 if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
803 yy_shift(yypParser,yyact,yymajor,&yyminorunion);
804 yypParser->yyerrcnt--;
805 yymajor = YYNOCODE;
drh3bd48ab2015-09-07 18:23:37 +0000806 }else if( yyact <= YY_MAX_REDUCE ){
807 yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
drhc4dd3fd2008-01-22 01:48:05 +0000808 }else{
809 assert( yyact == YY_ERROR_ACTION );
810#ifdef YYERRORSYMBOL
drh3ddfdf72003-12-22 14:53:19 +0000811 int yymx;
drhc4dd3fd2008-01-22 01:48:05 +0000812#endif
drh75897232000-05-29 14:26:00 +0000813#ifndef NDEBUG
814 if( yyTraceFILE ){
815 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
816 }
817#endif
818#ifdef YYERRORSYMBOL
819 /* A syntax error has occurred.
820 ** The response to an error depends upon whether or not the
821 ** grammar defines an error token "ERROR".
822 **
823 ** This is what we do if the grammar does define ERROR:
824 **
825 ** * Call the %syntax_error function.
826 **
827 ** * Begin popping the stack until we enter a state where
828 ** it is legal to shift the error symbol, then shift
829 ** the error symbol.
830 **
831 ** * Set the error count to three.
832 **
833 ** * Begin accepting and shifting new tokens. No new error
834 ** processing will occur until three tokens have been
835 ** shifted successfully.
836 **
837 */
drh1f245e42002-03-11 13:55:50 +0000838 if( yypParser->yyerrcnt<0 ){
839 yy_syntax_error(yypParser,yymajor,yyminorunion);
drh75897232000-05-29 14:26:00 +0000840 }
drh3ddfdf72003-12-22 14:53:19 +0000841 yymx = yypParser->yystack[yypParser->yyidx].major;
842 if( yymx==YYERRORSYMBOL || yyerrorhit ){
drh75897232000-05-29 14:26:00 +0000843#ifndef NDEBUG
844 if( yyTraceFILE ){
845 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
846 yyTracePrompt,yyTokenName[yymajor]);
847 }
848#endif
drhb27b7f52008-12-10 18:03:45 +0000849 yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);
drh75897232000-05-29 14:26:00 +0000850 yymajor = YYNOCODE;
851 }else{
852 while(
drh1f245e42002-03-11 13:55:50 +0000853 yypParser->yyidx >= 0 &&
drh3ddfdf72003-12-22 14:53:19 +0000854 yymx != YYERRORSYMBOL &&
drhf3a58882006-05-08 15:14:19 +0000855 (yyact = yy_find_reduce_action(
856 yypParser->yystack[yypParser->yyidx].stateno,
drh3bd48ab2015-09-07 18:23:37 +0000857 YYERRORSYMBOL)) >= YY_MIN_REDUCE
drh75897232000-05-29 14:26:00 +0000858 ){
859 yy_pop_parser_stack(yypParser);
860 }
drh1f245e42002-03-11 13:55:50 +0000861 if( yypParser->yyidx < 0 || yymajor==0 ){
drhb27b7f52008-12-10 18:03:45 +0000862 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh1f245e42002-03-11 13:55:50 +0000863 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000864 yymajor = YYNOCODE;
drh3ddfdf72003-12-22 14:53:19 +0000865 }else if( yymx!=YYERRORSYMBOL ){
drh75897232000-05-29 14:26:00 +0000866 YYMINORTYPE u2;
867 u2.YYERRSYMDT = 0;
868 yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
869 }
870 }
drh1f245e42002-03-11 13:55:50 +0000871 yypParser->yyerrcnt = 3;
drh75897232000-05-29 14:26:00 +0000872 yyerrorhit = 1;
drhd3ec02d2009-06-12 02:27:14 +0000873#elif defined(YYNOERRORRECOVERY)
874 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
875 ** do any kind of error recovery. Instead, simply invoke the syntax
876 ** error routine and continue going as if nothing had happened.
877 **
878 ** Applications can set this macro (for example inside %include) if
879 ** they intend to abandon the parse upon the first syntax error seen.
880 */
881 yy_syntax_error(yypParser,yymajor,yyminorunion);
882 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
883 yymajor = YYNOCODE;
884
drh75897232000-05-29 14:26:00 +0000885#else /* YYERRORSYMBOL is not defined */
886 /* This is what we do if the grammar does not define ERROR:
887 **
888 ** * Report an error message, and throw away the input token.
889 **
890 ** * If the input token is $, then fail the parse.
891 **
892 ** As before, subsequent error messages are suppressed until
893 ** three input tokens have been successfully shifted.
894 */
drh1f245e42002-03-11 13:55:50 +0000895 if( yypParser->yyerrcnt<=0 ){
896 yy_syntax_error(yypParser,yymajor,yyminorunion);
drh75897232000-05-29 14:26:00 +0000897 }
drh1f245e42002-03-11 13:55:50 +0000898 yypParser->yyerrcnt = 3;
drhb27b7f52008-12-10 18:03:45 +0000899 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
drh75897232000-05-29 14:26:00 +0000900 if( yyendofinput ){
drh1f245e42002-03-11 13:55:50 +0000901 yy_parse_failed(yypParser);
drh75897232000-05-29 14:26:00 +0000902 }
903 yymajor = YYNOCODE;
904#endif
drh75897232000-05-29 14:26:00 +0000905 }
drh1f245e42002-03-11 13:55:50 +0000906 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
drh3bd48ab2015-09-07 18:23:37 +0000907#ifndef NDEBUG
908 if( yyTraceFILE ){
drh0c4105e2015-11-10 14:51:22 +0000909 int i;
910 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
911 for(i=1; i<=yypParser->yyidx; i++)
912 fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ',
913 yyTokenName[yypParser->yystack[i].major]);
914 fprintf(yyTraceFILE,"]\n");
drh3bd48ab2015-09-07 18:23:37 +0000915 }
916#endif
drh75897232000-05-29 14:26:00 +0000917 return;
918}