1 /* This file is automatically generated by Lemon from input grammar
2 ** source file "src/trace_processor/perfetto_sql/preprocessor/preprocessor_grammar.y".
3 */
4 /*
5 ** 2000-05-29
6 **
7 ** The author disclaims copyright to this source code. In place of
8 ** a legal notice, here is a blessing:
9 **
10 ** May you do good and not evil.
11 ** May you find forgiveness for yourself and forgive others.
12 ** May you share freely, never taking more than you give.
13 **
14 *************************************************************************
15 ** Driver template for the LEMON parser generator.
16 **
17 ** The "lemon" program processes an LALR(1) input grammar file, then uses
18 ** this template to construct a parser. The "lemon" program inserts text
19 ** at each "%%" line. Also, any "P-a-r-s-e" identifer prefix (without the
20 ** interstitial "-" characters) contained in this template is changed into
21 ** the value of the %name directive from the grammar. Otherwise, the content
22 ** of this template is copied straight through into the generate parser
23 ** source file.
24 **
25 ** The following is the concatenation of all %include directives from the
26 ** input grammar file:
27 */
28 /************ Begin %include sections from the grammar ************************/
29 #include "src/trace_processor/perfetto_sql/preprocessor/preprocessor_grammar_interface.h"
30
31 #define YYNOERRORRECOVERY 1
32 #define YYPARSEFREENEVERNULL 1
33 /**************** End of %include directives **********************************/
34 /* These constants specify the various numeric values for terminal symbols.
35 ***************** Begin token definitions *************************************/
36 #ifndef PPTK_SEMI
37 #define PPTK_SEMI 1
38 #define PPTK_APPLY 2
39 #define PPTK_COMMA 3
40 #define PPTK_AND 4
41 #define PPTK_TRUE 5
42 #define PPTK_FALSE 6
43 #define PPTK_ID 7
44 #define PPTK_LP 8
45 #define PPTK_RP 9
46 #define PPTK_OPAQUE 10
47 #define PPTK_EXCLAIM 11
48 #define PPTK_VARIABLE 12
49 #endif
50 /**************** End token definitions ***************************************/
51
52 /* The next sections is a series of control #defines.
53 ** various aspects of the generated parser.
54 ** YYCODETYPE is the data type used to store the integer codes
55 ** that represent terminal and non-terminal symbols.
56 ** "unsigned char" is used if there are fewer than
57 ** 256 symbols. Larger types otherwise.
58 ** YYNOCODE is a number of type YYCODETYPE that is not used for
59 ** any terminal or nonterminal symbol.
60 ** YYFALLBACK If defined, this indicates that one or more tokens
61 ** (also known as: "terminal symbols") have fall-back
62 ** values which should be used if the original symbol
63 ** would not parse. This permits keywords to sometimes
64 ** be used as identifiers, for example.
65 ** YYACTIONTYPE is the data type used for "action codes" - numbers
66 ** that indicate what to do in response to the next
67 ** token.
68 ** PreprocessorGrammarParseTOKENTYPE is the data type used for minor type for terminal
69 ** symbols. Background: A "minor type" is a semantic
70 ** value associated with a terminal or non-terminal
71 ** symbols. For example, for an "ID" terminal symbol,
72 ** the minor type might be the name of the identifier.
73 ** Each non-terminal can have a different minor type.
74 ** Terminal symbols all have the same minor type, though.
75 ** This macros defines the minor type for terminal
76 ** symbols.
77 ** YYMINORTYPE is the data type used for all minor types.
78 ** This is typically a union of many types, one of
79 ** which is PreprocessorGrammarParseTOKENTYPE. The entry in the union
80 ** for terminal symbols is called "yy0".
81 ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
82 ** zero the stack is dynamically sized using realloc()
83 ** PreprocessorGrammarParseARG_SDECL A static variable declaration for the %extra_argument
84 ** PreprocessorGrammarParseARG_PDECL A parameter declaration for the %extra_argument
85 ** PreprocessorGrammarParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
86 ** PreprocessorGrammarParseARG_STORE Code to store %extra_argument into yypParser
87 ** PreprocessorGrammarParseARG_FETCH Code to extract %extra_argument from yypParser
88 ** PreprocessorGrammarParseCTX_* As PreprocessorGrammarParseARG_ except for %extra_context
89 ** YYERRORSYMBOL is the code number of the error symbol. If not
90 ** defined, then do no error processing.
91 ** YYNSTATE the combined number of states.
92 ** YYNRULE the number of rules in the grammar
93 ** YYNTOKEN Number of terminal symbols
94 ** YY_MAX_SHIFT Maximum value for shift actions
95 ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
96 ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
97 ** YY_ERROR_ACTION The yy_action[] code for syntax error
98 ** YY_ACCEPT_ACTION The yy_action[] code for accept
99 ** YY_NO_ACTION The yy_action[] code for no-op
100 ** YY_MIN_REDUCE Minimum value for reduce actions
101 ** YY_MAX_REDUCE Maximum value for reduce actions
102 */
103 #ifndef INTERFACE
104 # define INTERFACE 1
105 #endif
106 /************* Begin control #defines *****************************************/
107 #define YYCODETYPE unsigned char
108 #define YYNOCODE 25
109 #define YYACTIONTYPE unsigned char
110 #define PreprocessorGrammarParseTOKENTYPE struct PreprocessorGrammarToken
111 typedef union {
112 int yyinit;
113 PreprocessorGrammarParseTOKENTYPE yy0;
114 struct PreprocessorGrammarApplyList* yy2;
115 struct PreprocessorGrammarTokenBounds yy32;
116 } YYMINORTYPE;
117 #ifndef YYSTACKDEPTH
118 #define YYSTACKDEPTH 100
119 #endif
120 #define PreprocessorGrammarParseARG_SDECL
121 #define PreprocessorGrammarParseARG_PDECL
122 #define PreprocessorGrammarParseARG_PARAM
123 #define PreprocessorGrammarParseARG_FETCH
124 #define PreprocessorGrammarParseARG_STORE
125 #define PreprocessorGrammarParseCTX_SDECL struct PreprocessorGrammarState* state;
126 #define PreprocessorGrammarParseCTX_PDECL ,struct PreprocessorGrammarState* state
127 #define PreprocessorGrammarParseCTX_PARAM ,state
128 #define PreprocessorGrammarParseCTX_FETCH struct PreprocessorGrammarState* state=yypParser->state;
129 #define PreprocessorGrammarParseCTX_STORE yypParser->state=state;
130 #define YYNSTATE 26
131 #define YYNRULE 26
132 #define YYNRULE_WITH_ACTION 16
133 #define YYNTOKEN 13
134 #define YY_MAX_SHIFT 25
135 #define YY_MIN_SHIFTREDUCE 42
136 #define YY_MAX_SHIFTREDUCE 67
137 #define YY_ERROR_ACTION 68
138 #define YY_ACCEPT_ACTION 69
139 #define YY_NO_ACTION 70
140 #define YY_MIN_REDUCE 71
141 #define YY_MAX_REDUCE 96
142 /************* End control #defines *******************************************/
143 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
144
145 /* Define the yytestcase() macro to be a no-op if is not already defined
146 ** otherwise.
147 **
148 ** Applications can choose to define yytestcase() in the %include section
149 ** to a macro that can assist in verifying code coverage. For production
150 ** code the yytestcase() macro should be turned off. But it is useful
151 ** for testing.
152 */
153 #ifndef yytestcase
154 # define yytestcase(X)
155 #endif
156
157
158 /* Next are the tables used to determine what action to take based on the
159 ** current state and lookahead token. These tables are used to implement
160 ** functions that take a state number and lookahead value and return an
161 ** action integer.
162 **
163 ** Suppose the action integer is N. Then the action is determined as
164 ** follows
165 **
166 ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
167 ** token onto the stack and goto state N.
168 **
169 ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
170 ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
171 **
172 ** N == YY_ERROR_ACTION A syntax error has occurred.
173 **
174 ** N == YY_ACCEPT_ACTION The parser accepts its input.
175 **
176 ** N == YY_NO_ACTION No such action. Denotes unused
177 ** slots in the yy_action[] table.
178 **
179 ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
180 ** and YY_MAX_REDUCE
181 **
182 ** The action table is constructed as a single large table named yy_action[].
183 ** Given state S and lookahead X, the action is computed as either:
184 **
185 ** (A) N = yy_action[ yy_shift_ofst[S] + X ]
186 ** (B) N = yy_default[S]
187 **
188 ** The (A) formula is preferred. The B formula is used instead if
189 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
190 **
191 ** The formulas above are for computing the action when the lookahead is
192 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
193 ** a reduce action) then the yy_reduce_ofst[] array is used in place of
194 ** the yy_shift_ofst[] array.
195 **
196 ** The following are the tables generated in this section:
197 **
198 ** yy_action[] A single table containing all actions.
199 ** yy_lookahead[] A table containing the lookahead for each entry in
200 ** yy_action. Used to detect hash collisions.
201 ** yy_shift_ofst[] For each state, the offset into yy_action for
202 ** shifting terminals.
203 ** yy_reduce_ofst[] For each state, the offset into yy_action for
204 ** shifting non-terminals after a reduce.
205 ** yy_default[] Default action for each state.
206 **
207 *********** Begin parsing tables **********************************************/
208 #define YY_ACTTAB_COUNT (84)
209 static const YYACTIONTYPE yy_action[] = {
210 /* 0 */ 69, 25, 7, 19, 15, 62, 7, 7, 24, 21,
211 /* 10 */ 2, 3, 48, 11, 53, 86, 24, 22, 20, 20,
212 /* 20 */ 62, 85, 24, 4, 21, 2, 51, 48, 62, 53,
213 /* 30 */ 14, 14, 21, 2, 50, 48, 58, 53, 62, 89,
214 /* 40 */ 89, 24, 21, 2, 5, 48, 10, 53, 86, 24,
215 /* 50 */ 21, 2, 6, 48, 17, 53, 6, 6, 24, 59,
216 /* 60 */ 8, 12, 9, 83, 86, 24, 44, 1, 13, 9,
217 /* 70 */ 49, 86, 24, 8, 11, 23, 86, 24, 71, 16,
218 /* 80 */ 95, 70, 18, 18,
219 };
220 static const YYCODETYPE yy_lookahead[] = {
221 /* 0 */ 13, 14, 15, 16, 2, 3, 19, 20, 21, 7,
222 /* 10 */ 8, 8, 10, 18, 12, 20, 21, 22, 23, 24,
223 /* 20 */ 3, 20, 21, 8, 7, 8, 9, 10, 3, 12,
224 /* 30 */ 3, 4, 7, 8, 9, 10, 1, 12, 3, 19,
225 /* 40 */ 20, 21, 7, 8, 3, 10, 18, 12, 20, 21,
226 /* 50 */ 7, 8, 15, 10, 7, 12, 19, 20, 21, 1,
227 /* 60 */ 3, 17, 18, 11, 20, 21, 9, 8, 17, 18,
228 /* 70 */ 9, 20, 21, 3, 18, 11, 20, 21, 0, 9,
229 /* 80 */ 24, 25, 5, 6, 25, 25, 25, 25, 25, 25,
230 /* 90 */ 25, 25, 25, 25, 25, 25, 13,
231 };
232 #define YY_SHIFT_COUNT (25)
233 #define YY_SHIFT_MIN (0)
234 #define YY_SHIFT_MAX (78)
235 static const unsigned char yy_shift_ofst[] = {
236 /* 0 */ 2, 43, 17, 43, 43, 43, 25, 35, 43, 43,
237 /* 10 */ 43, 43, 57, 70, 77, 27, 3, 15, 47, 58,
238 /* 20 */ 41, 52, 61, 59, 64, 78,
239 };
240 #define YY_REDUCE_COUNT (11)
241 #define YY_REDUCE_MIN (-13)
242 #define YY_REDUCE_MAX (56)
243 static const signed char yy_reduce_ofst[] = {
244 /* 0 */ -13, -5, 37, 44, 51, 56, 20, 20, 28, 1,
245 /* 10 */ 1, 1,
246 };
247 static const YYACTIONTYPE yy_default[] = {
248 /* 0 */ 68, 94, 68, 76, 76, 68, 68, 68, 68, 75,
249 /* 10 */ 74, 84, 68, 68, 68, 68, 72, 68, 68, 68,
250 /* 20 */ 93, 81, 68, 68, 68, 68,
251 };
252 /********** End of lemon-generated parsing tables *****************************/
253
254 /* The next table maps tokens (terminal symbols) into fallback tokens.
255 ** If a construct like the following:
256 **
257 ** %fallback ID X Y Z.
258 **
259 ** appears in the grammar, then ID becomes a fallback token for X, Y,
260 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
261 ** but it does not parse, the type of the token is changed to ID and
262 ** the parse is retried before an error is thrown.
263 **
264 ** This feature can be used, for example, to cause some keywords in a language
265 ** to revert to identifiers if they keyword does not apply in the context where
266 ** it appears.
267 */
268 #ifdef YYFALLBACK
269 static const YYCODETYPE yyFallback[] = {
270 };
271 #endif /* YYFALLBACK */
272
273 /* The following structure represents a single element of the
274 ** parser's stack. Information stored includes:
275 **
276 ** + The state number for the parser at this level of the stack.
277 **
278 ** + The value of the token stored at this level of the stack.
279 ** (In other words, the "major" token.)
280 **
281 ** + The semantic value stored at this level of the stack. This is
282 ** the information used by the action routines in the grammar.
283 ** It is sometimes called the "minor" token.
284 **
285 ** After the "shift" half of a SHIFTREDUCE action, the stateno field
286 ** actually contains the reduce action for the second half of the
287 ** SHIFTREDUCE.
288 */
289 struct yyStackEntry {
290 YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
291 YYCODETYPE major; /* The major token value. This is the code
292 ** number for the token at this stack level */
293 YYMINORTYPE minor; /* The user-supplied minor token value. This
294 ** is the value of the token */
295 };
296 typedef struct yyStackEntry yyStackEntry;
297
298 /* The state of the parser is completely contained in an instance of
299 ** the following structure */
300 struct yyParser {
301 yyStackEntry *yytos; /* Pointer to top element of the stack */
302 #ifdef YYTRACKMAXSTACKDEPTH
303 int yyhwm; /* High-water mark of the stack */
304 #endif
305 #ifndef YYNOERRORRECOVERY
306 int yyerrcnt; /* Shifts left before out of the error */
307 #endif
308 PreprocessorGrammarParseARG_SDECL /* A place to hold %extra_argument */
309 PreprocessorGrammarParseCTX_SDECL /* A place to hold %extra_context */
310 #if YYSTACKDEPTH<=0
311 int yystksz; /* Current side of the stack */
312 yyStackEntry *yystack; /* The parser's stack */
313 yyStackEntry yystk0; /* First stack entry */
314 #else
315 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
316 yyStackEntry *yystackEnd; /* Last entry in the stack */
317 #endif
318 };
319 typedef struct yyParser yyParser;
320
321 #include <assert.h>
322 #ifndef NDEBUG
323 #include <stdio.h>
324 static FILE *yyTraceFILE = 0;
325 static char *yyTracePrompt = 0;
326 #endif /* NDEBUG */
327
328 #ifndef NDEBUG
329 /*
330 ** Turn parser tracing on by giving a stream to which to write the trace
331 ** and a prompt to preface each trace message. Tracing is turned off
332 ** by making either argument NULL
333 **
334 ** Inputs:
335 ** <ul>
336 ** <li> A FILE* to which trace output should be written.
337 ** If NULL, then tracing is turned off.
338 ** <li> A prefix string written at the beginning of every
339 ** line of trace output. If NULL, then tracing is
340 ** turned off.
341 ** </ul>
342 **
343 ** Outputs:
344 ** None.
345 */
PreprocessorGrammarParseTrace(FILE * TraceFILE,char * zTracePrompt)346 void PreprocessorGrammarParseTrace(FILE *TraceFILE, char *zTracePrompt){
347 yyTraceFILE = TraceFILE;
348 yyTracePrompt = zTracePrompt;
349 if( yyTraceFILE==0 ) yyTracePrompt = 0;
350 else if( yyTracePrompt==0 ) yyTraceFILE = 0;
351 }
352 #endif /* NDEBUG */
353
354 #if defined(YYCOVERAGE) || !defined(NDEBUG)
355 /* For tracing shifts, the names of all terminals and nonterminals
356 ** are required. The following table supplies these names */
357 static const char *const yyTokenName[] = {
358 /* 0 */ "$",
359 /* 1 */ "SEMI",
360 /* 2 */ "APPLY",
361 /* 3 */ "COMMA",
362 /* 4 */ "AND",
363 /* 5 */ "TRUE",
364 /* 6 */ "FALSE",
365 /* 7 */ "ID",
366 /* 8 */ "LP",
367 /* 9 */ "RP",
368 /* 10 */ "OPAQUE",
369 /* 11 */ "EXCLAIM",
370 /* 12 */ "VARIABLE",
371 /* 13 */ "input",
372 /* 14 */ "cmd",
373 /* 15 */ "sql",
374 /* 16 */ "apply",
375 /* 17 */ "applylist",
376 /* 18 */ "tokenlist",
377 /* 19 */ "sqltoken",
378 /* 20 */ "commalesssqltoken",
379 /* 21 */ "minvocationid",
380 /* 22 */ "marglist",
381 /* 23 */ "marglistinner",
382 /* 24 */ "marg",
383 };
384 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
385
386 #ifndef NDEBUG
387 /* For tracing reduce actions, the names of all rules are required.
388 */
389 static const char *const yyRuleName[] = {
390 /* 0 */ "input ::= cmd",
391 /* 1 */ "apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP",
392 /* 2 */ "apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP LP applylist RP",
393 /* 3 */ "applylist ::= applylist COMMA tokenlist",
394 /* 4 */ "applylist ::= tokenlist",
395 /* 5 */ "applylist ::=",
396 /* 6 */ "commalesssqltoken ::= OPAQUE",
397 /* 7 */ "commalesssqltoken ::= minvocationid EXCLAIM LP marglist RP",
398 /* 8 */ "commalesssqltoken ::= LP sql RP",
399 /* 9 */ "commalesssqltoken ::= LP RP",
400 /* 10 */ "commalesssqltoken ::= ID",
401 /* 11 */ "commalesssqltoken ::= VARIABLE",
402 /* 12 */ "minvocationid ::= ID",
403 /* 13 */ "marg ::= tokenlist",
404 /* 14 */ "tokenlist ::= tokenlist commalesssqltoken",
405 /* 15 */ "tokenlist ::= commalesssqltoken",
406 /* 16 */ "cmd ::= sql SEMI",
407 /* 17 */ "cmd ::= apply SEMI",
408 /* 18 */ "sql ::= sql sqltoken",
409 /* 19 */ "sql ::= sqltoken",
410 /* 20 */ "sqltoken ::= COMMA",
411 /* 21 */ "sqltoken ::= commalesssqltoken",
412 /* 22 */ "marglist ::= marglistinner",
413 /* 23 */ "marglist ::=",
414 /* 24 */ "marglistinner ::= marglistinner COMMA marg",
415 /* 25 */ "marglistinner ::= marg",
416 };
417 #endif /* NDEBUG */
418
419
420 #if YYSTACKDEPTH<=0
421 /*
422 ** Try to increase the size of the parser stack. Return the number
423 ** of errors. Return 0 on success.
424 */
yyGrowStack(yyParser * p)425 static int yyGrowStack(yyParser *p){
426 int newSize;
427 int idx;
428 yyStackEntry *pNew;
429
430 newSize = p->yystksz*2 + 100;
431 idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
432 if( p->yystack==&p->yystk0 ){
433 pNew = malloc(newSize*sizeof(pNew[0]));
434 if( pNew ) pNew[0] = p->yystk0;
435 }else{
436 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
437 }
438 if( pNew ){
439 p->yystack = pNew;
440 p->yytos = &p->yystack[idx];
441 #ifndef NDEBUG
442 if( yyTraceFILE ){
443 fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
444 yyTracePrompt, p->yystksz, newSize);
445 }
446 #endif
447 p->yystksz = newSize;
448 }
449 return pNew==0;
450 }
451 #endif
452
453 /* Datatype of the argument to the memory allocated passed as the
454 ** second argument to PreprocessorGrammarParseAlloc() below. This can be changed by
455 ** putting an appropriate #define in the %include section of the input
456 ** grammar.
457 */
458 #ifndef YYMALLOCARGTYPE
459 # define YYMALLOCARGTYPE size_t
460 #endif
461
462 /* Initialize a new parser that has already been allocated.
463 */
PreprocessorGrammarParseInit(void * yypRawParser PreprocessorGrammarParseCTX_PDECL)464 void PreprocessorGrammarParseInit(void *yypRawParser PreprocessorGrammarParseCTX_PDECL){
465 yyParser *yypParser = (yyParser*)yypRawParser;
466 PreprocessorGrammarParseCTX_STORE
467 #ifdef YYTRACKMAXSTACKDEPTH
468 yypParser->yyhwm = 0;
469 #endif
470 #if YYSTACKDEPTH<=0
471 yypParser->yytos = NULL;
472 yypParser->yystack = NULL;
473 yypParser->yystksz = 0;
474 if( yyGrowStack(yypParser) ){
475 yypParser->yystack = &yypParser->yystk0;
476 yypParser->yystksz = 1;
477 }
478 #endif
479 #ifndef YYNOERRORRECOVERY
480 yypParser->yyerrcnt = -1;
481 #endif
482 yypParser->yytos = yypParser->yystack;
483 yypParser->yystack[0].stateno = 0;
484 yypParser->yystack[0].major = 0;
485 #if YYSTACKDEPTH>0
486 yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
487 #endif
488 }
489
490 #ifndef PreprocessorGrammarParse_ENGINEALWAYSONSTACK
491 /*
492 ** This function allocates a new parser.
493 ** The only argument is a pointer to a function which works like
494 ** malloc.
495 **
496 ** Inputs:
497 ** A pointer to the function used to allocate memory.
498 **
499 ** Outputs:
500 ** A pointer to a parser. This pointer is used in subsequent calls
501 ** to PreprocessorGrammarParse and PreprocessorGrammarParseFree.
502 */
PreprocessorGrammarParseAlloc(void * (* mallocProc)(YYMALLOCARGTYPE)PreprocessorGrammarParseCTX_PDECL)503 void *PreprocessorGrammarParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) PreprocessorGrammarParseCTX_PDECL){
504 yyParser *yypParser;
505 yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
506 if( yypParser ){
507 PreprocessorGrammarParseCTX_STORE
508 PreprocessorGrammarParseInit(yypParser PreprocessorGrammarParseCTX_PARAM);
509 }
510 return (void*)yypParser;
511 }
512 #endif /* PreprocessorGrammarParse_ENGINEALWAYSONSTACK */
513
514
515 /* The following function deletes the "minor type" or semantic value
516 ** associated with a symbol. The symbol can be either a terminal
517 ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
518 ** a pointer to the value to be deleted. The code used to do the
519 ** deletions is derived from the %destructor and/or %token_destructor
520 ** directives of the input grammar.
521 */
yy_destructor(yyParser * yypParser,YYCODETYPE yymajor,YYMINORTYPE * yypminor)522 static void yy_destructor(
523 yyParser *yypParser, /* The parser */
524 YYCODETYPE yymajor, /* Type code for object to destroy */
525 YYMINORTYPE *yypminor /* The object to be destroyed */
526 ){
527 PreprocessorGrammarParseARG_FETCH
528 PreprocessorGrammarParseCTX_FETCH
529 switch( yymajor ){
530 /* Here is inserted the actions which take place when a
531 ** terminal or non-terminal is destroyed. This can happen
532 ** when the symbol is popped from the stack during a
533 ** reduce or during error processing or when a parser is
534 ** being destroyed before it is finished parsing.
535 **
536 ** Note: during a reduce, the only symbols destroyed are those
537 ** which appear on the RHS of the rule, but which are *not* used
538 ** inside the C code.
539 */
540 /********* Begin destructor definitions ***************************************/
541 case 17: /* applylist */
542 {
543 OnPreprocessorFreeApplyList(state, (yypminor->yy2));
544 }
545 break;
546 /********* End destructor definitions *****************************************/
547 default: break; /* If no destructor action specified: do nothing */
548 }
549 }
550
551 /*
552 ** Pop the parser's stack once.
553 **
554 ** If there is a destructor routine associated with the token which
555 ** is popped from the stack, then call it.
556 */
yy_pop_parser_stack(yyParser * pParser)557 static void yy_pop_parser_stack(yyParser *pParser){
558 yyStackEntry *yytos;
559 assert( pParser->yytos!=0 );
560 assert( pParser->yytos > pParser->yystack );
561 yytos = pParser->yytos--;
562 #ifndef NDEBUG
563 if( yyTraceFILE ){
564 fprintf(yyTraceFILE,"%sPopping %s\n",
565 yyTracePrompt,
566 yyTokenName[yytos->major]);
567 }
568 #endif
569 yy_destructor(pParser, yytos->major, &yytos->minor);
570 }
571
572 /*
573 ** Clear all secondary memory allocations from the parser
574 */
PreprocessorGrammarParseFinalize(void * p)575 void PreprocessorGrammarParseFinalize(void *p){
576 yyParser *pParser = (yyParser*)p;
577 while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
578 #if YYSTACKDEPTH<=0
579 if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);
580 #endif
581 }
582
583 #ifndef PreprocessorGrammarParse_ENGINEALWAYSONSTACK
584 /*
585 ** Deallocate and destroy a parser. Destructors are called for
586 ** all stack elements before shutting the parser down.
587 **
588 ** If the YYPARSEFREENEVERNULL macro exists (for example because it
589 ** is defined in a %include section of the input grammar) then it is
590 ** assumed that the input pointer is never NULL.
591 */
PreprocessorGrammarParseFree(void * p,void (* freeProc)(void *))592 void PreprocessorGrammarParseFree(
593 void *p, /* The parser to be deleted */
594 void (*freeProc)(void*) /* Function used to reclaim memory */
595 ){
596 #ifndef YYPARSEFREENEVERNULL
597 if( p==0 ) return;
598 #endif
599 PreprocessorGrammarParseFinalize(p);
600 (*freeProc)(p);
601 }
602 #endif /* PreprocessorGrammarParse_ENGINEALWAYSONSTACK */
603
604 /*
605 ** Return the peak depth of the stack for a parser.
606 */
607 #ifdef YYTRACKMAXSTACKDEPTH
PreprocessorGrammarParseStackPeak(void * p)608 int PreprocessorGrammarParseStackPeak(void *p){
609 yyParser *pParser = (yyParser*)p;
610 return pParser->yyhwm;
611 }
612 #endif
613
614 /* This array of booleans keeps track of the parser statement
615 ** coverage. The element yycoverage[X][Y] is set when the parser
616 ** is in state X and has a lookahead token Y. In a well-tested
617 ** systems, every element of this matrix should end up being set.
618 */
619 #if defined(YYCOVERAGE)
620 static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
621 #endif
622
623 /*
624 ** Write into out a description of every state/lookahead combination that
625 **
626 ** (1) has not been used by the parser, and
627 ** (2) is not a syntax error.
628 **
629 ** Return the number of missed state/lookahead combinations.
630 */
631 #if defined(YYCOVERAGE)
PreprocessorGrammarParseCoverage(FILE * out)632 int PreprocessorGrammarParseCoverage(FILE *out){
633 int stateno, iLookAhead, i;
634 int nMissed = 0;
635 for(stateno=0; stateno<YYNSTATE; stateno++){
636 i = yy_shift_ofst[stateno];
637 for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
638 if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
639 if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
640 if( out ){
641 fprintf(out,"State %d lookahead %s %s\n", stateno,
642 yyTokenName[iLookAhead],
643 yycoverage[stateno][iLookAhead] ? "ok" : "missed");
644 }
645 }
646 }
647 return nMissed;
648 }
649 #endif
650
651 /*
652 ** Find the appropriate action for a parser given the terminal
653 ** look-ahead token iLookAhead.
654 */
yy_find_shift_action(YYCODETYPE iLookAhead,YYACTIONTYPE stateno)655 static YYACTIONTYPE yy_find_shift_action(
656 YYCODETYPE iLookAhead, /* The look-ahead token */
657 YYACTIONTYPE stateno /* Current state number */
658 ){
659 int i;
660
661 if( stateno>YY_MAX_SHIFT ) return stateno;
662 assert( stateno <= YY_SHIFT_COUNT );
663 #if defined(YYCOVERAGE)
664 yycoverage[stateno][iLookAhead] = 1;
665 #endif
666 do{
667 i = yy_shift_ofst[stateno];
668 assert( i>=0 );
669 assert( i<=YY_ACTTAB_COUNT );
670 assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
671 assert( iLookAhead!=YYNOCODE );
672 assert( iLookAhead < YYNTOKEN );
673 i += iLookAhead;
674 assert( i<(int)YY_NLOOKAHEAD );
675 if( yy_lookahead[i]!=iLookAhead ){
676 #ifdef YYFALLBACK
677 YYCODETYPE iFallback; /* Fallback token */
678 assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
679 iFallback = yyFallback[iLookAhead];
680 if( iFallback!=0 ){
681 #ifndef NDEBUG
682 if( yyTraceFILE ){
683 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
684 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
685 }
686 #endif
687 assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
688 iLookAhead = iFallback;
689 continue;
690 }
691 #endif
692 #ifdef YYWILDCARD
693 {
694 int j = i - iLookAhead + YYWILDCARD;
695 assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
696 if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
697 #ifndef NDEBUG
698 if( yyTraceFILE ){
699 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
700 yyTracePrompt, yyTokenName[iLookAhead],
701 yyTokenName[YYWILDCARD]);
702 }
703 #endif /* NDEBUG */
704 return yy_action[j];
705 }
706 }
707 #endif /* YYWILDCARD */
708 return yy_default[stateno];
709 }else{
710 assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) );
711 return yy_action[i];
712 }
713 }while(1);
714 }
715
716 /*
717 ** Find the appropriate action for a parser given the non-terminal
718 ** look-ahead token iLookAhead.
719 */
yy_find_reduce_action(YYACTIONTYPE stateno,YYCODETYPE iLookAhead)720 static YYACTIONTYPE yy_find_reduce_action(
721 YYACTIONTYPE stateno, /* Current state number */
722 YYCODETYPE iLookAhead /* The look-ahead token */
723 ){
724 int i;
725 #ifdef YYERRORSYMBOL
726 if( stateno>YY_REDUCE_COUNT ){
727 return yy_default[stateno];
728 }
729 #else
730 assert( stateno<=YY_REDUCE_COUNT );
731 #endif
732 i = yy_reduce_ofst[stateno];
733 assert( iLookAhead!=YYNOCODE );
734 i += iLookAhead;
735 #ifdef YYERRORSYMBOL
736 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
737 return yy_default[stateno];
738 }
739 #else
740 assert( i>=0 && i<YY_ACTTAB_COUNT );
741 assert( yy_lookahead[i]==iLookAhead );
742 #endif
743 return yy_action[i];
744 }
745
746 /*
747 ** The following routine is called if the stack overflows.
748 */
yyStackOverflow(yyParser * yypParser)749 static void yyStackOverflow(yyParser *yypParser){
750 PreprocessorGrammarParseARG_FETCH
751 PreprocessorGrammarParseCTX_FETCH
752 #ifndef NDEBUG
753 if( yyTraceFILE ){
754 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
755 }
756 #endif
757 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
758 /* Here code is inserted which will execute if the parser
759 ** stack every overflows */
760 /******** Begin %stack_overflow code ******************************************/
761 /******** End %stack_overflow code ********************************************/
762 PreprocessorGrammarParseARG_STORE /* Suppress warning about unused %extra_argument var */
763 PreprocessorGrammarParseCTX_STORE
764 }
765
766 /*
767 ** Print tracing information for a SHIFT action
768 */
769 #ifndef NDEBUG
yyTraceShift(yyParser * yypParser,int yyNewState,const char * zTag)770 static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
771 if( yyTraceFILE ){
772 if( yyNewState<YYNSTATE ){
773 fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
774 yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
775 yyNewState);
776 }else{
777 fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
778 yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
779 yyNewState - YY_MIN_REDUCE);
780 }
781 }
782 }
783 #else
784 # define yyTraceShift(X,Y,Z)
785 #endif
786
787 /*
788 ** Perform a shift action.
789 */
yy_shift(yyParser * yypParser,YYACTIONTYPE yyNewState,YYCODETYPE yyMajor,PreprocessorGrammarParseTOKENTYPE yyMinor)790 static void yy_shift(
791 yyParser *yypParser, /* The parser to be shifted */
792 YYACTIONTYPE yyNewState, /* The new state to shift in */
793 YYCODETYPE yyMajor, /* The major token to shift in */
794 PreprocessorGrammarParseTOKENTYPE yyMinor /* The minor token to shift in */
795 ){
796 yyStackEntry *yytos;
797 yypParser->yytos++;
798 #ifdef YYTRACKMAXSTACKDEPTH
799 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
800 yypParser->yyhwm++;
801 assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
802 }
803 #endif
804 #if YYSTACKDEPTH>0
805 if( yypParser->yytos>yypParser->yystackEnd ){
806 yypParser->yytos--;
807 yyStackOverflow(yypParser);
808 return;
809 }
810 #else
811 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){
812 if( yyGrowStack(yypParser) ){
813 yypParser->yytos--;
814 yyStackOverflow(yypParser);
815 return;
816 }
817 }
818 #endif
819 if( yyNewState > YY_MAX_SHIFT ){
820 yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
821 }
822 yytos = yypParser->yytos;
823 yytos->stateno = yyNewState;
824 yytos->major = yyMajor;
825 yytos->minor.yy0 = yyMinor;
826 yyTraceShift(yypParser, yyNewState, "Shift");
827 }
828
829 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
830 ** of that rule */
831 static const YYCODETYPE yyRuleInfoLhs[] = {
832 13, /* (0) input ::= cmd */
833 16, /* (1) apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP */
834 16, /* (2) apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP LP applylist RP */
835 17, /* (3) applylist ::= applylist COMMA tokenlist */
836 17, /* (4) applylist ::= tokenlist */
837 17, /* (5) applylist ::= */
838 20, /* (6) commalesssqltoken ::= OPAQUE */
839 20, /* (7) commalesssqltoken ::= minvocationid EXCLAIM LP marglist RP */
840 20, /* (8) commalesssqltoken ::= LP sql RP */
841 20, /* (9) commalesssqltoken ::= LP RP */
842 20, /* (10) commalesssqltoken ::= ID */
843 20, /* (11) commalesssqltoken ::= VARIABLE */
844 21, /* (12) minvocationid ::= ID */
845 24, /* (13) marg ::= tokenlist */
846 18, /* (14) tokenlist ::= tokenlist commalesssqltoken */
847 18, /* (15) tokenlist ::= commalesssqltoken */
848 14, /* (16) cmd ::= sql SEMI */
849 14, /* (17) cmd ::= apply SEMI */
850 15, /* (18) sql ::= sql sqltoken */
851 15, /* (19) sql ::= sqltoken */
852 19, /* (20) sqltoken ::= COMMA */
853 19, /* (21) sqltoken ::= commalesssqltoken */
854 22, /* (22) marglist ::= marglistinner */
855 22, /* (23) marglist ::= */
856 23, /* (24) marglistinner ::= marglistinner COMMA marg */
857 23, /* (25) marglistinner ::= marg */
858 };
859
860 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
861 ** of symbols on the right-hand side of that rule. */
862 static const signed char yyRuleInfoNRhs[] = {
863 -1, /* (0) input ::= cmd */
864 -7, /* (1) apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP */
865 -10, /* (2) apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP LP applylist RP */
866 -3, /* (3) applylist ::= applylist COMMA tokenlist */
867 -1, /* (4) applylist ::= tokenlist */
868 0, /* (5) applylist ::= */
869 -1, /* (6) commalesssqltoken ::= OPAQUE */
870 -5, /* (7) commalesssqltoken ::= minvocationid EXCLAIM LP marglist RP */
871 -3, /* (8) commalesssqltoken ::= LP sql RP */
872 -2, /* (9) commalesssqltoken ::= LP RP */
873 -1, /* (10) commalesssqltoken ::= ID */
874 -1, /* (11) commalesssqltoken ::= VARIABLE */
875 -1, /* (12) minvocationid ::= ID */
876 -1, /* (13) marg ::= tokenlist */
877 -2, /* (14) tokenlist ::= tokenlist commalesssqltoken */
878 -1, /* (15) tokenlist ::= commalesssqltoken */
879 -2, /* (16) cmd ::= sql SEMI */
880 -2, /* (17) cmd ::= apply SEMI */
881 -2, /* (18) sql ::= sql sqltoken */
882 -1, /* (19) sql ::= sqltoken */
883 -1, /* (20) sqltoken ::= COMMA */
884 -1, /* (21) sqltoken ::= commalesssqltoken */
885 -1, /* (22) marglist ::= marglistinner */
886 0, /* (23) marglist ::= */
887 -3, /* (24) marglistinner ::= marglistinner COMMA marg */
888 -1, /* (25) marglistinner ::= marg */
889 };
890
891 static void yy_accept(yyParser*); /* Forward Declaration */
892
893 /*
894 ** Perform a reduce action and the shift that must immediately
895 ** follow the reduce.
896 **
897 ** The yyLookahead and yyLookaheadToken parameters provide reduce actions
898 ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
899 ** if the lookahead token has already been consumed. As this procedure is
900 ** only called from one place, optimizing compilers will in-line it, which
901 ** means that the extra parameters have no performance impact.
902 */
yy_reduce(yyParser * yypParser,unsigned int yyruleno,int yyLookahead,PreprocessorGrammarParseTOKENTYPE yyLookaheadToken PreprocessorGrammarParseCTX_PDECL)903 static YYACTIONTYPE yy_reduce(
904 yyParser *yypParser, /* The parser */
905 unsigned int yyruleno, /* Number of the rule by which to reduce */
906 int yyLookahead, /* Lookahead token, or YYNOCODE if none */
907 PreprocessorGrammarParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
908 PreprocessorGrammarParseCTX_PDECL /* %extra_context */
909 ){
910 int yygoto; /* The next state */
911 YYACTIONTYPE yyact; /* The next action */
912 yyStackEntry *yymsp; /* The top of the parser's stack */
913 int yysize; /* Amount to pop the stack */
914 PreprocessorGrammarParseARG_FETCH
915 (void)yyLookahead;
916 (void)yyLookaheadToken;
917 yymsp = yypParser->yytos;
918
919 switch( yyruleno ){
920 /* Beginning here are the reduction cases. A typical example
921 ** follows:
922 ** case 0:
923 ** #line <lineno> <grammarfile>
924 ** { ... } // User supplied code
925 ** #line <lineno> <thisfile>
926 ** break;
927 */
928 /********** Begin reduce actions **********************************************/
929 YYMINORTYPE yylhsminor;
930 case 0: /* input ::= cmd */
931 {
932 OnPreprocessorEnd(state);
933 }
934 break;
935 case 1: /* apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP */
936 {
937 OnPreprocessorApply(state, &yymsp[-3].minor.yy0, &yymsp[-5].minor.yy0, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy2, 0);
938 }
939 break;
940 case 2: /* apply ::= APPLY COMMA|AND TRUE|FALSE ID LP applylist RP LP applylist RP */
941 {
942 OnPreprocessorApply(state, &yymsp[-6].minor.yy0, &yymsp[-8].minor.yy0, &yymsp[-7].minor.yy0, yymsp[-4].minor.yy2, yymsp[-1].minor.yy2);
943 }
944 break;
945 case 3: /* applylist ::= applylist COMMA tokenlist */
946 {
947 yylhsminor.yy2 = OnPreprocessorAppendApplyList(yymsp[-2].minor.yy2, &yymsp[0].minor.yy32);
948 }
949 yymsp[-2].minor.yy2 = yylhsminor.yy2;
950 break;
951 case 4: /* applylist ::= tokenlist */
952 {
953 yylhsminor.yy2 = OnPreprocessorAppendApplyList(OnPreprocessorCreateApplyList(), &yymsp[0].minor.yy32);
954 }
955 yymsp[0].minor.yy2 = yylhsminor.yy2;
956 break;
957 case 5: /* applylist ::= */
958 {
959 yymsp[1].minor.yy2 = OnPreprocessorCreateApplyList();
960 }
961 break;
962 case 6: /* commalesssqltoken ::= OPAQUE */
963 case 10: /* commalesssqltoken ::= ID */ yytestcase(yyruleno==10);
964 {
965 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[0].minor.yy0, yymsp[0].minor.yy0};
966 }
967 yymsp[0].minor.yy32 = yylhsminor.yy32;
968 break;
969 case 7: /* commalesssqltoken ::= minvocationid EXCLAIM LP marglist RP */
970 {
971 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[-4].minor.yy0, yymsp[0].minor.yy0};
972 OnPreprocessorMacroEnd(state, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);
973 }
974 yymsp[-4].minor.yy32 = yylhsminor.yy32;
975 break;
976 case 8: /* commalesssqltoken ::= LP sql RP */
977 {
978 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[-2].minor.yy0, yymsp[0].minor.yy0};
979 }
980 yymsp[-2].minor.yy32 = yylhsminor.yy32;
981 break;
982 case 9: /* commalesssqltoken ::= LP RP */
983 {
984 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[-1].minor.yy0, yymsp[0].minor.yy0};
985 }
986 yymsp[-1].minor.yy32 = yylhsminor.yy32;
987 break;
988 case 11: /* commalesssqltoken ::= VARIABLE */
989 {
990 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[0].minor.yy0, yymsp[0].minor.yy0};
991 OnPreprocessorVariable(state, &yymsp[0].minor.yy0);
992 }
993 yymsp[0].minor.yy32 = yylhsminor.yy32;
994 break;
995 case 12: /* minvocationid ::= ID */
996 {
997 yylhsminor.yy0 = yymsp[0].minor.yy0;
998 OnPreprocessorMacroId(state, &yymsp[0].minor.yy0);
999 }
1000 yymsp[0].minor.yy0 = yylhsminor.yy0;
1001 break;
1002 case 13: /* marg ::= tokenlist */
1003 {
1004 OnPreprocessorMacroArg(state, &yymsp[0].minor.yy32);
1005 }
1006 break;
1007 case 14: /* tokenlist ::= tokenlist commalesssqltoken */
1008 {
1009 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[-1].minor.yy32.start, yymsp[0].minor.yy32.end};
1010 }
1011 yymsp[-1].minor.yy32 = yylhsminor.yy32;
1012 break;
1013 case 15: /* tokenlist ::= commalesssqltoken */
1014 {
1015 yylhsminor.yy32 = (struct PreprocessorGrammarTokenBounds) {yymsp[0].minor.yy32.start, yymsp[0].minor.yy32.end};
1016 }
1017 yymsp[0].minor.yy32 = yylhsminor.yy32;
1018 break;
1019 default:
1020 /* (16) cmd ::= sql SEMI */ yytestcase(yyruleno==16);
1021 /* (17) cmd ::= apply SEMI */ yytestcase(yyruleno==17);
1022 /* (18) sql ::= sql sqltoken */ yytestcase(yyruleno==18);
1023 /* (19) sql ::= sqltoken (OPTIMIZED OUT) */ assert(yyruleno!=19);
1024 /* (20) sqltoken ::= COMMA */ yytestcase(yyruleno==20);
1025 /* (21) sqltoken ::= commalesssqltoken (OPTIMIZED OUT) */ assert(yyruleno!=21);
1026 /* (22) marglist ::= marglistinner */ yytestcase(yyruleno==22);
1027 /* (23) marglist ::= */ yytestcase(yyruleno==23);
1028 /* (24) marglistinner ::= marglistinner COMMA marg */ yytestcase(yyruleno==24);
1029 /* (25) marglistinner ::= marg (OPTIMIZED OUT) */ assert(yyruleno!=25);
1030 break;
1031 /********** End reduce actions ************************************************/
1032 };
1033 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
1034 yygoto = yyRuleInfoLhs[yyruleno];
1035 yysize = yyRuleInfoNRhs[yyruleno];
1036 yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
1037
1038 /* There are no SHIFTREDUCE actions on nonterminals because the table
1039 ** generator has simplified them to pure REDUCE actions. */
1040 assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );
1041
1042 /* It is not possible for a REDUCE to be followed by an error */
1043 assert( yyact!=YY_ERROR_ACTION );
1044
1045 yymsp += yysize+1;
1046 yypParser->yytos = yymsp;
1047 yymsp->stateno = (YYACTIONTYPE)yyact;
1048 yymsp->major = (YYCODETYPE)yygoto;
1049 yyTraceShift(yypParser, yyact, "... then shift");
1050 return yyact;
1051 }
1052
1053 /*
1054 ** The following code executes when the parse fails
1055 */
1056 #ifndef YYNOERRORRECOVERY
yy_parse_failed(yyParser * yypParser)1057 static void yy_parse_failed(
1058 yyParser *yypParser /* The parser */
1059 ){
1060 PreprocessorGrammarParseARG_FETCH
1061 PreprocessorGrammarParseCTX_FETCH
1062 #ifndef NDEBUG
1063 if( yyTraceFILE ){
1064 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
1065 }
1066 #endif
1067 while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
1068 /* Here code is inserted which will be executed whenever the
1069 ** parser fails */
1070 /************ Begin %parse_failure code ***************************************/
1071 /************ End %parse_failure code *****************************************/
1072 PreprocessorGrammarParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1073 PreprocessorGrammarParseCTX_STORE
1074 }
1075 #endif /* YYNOERRORRECOVERY */
1076
1077 /*
1078 ** The following code executes when a syntax error first occurs.
1079 */
yy_syntax_error(yyParser * yypParser,int yymajor,PreprocessorGrammarParseTOKENTYPE yyminor)1080 static void yy_syntax_error(
1081 yyParser *yypParser, /* The parser */
1082 int yymajor, /* The major type of the error token */
1083 PreprocessorGrammarParseTOKENTYPE yyminor /* The minor type of the error token */
1084 ){
1085 PreprocessorGrammarParseARG_FETCH
1086 PreprocessorGrammarParseCTX_FETCH
1087 #define TOKEN yyminor
1088 /************ Begin %syntax_error code ****************************************/
1089
1090 OnPreprocessorSyntaxError(state, &yyminor);
1091 /************ End %syntax_error code ******************************************/
1092 PreprocessorGrammarParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1093 PreprocessorGrammarParseCTX_STORE
1094 }
1095
1096 /*
1097 ** The following is executed when the parser accepts
1098 */
yy_accept(yyParser * yypParser)1099 static void yy_accept(
1100 yyParser *yypParser /* The parser */
1101 ){
1102 PreprocessorGrammarParseARG_FETCH
1103 PreprocessorGrammarParseCTX_FETCH
1104 #ifndef NDEBUG
1105 if( yyTraceFILE ){
1106 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
1107 }
1108 #endif
1109 #ifndef YYNOERRORRECOVERY
1110 yypParser->yyerrcnt = -1;
1111 #endif
1112 assert( yypParser->yytos==yypParser->yystack );
1113 /* Here code is inserted which will be executed whenever the
1114 ** parser accepts */
1115 /*********** Begin %parse_accept code *****************************************/
1116 /*********** End %parse_accept code *******************************************/
1117 PreprocessorGrammarParseARG_STORE /* Suppress warning about unused %extra_argument variable */
1118 PreprocessorGrammarParseCTX_STORE
1119 }
1120
1121 /* The main parser program.
1122 ** The first argument is a pointer to a structure obtained from
1123 ** "PreprocessorGrammarParseAlloc" which describes the current state of the parser.
1124 ** The second argument is the major token number. The third is
1125 ** the minor token. The fourth optional argument is whatever the
1126 ** user wants (and specified in the grammar) and is available for
1127 ** use by the action routines.
1128 **
1129 ** Inputs:
1130 ** <ul>
1131 ** <li> A pointer to the parser (an opaque structure.)
1132 ** <li> The major token number.
1133 ** <li> The minor token number.
1134 ** <li> An option argument of a grammar-specified type.
1135 ** </ul>
1136 **
1137 ** Outputs:
1138 ** None.
1139 */
PreprocessorGrammarParse(void * yyp,int yymajor,PreprocessorGrammarParseTOKENTYPE yyminor PreprocessorGrammarParseARG_PDECL)1140 void PreprocessorGrammarParse(
1141 void *yyp, /* The parser */
1142 int yymajor, /* The major token code number */
1143 PreprocessorGrammarParseTOKENTYPE yyminor /* The value for the token */
1144 PreprocessorGrammarParseARG_PDECL /* Optional %extra_argument parameter */
1145 ){
1146 YYMINORTYPE yyminorunion;
1147 YYACTIONTYPE yyact; /* The parser action. */
1148 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1149 int yyendofinput; /* True if we are at the end of input */
1150 #endif
1151 #ifdef YYERRORSYMBOL
1152 int yyerrorhit = 0; /* True if yymajor has invoked an error */
1153 #endif
1154 yyParser *yypParser = (yyParser*)yyp; /* The parser */
1155 PreprocessorGrammarParseCTX_FETCH
1156 PreprocessorGrammarParseARG_STORE
1157
1158 assert( yypParser->yytos!=0 );
1159 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1160 yyendofinput = (yymajor==0);
1161 #endif
1162
1163 yyact = yypParser->yytos->stateno;
1164 #ifndef NDEBUG
1165 if( yyTraceFILE ){
1166 if( yyact < YY_MIN_REDUCE ){
1167 fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
1168 yyTracePrompt,yyTokenName[yymajor],yyact);
1169 }else{
1170 fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
1171 yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
1172 }
1173 }
1174 #endif
1175
1176 while(1){ /* Exit by "break" */
1177 assert( yypParser->yytos>=yypParser->yystack );
1178 assert( yyact==yypParser->yytos->stateno );
1179 yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
1180 if( yyact >= YY_MIN_REDUCE ){
1181 unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
1182 #ifndef NDEBUG
1183 assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
1184 if( yyTraceFILE ){
1185 int yysize = yyRuleInfoNRhs[yyruleno];
1186 if( yysize ){
1187 fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
1188 yyTracePrompt,
1189 yyruleno, yyRuleName[yyruleno],
1190 yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
1191 yypParser->yytos[yysize].stateno);
1192 }else{
1193 fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
1194 yyTracePrompt, yyruleno, yyRuleName[yyruleno],
1195 yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
1196 }
1197 }
1198 #endif /* NDEBUG */
1199
1200 /* Check that the stack is large enough to grow by a single entry
1201 ** if the RHS of the rule is empty. This ensures that there is room
1202 ** enough on the stack to push the LHS value */
1203 if( yyRuleInfoNRhs[yyruleno]==0 ){
1204 #ifdef YYTRACKMAXSTACKDEPTH
1205 if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
1206 yypParser->yyhwm++;
1207 assert( yypParser->yyhwm ==
1208 (int)(yypParser->yytos - yypParser->yystack));
1209 }
1210 #endif
1211 #if YYSTACKDEPTH>0
1212 if( yypParser->yytos>=yypParser->yystackEnd ){
1213 yyStackOverflow(yypParser);
1214 break;
1215 }
1216 #else
1217 if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
1218 if( yyGrowStack(yypParser) ){
1219 yyStackOverflow(yypParser);
1220 break;
1221 }
1222 }
1223 #endif
1224 }
1225 yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor PreprocessorGrammarParseCTX_PARAM);
1226 }else if( yyact <= YY_MAX_SHIFTREDUCE ){
1227 yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
1228 #ifndef YYNOERRORRECOVERY
1229 yypParser->yyerrcnt--;
1230 #endif
1231 break;
1232 }else if( yyact==YY_ACCEPT_ACTION ){
1233 yypParser->yytos--;
1234 yy_accept(yypParser);
1235 return;
1236 }else{
1237 assert( yyact == YY_ERROR_ACTION );
1238 yyminorunion.yy0 = yyminor;
1239 #ifdef YYERRORSYMBOL
1240 int yymx;
1241 #endif
1242 #ifndef NDEBUG
1243 if( yyTraceFILE ){
1244 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
1245 }
1246 #endif
1247 #ifdef YYERRORSYMBOL
1248 /* A syntax error has occurred.
1249 ** The response to an error depends upon whether or not the
1250 ** grammar defines an error token "ERROR".
1251 **
1252 ** This is what we do if the grammar does define ERROR:
1253 **
1254 ** * Call the %syntax_error function.
1255 **
1256 ** * Begin popping the stack until we enter a state where
1257 ** it is legal to shift the error symbol, then shift
1258 ** the error symbol.
1259 **
1260 ** * Set the error count to three.
1261 **
1262 ** * Begin accepting and shifting new tokens. No new error
1263 ** processing will occur until three tokens have been
1264 ** shifted successfully.
1265 **
1266 */
1267 if( yypParser->yyerrcnt<0 ){
1268 yy_syntax_error(yypParser,yymajor,yyminor);
1269 }
1270 yymx = yypParser->yytos->major;
1271 if( yymx==YYERRORSYMBOL || yyerrorhit ){
1272 #ifndef NDEBUG
1273 if( yyTraceFILE ){
1274 fprintf(yyTraceFILE,"%sDiscard input token %s\n",
1275 yyTracePrompt,yyTokenName[yymajor]);
1276 }
1277 #endif
1278 yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1279 yymajor = YYNOCODE;
1280 }else{
1281 while( yypParser->yytos > yypParser->yystack ){
1282 yyact = yy_find_reduce_action(yypParser->yytos->stateno,
1283 YYERRORSYMBOL);
1284 if( yyact<=YY_MAX_SHIFTREDUCE ) break;
1285 yy_pop_parser_stack(yypParser);
1286 }
1287 if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){
1288 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1289 yy_parse_failed(yypParser);
1290 #ifndef YYNOERRORRECOVERY
1291 yypParser->yyerrcnt = -1;
1292 #endif
1293 yymajor = YYNOCODE;
1294 }else if( yymx!=YYERRORSYMBOL ){
1295 yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);
1296 }
1297 }
1298 yypParser->yyerrcnt = 3;
1299 yyerrorhit = 1;
1300 if( yymajor==YYNOCODE ) break;
1301 yyact = yypParser->yytos->stateno;
1302 #elif defined(YYNOERRORRECOVERY)
1303 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
1304 ** do any kind of error recovery. Instead, simply invoke the syntax
1305 ** error routine and continue going as if nothing had happened.
1306 **
1307 ** Applications can set this macro (for example inside %include) if
1308 ** they intend to abandon the parse upon the first syntax error seen.
1309 */
1310 yy_syntax_error(yypParser,yymajor, yyminor);
1311 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1312 break;
1313 #else /* YYERRORSYMBOL is not defined */
1314 /* This is what we do if the grammar does not define ERROR:
1315 **
1316 ** * Report an error message, and throw away the input token.
1317 **
1318 ** * If the input token is $, then fail the parse.
1319 **
1320 ** As before, subsequent error messages are suppressed until
1321 ** three input tokens have been successfully shifted.
1322 */
1323 if( yypParser->yyerrcnt<=0 ){
1324 yy_syntax_error(yypParser,yymajor, yyminor);
1325 }
1326 yypParser->yyerrcnt = 3;
1327 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
1328 if( yyendofinput ){
1329 yy_parse_failed(yypParser);
1330 #ifndef YYNOERRORRECOVERY
1331 yypParser->yyerrcnt = -1;
1332 #endif
1333 }
1334 break;
1335 #endif
1336 }
1337 }
1338 #ifndef NDEBUG
1339 if( yyTraceFILE ){
1340 yyStackEntry *i;
1341 char cDiv = '[';
1342 fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt);
1343 for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){
1344 fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]);
1345 cDiv = ' ';
1346 }
1347 fprintf(yyTraceFILE,"]\n");
1348 }
1349 #endif
1350 return;
1351 }
1352
1353 /*
1354 ** Return the fallback token corresponding to canonical token iToken, or
1355 ** 0 if iToken has no fallback.
1356 */
PreprocessorGrammarParseFallback(int iToken)1357 int PreprocessorGrammarParseFallback(int iToken){
1358 #ifdef YYFALLBACK
1359 assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
1360 return yyFallback[iToken];
1361 #else
1362 (void)iToken;
1363 return 0;
1364 #endif
1365 }
1366