BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* Driver template for the LEMON parser generator. |
2 | ** The author disclaims copyright to this source code. |
||
3 | */ |
||
4 | /* First off, code is included that follows the "include" declaration |
||
5 | ** in the input grammar file. */ |
||
6 | #include <stdio.h> |
||
7 | /* Next is all token values, in a form suitable for use by makeheaders. |
||
8 | ** This section will be null unless lemon is run with the -m switch. |
||
9 | */ |
||
10 | /* |
||
11 | ** These constants (all generated automatically by the parser generator) |
||
12 | ** specify the various kinds of tokens (terminals) that the parser |
||
13 | ** understands. |
||
14 | ** |
||
15 | ** Each symbol here is a terminal symbol in the grammar. |
||
16 | */ |
||
17 | /* Make sure the INTERFACE macro is defined. |
||
18 | */ |
||
19 | #ifndef INTERFACE |
||
20 | # define INTERFACE 1 |
||
21 | #endif |
||
22 | /* The next thing included is series of defines which control |
||
23 | ** various aspects of the generated parser. |
||
24 | ** YYCODETYPE is the data type used for storing terminal |
||
25 | ** and nonterminal numbers. "unsigned char" is |
||
26 | ** used if there are fewer than 250 terminals |
||
27 | ** and nonterminals. "int" is used otherwise. |
||
28 | ** YYNOCODE is a number of type YYCODETYPE which corresponds |
||
29 | ** to no legal terminal or nonterminal number. This |
||
30 | ** number is used to fill in empty slots of the hash |
||
31 | ** table. |
||
32 | ** YYFALLBACK If defined, this indicates that one or more tokens |
||
33 | ** have fall-back values which should be used if the |
||
34 | ** original value of the token will not parse. |
||
35 | ** YYACTIONTYPE is the data type used for storing terminal |
||
36 | ** and nonterminal numbers. "unsigned char" is |
||
37 | ** used if there are fewer than 250 rules and |
||
38 | ** states combined. "int" is used otherwise. |
||
39 | ** ParseTOKENTYPE is the data type used for minor tokens given |
||
40 | ** directly to the parser from the tokenizer. |
||
41 | ** YYMINORTYPE is the data type used for all minor tokens. |
||
42 | ** This is typically a union of many types, one of |
||
43 | ** which is ParseTOKENTYPE. The entry in the union |
||
44 | ** for base tokens is called "yy0". |
||
45 | ** YYSTACKDEPTH is the maximum depth of the parser's stack. If |
||
46 | ** zero the stack is dynamically sized using realloc() |
||
47 | ** ParseARG_SDECL A static variable declaration for the %extra_argument |
||
48 | ** ParseARG_PDECL A parameter declaration for the %extra_argument |
||
49 | ** ParseARG_STORE Code to store %extra_argument into yypParser |
||
50 | ** ParseARG_FETCH Code to extract %extra_argument from yypParser |
||
51 | ** YYNSTATE the combined number of states. |
||
52 | ** YYNRULE the number of rules in the grammar |
||
53 | ** YYERRORSYMBOL is the code number of the error symbol. If not |
||
54 | ** defined, then do no error processing. |
||
55 | */ |
||
56 | #define YYCODETYPE unsigned char |
||
57 | #define YYNOCODE 16 |
||
58 | #define YYACTIONTYPE unsigned char |
||
59 | #define ParseTOKENTYPE struct token |
||
60 | typedef union { |
||
61 | int yyinit; |
||
62 | ParseTOKENTYPE yy0; |
||
63 | struct value yy1; |
||
64 | } YYMINORTYPE; |
||
65 | #ifndef YYSTACKDEPTH |
||
66 | #define YYSTACKDEPTH 0 |
||
67 | #endif |
||
68 | #define ParseARG_SDECL struct parser_state *parser_out ; |
||
69 | #define ParseARG_PDECL , struct parser_state *parser_out |
||
70 | #define ParseARG_FETCH struct parser_state *parser_out = yypParser->parser_out |
||
71 | #define ParseARG_STORE yypParser->parser_out = parser_out |
||
72 | #define YYNSTATE 21 |
||
73 | #define YYNRULE 12 |
||
74 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
||
75 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
||
76 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
||
77 | |||
78 | /* The yyzerominor constant is used to initialize instances of |
||
79 | ** YYMINORTYPE objects to zero. */ |
||
80 | static const YYMINORTYPE yyzerominor = { 0 }; |
||
81 | |||
82 | /* Define the yytestcase() macro to be a no-op if is not already defined |
||
83 | ** otherwise. |
||
84 | ** |
||
85 | ** Applications can choose to define yytestcase() in the %include section |
||
86 | ** to a macro that can assist in verifying code coverage. For production |
||
87 | ** code the yytestcase() macro should be turned off. But it is useful |
||
88 | ** for testing. |
||
89 | */ |
||
90 | #ifndef yytestcase |
||
91 | # define yytestcase(X) |
||
92 | #endif |
||
93 | |||
94 | |||
95 | /* Next are the tables used to determine what action to take based on the |
||
96 | ** current state and lookahead token. These tables are used to implement |
||
97 | ** functions that take a state number and lookahead value and return an |
||
98 | ** action integer. |
||
99 | ** |
||
100 | ** Suppose the action integer is N. Then the action is determined as |
||
101 | ** follows |
||
102 | ** |
||
103 | ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead |
||
104 | ** token onto the stack and goto state N. |
||
105 | ** |
||
106 | ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. |
||
107 | ** |
||
108 | ** N == YYNSTATE+YYNRULE A syntax error has occurred. |
||
109 | ** |
||
110 | ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. |
||
111 | ** |
||
112 | ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused |
||
113 | ** slots in the yy_action[] table. |
||
114 | ** |
||
115 | ** The action table is constructed as a single large table named yy_action[]. |
||
116 | ** Given state S and lookahead X, the action is computed as |
||
117 | ** |
||
118 | ** yy_action[ yy_shift_ofst[S] + X ] |
||
119 | ** |
||
120 | ** If the index value yy_shift_ofst[S]+X is out of range or if the value |
||
121 | ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] |
||
122 | ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table |
||
123 | ** and that yy_default[S] should be used instead. |
||
124 | ** |
||
125 | ** The formula above is for computing the action when the lookahead is |
||
126 | ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
||
127 | ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
||
128 | ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of |
||
129 | ** YY_SHIFT_USE_DFLT. |
||
130 | ** |
||
131 | ** The following are the tables generated in this section: |
||
132 | ** |
||
133 | ** yy_action[] A single table containing all actions. |
||
134 | ** yy_lookahead[] A table containing the lookahead for each entry in |
||
135 | ** yy_action. Used to detect hash collisions. |
||
136 | ** yy_shift_ofst[] For each state, the offset into yy_action for |
||
137 | ** shifting terminals. |
||
138 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
||
139 | ** shifting non-terminals after a reduce. |
||
140 | ** yy_default[] Default action for each state. |
||
141 | */ |
||
142 | static const YYACTIONTYPE yy_action[] = { |
||
143 | /* 0 */ 15, 21, 16, 6, 34, 1, 19, 3, 2, 15, |
||
144 | /* 10 */ 14, 16, 9, 11, 15, 5, 16, 7, 18, 1, |
||
145 | /* 20 */ 35, 20, 2, 17, 14, 15, 10, 16, 8, 12, |
||
146 | /* 30 */ 15, 4, 16, 7, 15, 13, 16, 8, 1, 35, |
||
147 | /* 40 */ 35, 2, 35, 14, |
||
148 | }; |
||
149 | static const YYCODETYPE yy_lookahead[] = { |
||
150 | /* 0 */ 10, 0, 12, 13, 14, 2, 3, 1, 5, 10, |
||
151 | /* 10 */ 7, 12, 13, 9, 10, 4, 12, 13, 6, 2, |
||
152 | /* 20 */ 15, 3, 5, 6, 7, 10, 11, 12, 13, 9, |
||
153 | /* 30 */ 10, 1, 12, 13, 10, 11, 12, 13, 2, 15, |
||
154 | /* 40 */ 15, 5, 15, 7, |
||
155 | }; |
||
156 | #define YY_SHIFT_USE_DFLT (-1) |
||
157 | #define YY_SHIFT_MAX 11 |
||
158 | static const signed char yy_shift_ofst[] = { |
||
159 | /* 0 */ 36, 3, 17, 36, 36, 36, 1, 6, 11, 30, |
||
160 | /* 10 */ 12, 18, |
||
161 | }; |
||
162 | #define YY_REDUCE_USE_DFLT (-11) |
||
163 | #define YY_REDUCE_MAX 5 |
||
164 | static const signed char yy_reduce_ofst[] = { |
||
165 | /* 0 */ -10, 4, 15, 20, 24, -1, |
||
166 | }; |
||
167 | static const YYACTIONTYPE yy_default[] = { |
||
168 | /* 0 */ 33, 33, 33, 33, 33, 33, 33, 22, 33, 26, |
||
169 | /* 10 */ 33, 33, 23, 27, 30, 31, 32, 28, 29, 24, |
||
170 | /* 20 */ 25, |
||
171 | }; |
||
172 | #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) |
||
173 | |||
174 | /* The next table maps tokens into fallback tokens. If a construct |
||
175 | ** like the following: |
||
176 | ** |
||
177 | ** %fallback ID X Y Z. |
||
178 | ** |
||
179 | ** appears in the grammar, then ID becomes a fallback token for X, Y, |
||
180 | ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
||
181 | ** but it does not parse, the type of the token is changed to ID and |
||
182 | ** the parse is retried before an error is thrown. |
||
183 | */ |
||
184 | #ifdef YYFALLBACK |
||
185 | static const YYCODETYPE yyFallback[] = { |
||
186 | }; |
||
187 | #endif /* YYFALLBACK */ |
||
188 | |||
189 | /* The following structure represents a single element of the |
||
190 | ** parser's stack. Information stored includes: |
||
191 | ** |
||
192 | ** + The state number for the parser at this level of the stack. |
||
193 | ** |
||
194 | ** + The value of the token stored at this level of the stack. |
||
195 | ** (In other words, the "major" token.) |
||
196 | ** |
||
197 | ** + The semantic value stored at this level of the stack. This is |
||
198 | ** the information used by the action routines in the grammar. |
||
199 | ** It is sometimes called the "minor" token. |
||
200 | */ |
||
201 | struct yyStackEntry { |
||
202 | YYACTIONTYPE stateno; /* The state-number */ |
||
203 | YYCODETYPE major; /* The major token value. This is the code |
||
204 | ** number for the token at this stack level */ |
||
205 | YYMINORTYPE minor; /* The user-supplied minor token value. This |
||
206 | ** is the value of the token */ |
||
207 | }; |
||
208 | typedef struct yyStackEntry yyStackEntry; |
||
209 | |||
210 | /* The state of the parser is completely contained in an instance of |
||
211 | ** the following structure */ |
||
212 | struct yyParser { |
||
213 | int yyidx; /* Index of top element in stack */ |
||
214 | #ifdef YYTRACKMAXSTACKDEPTH |
||
215 | int yyidxMax; /* Maximum value of yyidx */ |
||
216 | #endif |
||
217 | int yyerrcnt; /* Shifts left before out of the error */ |
||
218 | ParseARG_SDECL /* A place to hold %extra_argument */ |
||
219 | #if YYSTACKDEPTH<=0 |
||
220 | int yystksz; /* Current side of the stack */ |
||
221 | yyStackEntry *yystack; /* The parser's stack */ |
||
222 | #else |
||
223 | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
||
224 | #endif |
||
225 | }; |
||
226 | typedef struct yyParser yyParser; |
||
227 | |||
228 | #ifndef NDEBUG |
||
229 | #include <stdio.h> |
||
230 | static FILE *yyTraceFILE = 0; |
||
231 | static char *yyTracePrompt = 0; |
||
232 | #endif /* NDEBUG */ |
||
233 | |||
234 | #ifndef NDEBUG |
||
235 | /* |
||
236 | ** Turn parser tracing on by giving a stream to which to write the trace |
||
237 | ** and a prompt to preface each trace message. Tracing is turned off |
||
238 | ** by making either argument NULL |
||
239 | ** |
||
240 | ** Inputs: |
||
241 | ** <ul> |
||
242 | ** <li> A FILE* to which trace output should be written. |
||
243 | ** If NULL, then tracing is turned off. |
||
244 | ** <li> A prefix string written at the beginning of every |
||
245 | ** line of trace output. If NULL, then tracing is |
||
246 | ** turned off. |
||
247 | ** </ul> |
||
248 | ** |
||
249 | ** Outputs: |
||
250 | ** None. |
||
251 | */ |
||
252 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ |
||
253 | yyTraceFILE = TraceFILE; |
||
254 | yyTracePrompt = zTracePrompt; |
||
255 | if( yyTraceFILE==0 ) yyTracePrompt = 0; |
||
256 | else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
||
257 | } |
||
258 | #endif /* NDEBUG */ |
||
259 | |||
260 | #ifndef NDEBUG |
||
261 | /* For tracing shifts, the names of all terminals and nonterminals |
||
262 | ** are required. The following table supplies these names */ |
||
263 | static const char *const yyTokenName[] = { |
||
264 | "$", "COMMA", "CURLY_OPEN", "CURLY_CLOSE", |
||
265 | "COLON", "BRACKET_OPEN", "BRACKET_CLOSE", "STRING", |
||
266 | "error", "list_contents", "list", "map_contents", |
||
267 | "map", "value", "input", |
||
268 | }; |
||
269 | #endif /* NDEBUG */ |
||
270 | |||
271 | #ifndef NDEBUG |
||
272 | /* For tracing reduce actions, the names of all rules are required. |
||
273 | */ |
||
274 | static const char *const yyRuleName[] = { |
||
275 | /* 0 */ "input ::= value", |
||
276 | /* 1 */ "list_contents ::= value", |
||
277 | /* 2 */ "list_contents ::= value COMMA list_contents", |
||
278 | /* 3 */ "list ::= CURLY_OPEN CURLY_CLOSE", |
||
279 | /* 4 */ "list ::= CURLY_OPEN list_contents CURLY_CLOSE", |
||
280 | /* 5 */ "map_contents ::= value COLON value", |
||
281 | /* 6 */ "map_contents ::= value COLON value COMMA map_contents", |
||
282 | /* 7 */ "map ::= BRACKET_OPEN BRACKET_CLOSE", |
||
283 | /* 8 */ "map ::= BRACKET_OPEN map_contents BRACKET_CLOSE", |
||
284 | /* 9 */ "value ::= STRING", |
||
285 | /* 10 */ "value ::= list", |
||
286 | /* 11 */ "value ::= map", |
||
287 | }; |
||
288 | #endif /* NDEBUG */ |
||
289 | |||
290 | |||
291 | #if YYSTACKDEPTH<=0 |
||
292 | /* |
||
293 | ** Try to increase the size of the parser stack. |
||
294 | */ |
||
295 | static void yyGrowStack(yyParser *p){ |
||
296 | int newSize; |
||
297 | yyStackEntry *pNew; |
||
298 | |||
299 | newSize = p->yystksz*2 + 100; |
||
300 | pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
||
301 | if( pNew ){ |
||
302 | p->yystack = pNew; |
||
303 | p->yystksz = newSize; |
||
304 | #ifndef NDEBUG |
||
305 | if( yyTraceFILE ){ |
||
306 | fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", |
||
307 | yyTracePrompt, p->yystksz); |
||
308 | } |
||
309 | #endif |
||
310 | } |
||
311 | } |
||
312 | #endif |
||
313 | |||
314 | /* |
||
315 | ** This function allocates a new parser. |
||
316 | ** The only argument is a pointer to a function which works like |
||
317 | ** malloc. |
||
318 | ** |
||
319 | ** Inputs: |
||
320 | ** A pointer to the function used to allocate memory. |
||
321 | ** |
||
322 | ** Outputs: |
||
323 | ** A pointer to a parser. This pointer is used in subsequent calls |
||
324 | ** to Parse and ParseFree. |
||
325 | */ |
||
326 | void *ParseAlloc(void *(*mallocProc)(size_t)){ |
||
327 | yyParser *pParser; |
||
328 | pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); |
||
329 | if( pParser ){ |
||
330 | pParser->yyidx = -1; |
||
331 | #ifdef YYTRACKMAXSTACKDEPTH |
||
332 | pParser->yyidxMax = 0; |
||
333 | #endif |
||
334 | #if YYSTACKDEPTH<=0 |
||
335 | pParser->yystack = NULL; |
||
336 | pParser->yystksz = 0; |
||
337 | yyGrowStack(pParser); |
||
338 | #endif |
||
339 | } |
||
340 | return pParser; |
||
341 | } |
||
342 | |||
343 | /* The following function deletes the value associated with a |
||
344 | ** symbol. The symbol can be either a terminal or nonterminal. |
||
345 | ** "yymajor" is the symbol code, and "yypminor" is a pointer to |
||
346 | ** the value. |
||
347 | */ |
||
348 | static void yy_destructor( |
||
349 | yyParser *yypParser, /* The parser */ |
||
350 | YYCODETYPE yymajor, /* Type code for object to destroy */ |
||
351 | YYMINORTYPE *yypminor /* The object to be destroyed */ |
||
352 | ){ |
||
353 | ParseARG_FETCH; |
||
354 | switch( yymajor ){ |
||
355 | /* Here is inserted the actions which take place when a |
||
356 | ** terminal or non-terminal is destroyed. This can happen |
||
357 | ** when the symbol is popped from the stack during a |
||
358 | ** reduce or during error processing or when a parser is |
||
359 | ** being destroyed before it is finished parsing. |
||
360 | ** |
||
361 | ** Note: during a reduce, the only symbols destroyed are those |
||
362 | ** which appear on the RHS of the rule, but which are not used |
||
363 | ** inside the C code. |
||
364 | */ |
||
365 | /* TERMINAL Destructor */ |
||
366 | case 1: /* COMMA */ |
||
367 | case 2: /* CURLY_OPEN */ |
||
368 | case 3: /* CURLY_CLOSE */ |
||
369 | case 4: /* COLON */ |
||
370 | case 5: /* BRACKET_OPEN */ |
||
371 | case 6: /* BRACKET_CLOSE */ |
||
372 | case 7: /* STRING */ |
||
373 | { |
||
374 | #line 37 "NCDValParser_parse.y" |
||
375 | free_token((yypminor->yy0)); |
||
376 | #line 377 "NCDValParser_parse.c" |
||
377 | } |
||
378 | break; |
||
379 | case 9: /* list_contents */ |
||
380 | { |
||
381 | #line 47 "NCDValParser_parse.y" |
||
382 | (void)parser_out; |
||
383 | #line 384 "NCDValParser_parse.c" |
||
384 | } |
||
385 | break; |
||
386 | default: break; /* If no destructor action specified: do nothing */ |
||
387 | } |
||
388 | } |
||
389 | |||
390 | /* |
||
391 | ** Pop the parser's stack once. |
||
392 | ** |
||
393 | ** If there is a destructor routine associated with the token which |
||
394 | ** is popped from the stack, then call it. |
||
395 | ** |
||
396 | ** Return the major token number for the symbol popped. |
||
397 | */ |
||
398 | static int yy_pop_parser_stack(yyParser *pParser){ |
||
399 | YYCODETYPE yymajor; |
||
400 | yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; |
||
401 | |||
402 | if( pParser->yyidx<0 ) return 0; |
||
403 | #ifndef NDEBUG |
||
404 | if( yyTraceFILE && pParser->yyidx>=0 ){ |
||
405 | fprintf(yyTraceFILE,"%sPopping %s\n", |
||
406 | yyTracePrompt, |
||
407 | yyTokenName[yytos->major]); |
||
408 | } |
||
409 | #endif |
||
410 | yymajor = yytos->major; |
||
411 | yy_destructor(pParser, yymajor, &yytos->minor); |
||
412 | pParser->yyidx--; |
||
413 | return yymajor; |
||
414 | } |
||
415 | |||
416 | /* |
||
417 | ** Deallocate and destroy a parser. Destructors are all called for |
||
418 | ** all stack elements before shutting the parser down. |
||
419 | ** |
||
420 | ** Inputs: |
||
421 | ** <ul> |
||
422 | ** <li> A pointer to the parser. This should be a pointer |
||
423 | ** obtained from ParseAlloc. |
||
424 | ** <li> A pointer to a function used to reclaim memory obtained |
||
425 | ** from malloc. |
||
426 | ** </ul> |
||
427 | */ |
||
428 | void ParseFree( |
||
429 | void *p, /* The parser to be deleted */ |
||
430 | void (*freeProc)(void*) /* Function used to reclaim memory */ |
||
431 | ){ |
||
432 | yyParser *pParser = (yyParser*)p; |
||
433 | if( pParser==0 ) return; |
||
434 | while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); |
||
435 | #if YYSTACKDEPTH<=0 |
||
436 | free(pParser->yystack); |
||
437 | #endif |
||
438 | (*freeProc)((void*)pParser); |
||
439 | } |
||
440 | |||
441 | /* |
||
442 | ** Return the peak depth of the stack for a parser. |
||
443 | */ |
||
444 | #ifdef YYTRACKMAXSTACKDEPTH |
||
445 | int ParseStackPeak(void *p){ |
||
446 | yyParser *pParser = (yyParser*)p; |
||
447 | return pParser->yyidxMax; |
||
448 | } |
||
449 | #endif |
||
450 | |||
451 | /* |
||
452 | ** Find the appropriate action for a parser given the terminal |
||
453 | ** look-ahead token iLookAhead. |
||
454 | ** |
||
455 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
||
456 | ** independent of the look-ahead. If it is, return the action, otherwise |
||
457 | ** return YY_NO_ACTION. |
||
458 | */ |
||
459 | static int yy_find_shift_action( |
||
460 | yyParser *pParser, /* The parser */ |
||
461 | YYCODETYPE iLookAhead /* The look-ahead token */ |
||
462 | ){ |
||
463 | int i; |
||
464 | int stateno = pParser->yystack[pParser->yyidx].stateno; |
||
465 | |||
466 | if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ |
||
467 | return yy_default[stateno]; |
||
468 | } |
||
469 | assert( iLookAhead!=YYNOCODE ); |
||
470 | i += iLookAhead; |
||
471 | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
||
472 | if( iLookAhead>0 ){ |
||
473 | #ifdef YYFALLBACK |
||
474 | YYCODETYPE iFallback; /* Fallback token */ |
||
475 | if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |
||
476 | && (iFallback = yyFallback[iLookAhead])!=0 ){ |
||
477 | #ifndef NDEBUG |
||
478 | if( yyTraceFILE ){ |
||
479 | fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
||
480 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
||
481 | } |
||
482 | #endif |
||
483 | return yy_find_shift_action(pParser, iFallback); |
||
484 | } |
||
485 | #endif |
||
486 | #ifdef YYWILDCARD |
||
487 | { |
||
488 | int j = i - iLookAhead + YYWILDCARD; |
||
489 | if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){ |
||
490 | #ifndef NDEBUG |
||
491 | if( yyTraceFILE ){ |
||
492 | fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |
||
493 | yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); |
||
494 | } |
||
495 | #endif /* NDEBUG */ |
||
496 | return yy_action[j]; |
||
497 | } |
||
498 | } |
||
499 | #endif /* YYWILDCARD */ |
||
500 | } |
||
501 | return yy_default[stateno]; |
||
502 | }else{ |
||
503 | return yy_action[i]; |
||
504 | } |
||
505 | } |
||
506 | |||
507 | /* |
||
508 | ** Find the appropriate action for a parser given the non-terminal |
||
509 | ** look-ahead token iLookAhead. |
||
510 | ** |
||
511 | ** If the look-ahead token is YYNOCODE, then check to see if the action is |
||
512 | ** independent of the look-ahead. If it is, return the action, otherwise |
||
513 | ** return YY_NO_ACTION. |
||
514 | */ |
||
515 | static int yy_find_reduce_action( |
||
516 | int stateno, /* Current state number */ |
||
517 | YYCODETYPE iLookAhead /* The look-ahead token */ |
||
518 | ){ |
||
519 | int i; |
||
520 | #ifdef YYERRORSYMBOL |
||
521 | if( stateno>YY_REDUCE_MAX ){ |
||
522 | return yy_default[stateno]; |
||
523 | } |
||
524 | #else |
||
525 | assert( stateno<=YY_REDUCE_MAX ); |
||
526 | #endif |
||
527 | i = yy_reduce_ofst[stateno]; |
||
528 | assert( i!=YY_REDUCE_USE_DFLT ); |
||
529 | assert( iLookAhead!=YYNOCODE ); |
||
530 | i += iLookAhead; |
||
531 | #ifdef YYERRORSYMBOL |
||
532 | if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ |
||
533 | return yy_default[stateno]; |
||
534 | } |
||
535 | #else |
||
536 | assert( i>=0 && i<YY_SZ_ACTTAB ); |
||
537 | assert( yy_lookahead[i]==iLookAhead ); |
||
538 | #endif |
||
539 | return yy_action[i]; |
||
540 | } |
||
541 | |||
542 | /* |
||
543 | ** The following routine is called if the stack overflows. |
||
544 | */ |
||
545 | static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ |
||
546 | ParseARG_FETCH; |
||
547 | yypParser->yyidx--; |
||
548 | #ifndef NDEBUG |
||
549 | if( yyTraceFILE ){ |
||
550 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
||
551 | } |
||
552 | #endif |
||
553 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
||
554 | /* Here code is inserted which will execute if the parser |
||
555 | ** stack every overflows */ |
||
556 | #line 58 "NCDValParser_parse.y" |
||
557 | |||
558 | if (yypMinor) { |
||
559 | free_token(yypMinor->yy0); |
||
560 | } |
||
561 | #line 562 "NCDValParser_parse.c" |
||
562 | ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ |
||
563 | } |
||
564 | |||
565 | /* |
||
566 | ** Perform a shift action. |
||
567 | */ |
||
568 | static void yy_shift( |
||
569 | yyParser *yypParser, /* The parser to be shifted */ |
||
570 | int yyNewState, /* The new state to shift in */ |
||
571 | int yyMajor, /* The major token to shift in */ |
||
572 | YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ |
||
573 | ){ |
||
574 | yyStackEntry *yytos; |
||
575 | yypParser->yyidx++; |
||
576 | #ifdef YYTRACKMAXSTACKDEPTH |
||
577 | if( yypParser->yyidx>yypParser->yyidxMax ){ |
||
578 | yypParser->yyidxMax = yypParser->yyidx; |
||
579 | } |
||
580 | #endif |
||
581 | #if YYSTACKDEPTH>0 |
||
582 | if( yypParser->yyidx>=YYSTACKDEPTH ){ |
||
583 | yyStackOverflow(yypParser, yypMinor); |
||
584 | return; |
||
585 | } |
||
586 | #else |
||
587 | if( yypParser->yyidx>=yypParser->yystksz ){ |
||
588 | yyGrowStack(yypParser); |
||
589 | if( yypParser->yyidx>=yypParser->yystksz ){ |
||
590 | yyStackOverflow(yypParser, yypMinor); |
||
591 | return; |
||
592 | } |
||
593 | } |
||
594 | #endif |
||
595 | yytos = &yypParser->yystack[yypParser->yyidx]; |
||
596 | yytos->stateno = (YYACTIONTYPE)yyNewState; |
||
597 | yytos->major = (YYCODETYPE)yyMajor; |
||
598 | yytos->minor = *yypMinor; |
||
599 | #ifndef NDEBUG |
||
600 | if( yyTraceFILE && yypParser->yyidx>0 ){ |
||
601 | int i; |
||
602 | fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
||
603 | fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
||
604 | for(i=1; i<=yypParser->yyidx; i++) |
||
605 | fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
||
606 | fprintf(yyTraceFILE,"\n"); |
||
607 | } |
||
608 | #endif |
||
609 | } |
||
610 | |||
611 | /* The following table contains information about every rule that |
||
612 | ** is used during the reduce. |
||
613 | */ |
||
614 | static const struct { |
||
615 | YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
||
616 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
||
617 | } yyRuleInfo[] = { |
||
618 | { 14, 1 }, |
||
619 | { 9, 1 }, |
||
620 | { 9, 3 }, |
||
621 | { 10, 2 }, |
||
622 | { 10, 3 }, |
||
623 | { 11, 3 }, |
||
624 | { 11, 5 }, |
||
625 | { 12, 2 }, |
||
626 | { 12, 3 }, |
||
627 | { 13, 1 }, |
||
628 | { 13, 1 }, |
||
629 | { 13, 1 }, |
||
630 | }; |
||
631 | |||
632 | static void yy_accept(yyParser*); /* Forward Declaration */ |
||
633 | |||
634 | /* |
||
635 | ** Perform a reduce action and the shift that must immediately |
||
636 | ** follow the reduce. |
||
637 | */ |
||
638 | static void yy_reduce( |
||
639 | yyParser *yypParser, /* The parser */ |
||
640 | int yyruleno /* Number of the rule by which to reduce */ |
||
641 | ){ |
||
642 | int yygoto; /* The next state */ |
||
643 | int yyact; /* The next action */ |
||
644 | YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ |
||
645 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
||
646 | int yysize; /* Amount to pop the stack */ |
||
647 | ParseARG_FETCH; |
||
648 | yymsp = &yypParser->yystack[yypParser->yyidx]; |
||
649 | #ifndef NDEBUG |
||
650 | if( yyTraceFILE && yyruleno>=0 |
||
651 | && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
||
652 | fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
||
653 | yyRuleName[yyruleno]); |
||
654 | } |
||
655 | #endif /* NDEBUG */ |
||
656 | |||
657 | /* Silence complaints from purify about yygotominor being uninitialized |
||
658 | ** in some cases when it is copied into the stack after the following |
||
659 | ** switch. yygotominor is uninitialized when a rule reduces that does |
||
660 | ** not set the value of its left-hand side nonterminal. Leaving the |
||
661 | ** value of the nonterminal uninitialized is utterly harmless as long |
||
662 | ** as the value is never used. So really the only thing this code |
||
663 | ** accomplishes is to quieten purify. |
||
664 | ** |
||
665 | ** 2007-01-16: The wireshark project (www.wireshark.org) reports that |
||
666 | ** without this code, their parser segfaults. I'm not sure what there |
||
667 | ** parser is doing to make this happen. This is the second bug report |
||
668 | ** from wireshark this week. Clearly they are stressing Lemon in ways |
||
669 | ** that it has not been previously stressed... (SQLite ticket #2172) |
||
670 | */ |
||
671 | /*memset(&yygotominor, 0, sizeof(yygotominor));*/ |
||
672 | yygotominor = yyzerominor; |
||
673 | |||
674 | |||
675 | switch( yyruleno ){ |
||
676 | /* Beginning here are the reduction cases. A typical example |
||
677 | ** follows: |
||
678 | ** case 0: |
||
679 | ** #line <lineno> <grammarfile> |
||
680 | ** { ... } // User supplied code |
||
681 | ** #line <lineno> <thisfile> |
||
682 | ** break; |
||
683 | */ |
||
684 | case 0: /* input ::= value */ |
||
685 | #line 64 "NCDValParser_parse.y" |
||
686 | { |
||
687 | if (!yymsp[0].minor.yy1.have) { |
||
688 | goto failZ0; |
||
689 | } |
||
690 | |||
691 | if (!NCDVal_IsInvalid(parser_out->value)) { |
||
692 | // should never happen |
||
693 | parser_out->error_flags |= ERROR_FLAG_SYNTAX; |
||
694 | goto failZ0; |
||
695 | } |
||
696 | |||
697 | if (!NCDValCons_Complete(&parser_out->cons, yymsp[0].minor.yy1.v, &parser_out->value, &parser_out->cons_error)) { |
||
698 | handle_cons_error(parser_out); |
||
699 | goto failZ0; |
||
700 | } |
||
701 | |||
702 | failZ0:; |
||
703 | } |
||
704 | #line 705 "NCDValParser_parse.c" |
||
705 | break; |
||
706 | case 1: /* list_contents ::= value */ |
||
707 | #line 83 "NCDValParser_parse.y" |
||
708 | { |
||
709 | if (!yymsp[0].minor.yy1.have) { |
||
710 | goto failL0; |
||
711 | } |
||
712 | |||
713 | NCDValCons_NewList(&parser_out->cons, &yygotominor.yy1.v); |
||
714 | |||
715 | if (!NCDValCons_ListPrepend(&parser_out->cons, &yygotominor.yy1.v, yymsp[0].minor.yy1.v, &parser_out->cons_error)) { |
||
716 | handle_cons_error(parser_out); |
||
717 | goto failL0; |
||
718 | } |
||
719 | |||
720 | yygotominor.yy1.have = 1; |
||
721 | goto doneL; |
||
722 | |||
723 | failL0: |
||
724 | yygotominor.yy1.have = 0; |
||
725 | doneL:; |
||
726 | } |
||
727 | #line 728 "NCDValParser_parse.c" |
||
728 | break; |
||
729 | case 2: /* list_contents ::= value COMMA list_contents */ |
||
730 | #line 103 "NCDValParser_parse.y" |
||
731 | { |
||
732 | if (!yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) { |
||
733 | goto failM0; |
||
734 | } |
||
735 | |||
736 | if (!NCDValCons_ListPrepend(&parser_out->cons, &yymsp[0].minor.yy1.v, yymsp[-2].minor.yy1.v, &parser_out->cons_error)) { |
||
737 | handle_cons_error(parser_out); |
||
738 | goto failM0; |
||
739 | } |
||
740 | |||
741 | yygotominor.yy1.have = 1; |
||
742 | yygotominor.yy1.v = yymsp[0].minor.yy1.v; |
||
743 | goto doneM; |
||
744 | |||
745 | failM0: |
||
746 | yygotominor.yy1.have = 0; |
||
747 | doneM:; |
||
748 | yy_destructor(yypParser,1,&yymsp[-1].minor); |
||
749 | } |
||
750 | #line 751 "NCDValParser_parse.c" |
||
751 | break; |
||
752 | case 3: /* list ::= CURLY_OPEN CURLY_CLOSE */ |
||
753 | #line 122 "NCDValParser_parse.y" |
||
754 | { |
||
755 | NCDValCons_NewList(&parser_out->cons, &yygotominor.yy1.v); |
||
756 | yygotominor.yy1.have = 1; |
||
757 | yy_destructor(yypParser,2,&yymsp[-1].minor); |
||
758 | yy_destructor(yypParser,3,&yymsp[0].minor); |
||
759 | } |
||
760 | #line 761 "NCDValParser_parse.c" |
||
761 | break; |
||
762 | case 4: /* list ::= CURLY_OPEN list_contents CURLY_CLOSE */ |
||
763 | #line 127 "NCDValParser_parse.y" |
||
764 | { |
||
765 | yygotominor.yy1 = yymsp[-1].minor.yy1; |
||
766 | yy_destructor(yypParser,2,&yymsp[-2].minor); |
||
767 | yy_destructor(yypParser,3,&yymsp[0].minor); |
||
768 | } |
||
769 | #line 770 "NCDValParser_parse.c" |
||
770 | break; |
||
771 | case 5: /* map_contents ::= value COLON value */ |
||
772 | #line 131 "NCDValParser_parse.y" |
||
773 | { |
||
774 | if (!yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) { |
||
775 | goto failS0; |
||
776 | } |
||
777 | |||
778 | NCDValCons_NewMap(&parser_out->cons, &yygotominor.yy1.v); |
||
779 | |||
780 | if (!NCDValCons_MapInsert(&parser_out->cons, &yygotominor.yy1.v, yymsp[-2].minor.yy1.v, yymsp[0].minor.yy1.v, &parser_out->cons_error)) { |
||
781 | handle_cons_error(parser_out); |
||
782 | goto failS0; |
||
783 | } |
||
784 | |||
785 | yygotominor.yy1.have = 1; |
||
786 | goto doneS; |
||
787 | |||
788 | failS0: |
||
789 | yygotominor.yy1.have = 0; |
||
790 | doneS:; |
||
791 | yy_destructor(yypParser,4,&yymsp[-1].minor); |
||
792 | } |
||
793 | #line 794 "NCDValParser_parse.c" |
||
794 | break; |
||
795 | case 6: /* map_contents ::= value COLON value COMMA map_contents */ |
||
796 | #line 151 "NCDValParser_parse.y" |
||
797 | { |
||
798 | if (!yymsp[-4].minor.yy1.have || !yymsp[-2].minor.yy1.have || !yymsp[0].minor.yy1.have) { |
||
799 | goto failT0; |
||
800 | } |
||
801 | |||
802 | if (!NCDValCons_MapInsert(&parser_out->cons, &yymsp[0].minor.yy1.v, yymsp[-4].minor.yy1.v, yymsp[-2].minor.yy1.v, &parser_out->cons_error)) { |
||
803 | handle_cons_error(parser_out); |
||
804 | goto failT0; |
||
805 | } |
||
806 | |||
807 | yygotominor.yy1.have = 1; |
||
808 | yygotominor.yy1.v = yymsp[0].minor.yy1.v; |
||
809 | goto doneT; |
||
810 | |||
811 | failT0: |
||
812 | yygotominor.yy1.have = 0; |
||
813 | doneT:; |
||
814 | yy_destructor(yypParser,4,&yymsp[-3].minor); |
||
815 | yy_destructor(yypParser,1,&yymsp[-1].minor); |
||
816 | } |
||
817 | #line 818 "NCDValParser_parse.c" |
||
818 | break; |
||
819 | case 7: /* map ::= BRACKET_OPEN BRACKET_CLOSE */ |
||
820 | #line 170 "NCDValParser_parse.y" |
||
821 | { |
||
822 | NCDValCons_NewMap(&parser_out->cons, &yygotominor.yy1.v); |
||
823 | yygotominor.yy1.have = 1; |
||
824 | yy_destructor(yypParser,5,&yymsp[-1].minor); |
||
825 | yy_destructor(yypParser,6,&yymsp[0].minor); |
||
826 | } |
||
827 | #line 828 "NCDValParser_parse.c" |
||
828 | break; |
||
829 | case 8: /* map ::= BRACKET_OPEN map_contents BRACKET_CLOSE */ |
||
830 | #line 175 "NCDValParser_parse.y" |
||
831 | { |
||
832 | yygotominor.yy1 = yymsp[-1].minor.yy1; |
||
833 | yy_destructor(yypParser,5,&yymsp[-2].minor); |
||
834 | yy_destructor(yypParser,6,&yymsp[0].minor); |
||
835 | } |
||
836 | #line 837 "NCDValParser_parse.c" |
||
837 | break; |
||
838 | case 9: /* value ::= STRING */ |
||
839 | #line 179 "NCDValParser_parse.y" |
||
840 | { |
||
841 | ASSERT(yymsp[0].minor.yy0.str) |
||
842 | |||
843 | if (!NCDValCons_NewString(&parser_out->cons, (const uint8_t *)yymsp[0].minor.yy0.str, yymsp[0].minor.yy0.len, &yygotominor.yy1.v, &parser_out->cons_error)) { |
||
844 | handle_cons_error(parser_out); |
||
845 | goto failU0; |
||
846 | } |
||
847 | |||
848 | yygotominor.yy1.have = 1; |
||
849 | goto doneU; |
||
850 | |||
851 | failU0: |
||
852 | yygotominor.yy1.have = 0; |
||
853 | doneU:; |
||
854 | free_token(yymsp[0].minor.yy0); |
||
855 | } |
||
856 | #line 857 "NCDValParser_parse.c" |
||
857 | break; |
||
858 | case 10: /* value ::= list */ |
||
859 | case 11: /* value ::= map */ yytestcase(yyruleno==11); |
||
860 | #line 196 "NCDValParser_parse.y" |
||
861 | { |
||
862 | yygotominor.yy1 = yymsp[0].minor.yy1; |
||
863 | } |
||
864 | #line 865 "NCDValParser_parse.c" |
||
865 | break; |
||
866 | default: |
||
867 | break; |
||
868 | }; |
||
869 | yygoto = yyRuleInfo[yyruleno].lhs; |
||
870 | yysize = yyRuleInfo[yyruleno].nrhs; |
||
871 | yypParser->yyidx -= yysize; |
||
872 | yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
||
873 | if( yyact < YYNSTATE ){ |
||
874 | #ifdef NDEBUG |
||
875 | /* If we are not debugging and the reduce action popped at least |
||
876 | ** one element off the stack, then we can push the new element back |
||
877 | ** onto the stack here, and skip the stack overflow test in yy_shift(). |
||
878 | ** That gives a significant speed improvement. */ |
||
879 | if( yysize ){ |
||
880 | yypParser->yyidx++; |
||
881 | yymsp -= yysize-1; |
||
882 | yymsp->stateno = (YYACTIONTYPE)yyact; |
||
883 | yymsp->major = (YYCODETYPE)yygoto; |
||
884 | yymsp->minor = yygotominor; |
||
885 | }else |
||
886 | #endif |
||
887 | { |
||
888 | yy_shift(yypParser,yyact,yygoto,&yygotominor); |
||
889 | } |
||
890 | }else{ |
||
891 | assert( yyact == YYNSTATE + YYNRULE + 1 ); |
||
892 | yy_accept(yypParser); |
||
893 | } |
||
894 | } |
||
895 | |||
896 | /* |
||
897 | ** The following code executes when the parse fails |
||
898 | */ |
||
899 | #ifndef YYNOERRORRECOVERY |
||
900 | static void yy_parse_failed( |
||
901 | yyParser *yypParser /* The parser */ |
||
902 | ){ |
||
903 | ParseARG_FETCH; |
||
904 | #ifndef NDEBUG |
||
905 | if( yyTraceFILE ){ |
||
906 | fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
||
907 | } |
||
908 | #endif |
||
909 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
||
910 | /* Here code is inserted which will be executed whenever the |
||
911 | ** parser fails */ |
||
912 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
||
913 | } |
||
914 | #endif /* YYNOERRORRECOVERY */ |
||
915 | |||
916 | /* |
||
917 | ** The following code executes when a syntax error first occurs. |
||
918 | */ |
||
919 | static void yy_syntax_error( |
||
920 | yyParser *yypParser, /* The parser */ |
||
921 | int yymajor, /* The major type of the error token */ |
||
922 | YYMINORTYPE yyminor /* The minor type of the error token */ |
||
923 | ){ |
||
924 | ParseARG_FETCH; |
||
925 | #define TOKEN (yyminor.yy0) |
||
926 | #line 53 "NCDValParser_parse.y" |
||
927 | |||
928 | parser_out->error_flags |= ERROR_FLAG_SYNTAX; |
||
929 | #line 930 "NCDValParser_parse.c" |
||
930 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
||
931 | } |
||
932 | |||
933 | /* |
||
934 | ** The following is executed when the parser accepts |
||
935 | */ |
||
936 | static void yy_accept( |
||
937 | yyParser *yypParser /* The parser */ |
||
938 | ){ |
||
939 | ParseARG_FETCH; |
||
940 | #ifndef NDEBUG |
||
941 | if( yyTraceFILE ){ |
||
942 | fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
||
943 | } |
||
944 | #endif |
||
945 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
||
946 | /* Here code is inserted which will be executed whenever the |
||
947 | ** parser accepts */ |
||
948 | ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
||
949 | } |
||
950 | |||
951 | /* The main parser program. |
||
952 | ** The first argument is a pointer to a structure obtained from |
||
953 | ** "ParseAlloc" which describes the current state of the parser. |
||
954 | ** The second argument is the major token number. The third is |
||
955 | ** the minor token. The fourth optional argument is whatever the |
||
956 | ** user wants (and specified in the grammar) and is available for |
||
957 | ** use by the action routines. |
||
958 | ** |
||
959 | ** Inputs: |
||
960 | ** <ul> |
||
961 | ** <li> A pointer to the parser (an opaque structure.) |
||
962 | ** <li> The major token number. |
||
963 | ** <li> The minor token number. |
||
964 | ** <li> An option argument of a grammar-specified type. |
||
965 | ** </ul> |
||
966 | ** |
||
967 | ** Outputs: |
||
968 | ** None. |
||
969 | */ |
||
970 | void Parse( |
||
971 | void *yyp, /* The parser */ |
||
972 | int yymajor, /* The major token code number */ |
||
973 | ParseTOKENTYPE yyminor /* The value for the token */ |
||
974 | ParseARG_PDECL /* Optional %extra_argument parameter */ |
||
975 | ){ |
||
976 | YYMINORTYPE yyminorunion; |
||
977 | int yyact; /* The parser action. */ |
||
978 | int yyendofinput; /* True if we are at the end of input */ |
||
979 | #ifdef YYERRORSYMBOL |
||
980 | int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
||
981 | #endif |
||
982 | yyParser *yypParser; /* The parser */ |
||
983 | |||
984 | /* (re)initialize the parser, if necessary */ |
||
985 | yypParser = (yyParser*)yyp; |
||
986 | if( yypParser->yyidx<0 ){ |
||
987 | #if YYSTACKDEPTH<=0 |
||
988 | if( yypParser->yystksz <=0 ){ |
||
989 | /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ |
||
990 | yyminorunion = yyzerominor; |
||
991 | yyStackOverflow(yypParser, &yyminorunion); |
||
992 | return; |
||
993 | } |
||
994 | #endif |
||
995 | yypParser->yyidx = 0; |
||
996 | yypParser->yyerrcnt = -1; |
||
997 | yypParser->yystack[0].stateno = 0; |
||
998 | yypParser->yystack[0].major = 0; |
||
999 | } |
||
1000 | yyminorunion.yy0 = yyminor; |
||
1001 | yyendofinput = (yymajor==0); |
||
1002 | ParseARG_STORE; |
||
1003 | |||
1004 | #ifndef NDEBUG |
||
1005 | if( yyTraceFILE ){ |
||
1006 | fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); |
||
1007 | } |
||
1008 | #endif |
||
1009 | |||
1010 | do{ |
||
1011 | yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
||
1012 | if( yyact<YYNSTATE ){ |
||
1013 | assert( !yyendofinput ); /* Impossible to shift the $ token */ |
||
1014 | yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
||
1015 | yypParser->yyerrcnt--; |
||
1016 | yymajor = YYNOCODE; |
||
1017 | }else if( yyact < YYNSTATE + YYNRULE ){ |
||
1018 | yy_reduce(yypParser,yyact-YYNSTATE); |
||
1019 | }else{ |
||
1020 | assert( yyact == YY_ERROR_ACTION ); |
||
1021 | #ifdef YYERRORSYMBOL |
||
1022 | int yymx; |
||
1023 | #endif |
||
1024 | #ifndef NDEBUG |
||
1025 | if( yyTraceFILE ){ |
||
1026 | fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); |
||
1027 | } |
||
1028 | #endif |
||
1029 | #ifdef YYERRORSYMBOL |
||
1030 | /* A syntax error has occurred. |
||
1031 | ** The response to an error depends upon whether or not the |
||
1032 | ** grammar defines an error token "ERROR". |
||
1033 | ** |
||
1034 | ** This is what we do if the grammar does define ERROR: |
||
1035 | ** |
||
1036 | ** * Call the %syntax_error function. |
||
1037 | ** |
||
1038 | ** * Begin popping the stack until we enter a state where |
||
1039 | ** it is legal to shift the error symbol, then shift |
||
1040 | ** the error symbol. |
||
1041 | ** |
||
1042 | ** * Set the error count to three. |
||
1043 | ** |
||
1044 | ** * Begin accepting and shifting new tokens. No new error |
||
1045 | ** processing will occur until three tokens have been |
||
1046 | ** shifted successfully. |
||
1047 | ** |
||
1048 | */ |
||
1049 | if( yypParser->yyerrcnt<0 ){ |
||
1050 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
||
1051 | } |
||
1052 | yymx = yypParser->yystack[yypParser->yyidx].major; |
||
1053 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
||
1054 | #ifndef NDEBUG |
||
1055 | if( yyTraceFILE ){ |
||
1056 | fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
||
1057 | yyTracePrompt,yyTokenName[yymajor]); |
||
1058 | } |
||
1059 | #endif |
||
1060 | yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); |
||
1061 | yymajor = YYNOCODE; |
||
1062 | }else{ |
||
1063 | while( |
||
1064 | yypParser->yyidx >= 0 && |
||
1065 | yymx != YYERRORSYMBOL && |
||
1066 | (yyact = yy_find_reduce_action( |
||
1067 | yypParser->yystack[yypParser->yyidx].stateno, |
||
1068 | YYERRORSYMBOL)) >= YYNSTATE |
||
1069 | ){ |
||
1070 | yy_pop_parser_stack(yypParser); |
||
1071 | } |
||
1072 | if( yypParser->yyidx < 0 || yymajor==0 ){ |
||
1073 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
||
1074 | yy_parse_failed(yypParser); |
||
1075 | yymajor = YYNOCODE; |
||
1076 | }else if( yymx!=YYERRORSYMBOL ){ |
||
1077 | YYMINORTYPE u2; |
||
1078 | u2.YYERRSYMDT = 0; |
||
1079 | yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); |
||
1080 | } |
||
1081 | } |
||
1082 | yypParser->yyerrcnt = 3; |
||
1083 | yyerrorhit = 1; |
||
1084 | #elif defined(YYNOERRORRECOVERY) |
||
1085 | /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to |
||
1086 | ** do any kind of error recovery. Instead, simply invoke the syntax |
||
1087 | ** error routine and continue going as if nothing had happened. |
||
1088 | ** |
||
1089 | ** Applications can set this macro (for example inside %include) if |
||
1090 | ** they intend to abandon the parse upon the first syntax error seen. |
||
1091 | */ |
||
1092 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
||
1093 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
||
1094 | yymajor = YYNOCODE; |
||
1095 | |||
1096 | #else /* YYERRORSYMBOL is not defined */ |
||
1097 | /* This is what we do if the grammar does not define ERROR: |
||
1098 | ** |
||
1099 | ** * Report an error message, and throw away the input token. |
||
1100 | ** |
||
1101 | ** * If the input token is $, then fail the parse. |
||
1102 | ** |
||
1103 | ** As before, subsequent error messages are suppressed until |
||
1104 | ** three input tokens have been successfully shifted. |
||
1105 | */ |
||
1106 | if( yypParser->yyerrcnt<=0 ){ |
||
1107 | yy_syntax_error(yypParser,yymajor,yyminorunion); |
||
1108 | } |
||
1109 | yypParser->yyerrcnt = 3; |
||
1110 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
||
1111 | if( yyendofinput ){ |
||
1112 | yy_parse_failed(yypParser); |
||
1113 | } |
||
1114 | yymajor = YYNOCODE; |
||
1115 | #endif |
||
1116 | } |
||
1117 | }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
||
1118 | return; |
||
1119 | } |