]>
Commit | Line | Data |
---|---|---|
1 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ | |
2 | #line 3 "bison.simple" | |
3 | /* This file comes from bison-@bison_version@. */ | |
4 | ||
5 | /* Skeleton output parser for bison, | |
6 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
22 | ||
23 | /* As a special exception, when this file is copied by Bison into a | |
24 | Bison output file, you may use that output file without restriction. | |
25 | This special exception was added by the Free Software Foundation | |
26 | in version 1.24 of Bison. */ | |
27 | ||
28 | /* This is the parser code that is written into each bison parser | |
29 | when the %semantic_parser declaration is not specified in the grammar. | |
30 | It was written by Richard Stallman by simplifying the hairy parser | |
31 | used when %semantic_parser is specified. */ | |
32 | ||
33 | #ifndef YYSTACK_USE_ALLOCA | |
34 | #ifdef alloca | |
35 | #define YYSTACK_USE_ALLOCA | |
36 | #else /* alloca not defined */ | |
37 | #ifdef __GNUC__ | |
38 | #define YYSTACK_USE_ALLOCA | |
39 | #define alloca __builtin_alloca | |
40 | #else /* not GNU C. */ | |
41 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) | |
42 | #define YYSTACK_USE_ALLOCA | |
43 | #include <alloca.h> | |
44 | #else /* not sparc */ | |
45 | /* We think this test detects Watcom and Microsoft C. */ | |
46 | /* This used to test MSDOS, but that is a bad idea | |
47 | since that symbol is in the user namespace. */ | |
48 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) | |
49 | #if 0 /* No need for malloc.h, which pollutes the namespace; | |
50 | instead, just don't use alloca. */ | |
51 | #include <malloc.h> | |
52 | #endif | |
53 | #else /* not MSDOS, or __TURBOC__ */ | |
54 | #if defined(_AIX) | |
55 | /* I don't know what this was needed for, but it pollutes the namespace. | |
56 | So I turned it off. rms, 2 May 1997. */ | |
57 | /* #include <malloc.h> */ | |
58 | #pragma alloca | |
59 | #define YYSTACK_USE_ALLOCA | |
60 | #else /* not MSDOS, or __TURBOC__, or _AIX */ | |
61 | #if 0 | |
62 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, | |
63 | and on HPUX 10. Eventually we can turn this on. */ | |
64 | #define YYSTACK_USE_ALLOCA | |
65 | #define alloca __builtin_alloca | |
66 | #endif /* __hpux */ | |
67 | #endif | |
68 | #endif /* not _AIX */ | |
69 | #endif /* not MSDOS, or __TURBOC__ */ | |
70 | #endif /* not sparc */ | |
71 | #endif /* not GNU C */ | |
72 | #endif /* alloca not defined */ | |
73 | #endif /* YYSTACK_USE_ALLOCA not defined */ | |
74 | ||
75 | #ifdef YYSTACK_USE_ALLOCA | |
76 | #define YYSTACK_ALLOC alloca | |
77 | #else | |
78 | #define YYSTACK_ALLOC malloc | |
79 | #endif | |
80 | ||
81 | /* Note: there must be only one dollar sign in this file. | |
82 | It is replaced by the list of actions, each action | |
83 | as one case of the switch. */ | |
84 | ||
85 | #define yyerrok (yyerrstatus = 0) | |
86 | #define yyclearin (yychar = YYEMPTY) | |
87 | #define YYEMPTY -2 | |
88 | #define YYEOF 0 | |
89 | #define YYACCEPT goto yyacceptlab | |
90 | #define YYABORT goto yyabortlab | |
91 | #define YYERROR goto yyerrlab1 | |
92 | /* Like YYERROR except do call yyerror. | |
93 | This remains here temporarily to ease the | |
94 | transition to the new meaning of YYERROR, for GCC. | |
95 | Once GCC version 2 has supplanted version 1, this can go. */ | |
96 | #define YYFAIL goto yyerrlab | |
97 | #define YYRECOVERING() (!!yyerrstatus) | |
98 | #define YYBACKUP(token, value) \ | |
99 | do \ | |
100 | if (yychar == YYEMPTY && yylen == 1) \ | |
101 | { yychar = (token), yylval = (value); \ | |
102 | yychar1 = YYTRANSLATE (yychar); \ | |
103 | YYPOPSTACK; \ | |
104 | goto yybackup; \ | |
105 | } \ | |
106 | else \ | |
107 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ | |
108 | while (0) | |
109 | ||
110 | #define YYTERROR 1 | |
111 | #define YYERRCODE 256 | |
112 | ||
113 | #ifndef YYPURE | |
114 | #define YYLEX yylex() | |
115 | #endif | |
116 | ||
117 | #ifdef YYPURE | |
118 | #ifdef YYLSP_NEEDED | |
119 | #ifdef YYLEX_PARAM | |
120 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) | |
121 | #else | |
122 | #define YYLEX yylex(&yylval, &yylloc) | |
123 | #endif | |
124 | #else /* not YYLSP_NEEDED */ | |
125 | #ifdef YYLEX_PARAM | |
126 | #define YYLEX yylex(&yylval, YYLEX_PARAM) | |
127 | #else | |
128 | #define YYLEX yylex(&yylval) | |
129 | #endif | |
130 | #endif /* not YYLSP_NEEDED */ | |
131 | #endif | |
132 | ||
133 | /* If nonreentrant, generate the variables here */ | |
134 | ||
135 | #ifndef YYPURE | |
136 | ||
137 | int yychar; /* the lookahead symbol */ | |
138 | YYSTYPE yylval; /* the semantic value of the */ | |
139 | /* lookahead symbol */ | |
140 | ||
141 | #ifdef YYLSP_NEEDED | |
142 | YYLTYPE yylloc; /* location data for the lookahead */ | |
143 | /* symbol */ | |
144 | #endif | |
145 | ||
146 | int yynerrs; /* number of parse errors so far */ | |
147 | #endif /* not YYPURE */ | |
148 | ||
149 | #if YYDEBUG != 0 | |
150 | int yydebug; /* nonzero means print parse trace */ | |
151 | /* Since this is uninitialized, it does not stop multiple parsers | |
152 | from coexisting. */ | |
153 | #endif | |
154 | ||
155 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ | |
156 | ||
157 | #ifndef YYINITDEPTH | |
158 | #define YYINITDEPTH 200 | |
159 | #endif | |
160 | ||
161 | /* YYMAXDEPTH is the maximum size the stacks can grow to | |
162 | (effective only if the built-in stack extension method is used). */ | |
163 | ||
164 | #if YYMAXDEPTH == 0 | |
165 | #undef YYMAXDEPTH | |
166 | #endif | |
167 | ||
168 | #ifndef YYMAXDEPTH | |
169 | #define YYMAXDEPTH 10000 | |
170 | #endif | |
171 | \f | |
172 | /* Define __yy_memcpy. Note that the size argument | |
173 | should be passed with type unsigned int, because that is what the non-GCC | |
174 | definitions require. With GCC, __builtin_memcpy takes an arg | |
175 | of type size_t, but it can handle unsigned int. */ | |
176 | ||
177 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ | |
178 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) | |
179 | #else /* not GNU C or C++ */ | |
180 | #ifndef __cplusplus | |
181 | ||
182 | /* This is the most reliable way to avoid incompatibilities | |
183 | in available built-in functions on various systems. */ | |
184 | static void | |
185 | __yy_memcpy (to, from, count) | |
186 | char *to; | |
187 | char *from; | |
188 | unsigned int count; | |
189 | { | |
190 | register char *f = from; | |
191 | register char *t = to; | |
192 | register int i = count; | |
193 | ||
194 | while (i-- > 0) | |
195 | *t++ = *f++; | |
196 | } | |
197 | ||
198 | #else /* __cplusplus */ | |
199 | ||
200 | /* This is the most reliable way to avoid incompatibilities | |
201 | in available built-in functions on various systems. */ | |
202 | static void | |
203 | __yy_memcpy (char *to, char *from, unsigned int count) | |
204 | { | |
205 | register char *t = to; | |
206 | register char *f = from; | |
207 | register int i = count; | |
208 | ||
209 | while (i-- > 0) | |
210 | *t++ = *f++; | |
211 | } | |
212 | ||
213 | #endif | |
214 | #endif | |
215 | \f | |
216 | #line 217 "bison.simple" | |
217 | ||
218 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | |
219 | into yyparse. The argument should have type void *. | |
220 | It should actually point to an object. | |
221 | Grammar actions can access the variable by casting it | |
222 | to the proper pointer type. */ | |
223 | ||
224 | #ifdef YYPARSE_PARAM | |
225 | #ifdef __cplusplus | |
226 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | |
227 | #define YYPARSE_PARAM_DECL | |
228 | #else /* not __cplusplus */ | |
229 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM | |
230 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | |
231 | #endif /* not __cplusplus */ | |
232 | #else /* not YYPARSE_PARAM */ | |
233 | #define YYPARSE_PARAM_ARG | |
234 | #define YYPARSE_PARAM_DECL | |
235 | #endif /* not YYPARSE_PARAM */ | |
236 | ||
237 | /* Prevent warning if -Wstrict-prototypes. */ | |
238 | #ifdef __GNUC__ | |
239 | #ifdef YYPARSE_PARAM | |
240 | int yyparse (void *); | |
241 | #else | |
242 | int yyparse (void); | |
243 | #endif | |
244 | #endif | |
245 | ||
246 | int | |
247 | yyparse(YYPARSE_PARAM_ARG) | |
248 | YYPARSE_PARAM_DECL | |
249 | { | |
250 | register int yystate; | |
251 | register int yyn; | |
252 | register short *yyssp; | |
253 | register YYSTYPE *yyvsp; | |
254 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ | |
255 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ | |
256 | ||
257 | short yyssa[YYINITDEPTH]; /* the state stack */ | |
258 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | |
259 | ||
260 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | |
261 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ | |
262 | ||
263 | #ifdef YYLSP_NEEDED | |
264 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | |
265 | YYLTYPE *yyls = yylsa; | |
266 | YYLTYPE *yylsp; | |
267 | ||
268 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
269 | #else | |
270 | #define YYPOPSTACK (yyvsp--, yyssp--) | |
271 | #endif | |
272 | ||
273 | int yystacksize = YYINITDEPTH; | |
274 | int yyfree_stacks = 0; | |
275 | ||
276 | #ifdef YYPURE | |
277 | int yychar; | |
278 | YYSTYPE yylval; | |
279 | int yynerrs; | |
280 | #ifdef YYLSP_NEEDED | |
281 | YYLTYPE yylloc; | |
282 | #endif | |
283 | #endif | |
284 | ||
285 | YYSTYPE yyval; /* the variable used to return */ | |
286 | /* semantic values from the action */ | |
287 | /* routines */ | |
288 | ||
289 | int yylen; | |
290 | ||
291 | #if YYDEBUG != 0 | |
292 | if (yydebug) | |
293 | fprintf(stderr, "Starting parse\n"); | |
294 | #endif | |
295 | ||
296 | yystate = 0; | |
297 | yyerrstatus = 0; | |
298 | yynerrs = 0; | |
299 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
300 | ||
301 | /* Initialize stack pointers. | |
302 | Waste one element of value and location stack | |
303 | so that they stay on the same level as the state stack. | |
304 | The wasted elements are never initialized. */ | |
305 | ||
306 | yyssp = yyss - 1; | |
307 | yyvsp = yyvs; | |
308 | #ifdef YYLSP_NEEDED | |
309 | yylsp = yyls; | |
310 | #endif | |
311 | ||
312 | /* Push a new state, which is found in yystate . */ | |
313 | /* In all cases, when you get here, the value and location stacks | |
314 | have just been pushed. so pushing a state here evens the stacks. */ | |
315 | yynewstate: | |
316 | ||
317 | *++yyssp = yystate; | |
318 | ||
319 | if (yyssp >= yyss + yystacksize - 1) | |
320 | { | |
321 | /* Give user a chance to reallocate the stack */ | |
322 | /* Use copies of these so that the &'s don't force the real ones into memory. */ | |
323 | YYSTYPE *yyvs1 = yyvs; | |
324 | short *yyss1 = yyss; | |
325 | #ifdef YYLSP_NEEDED | |
326 | YYLTYPE *yyls1 = yyls; | |
327 | #endif | |
328 | ||
329 | /* Get the current used size of the three stacks, in elements. */ | |
330 | int size = yyssp - yyss + 1; | |
331 | ||
332 | #ifdef yyoverflow | |
333 | /* Each stack pointer address is followed by the size of | |
334 | the data in use in that stack, in bytes. */ | |
335 | #ifdef YYLSP_NEEDED | |
336 | /* This used to be a conditional around just the two extra args, | |
337 | but that might be undefined if yyoverflow is a macro. */ | |
338 | yyoverflow("parser stack overflow", | |
339 | &yyss1, size * sizeof (*yyssp), | |
340 | &yyvs1, size * sizeof (*yyvsp), | |
341 | &yyls1, size * sizeof (*yylsp), | |
342 | &yystacksize); | |
343 | #else | |
344 | yyoverflow("parser stack overflow", | |
345 | &yyss1, size * sizeof (*yyssp), | |
346 | &yyvs1, size * sizeof (*yyvsp), | |
347 | &yystacksize); | |
348 | #endif | |
349 | ||
350 | yyss = yyss1; yyvs = yyvs1; | |
351 | #ifdef YYLSP_NEEDED | |
352 | yyls = yyls1; | |
353 | #endif | |
354 | #else /* no yyoverflow */ | |
355 | /* Extend the stack our own way. */ | |
356 | if (yystacksize >= YYMAXDEPTH) | |
357 | { | |
358 | yyerror("parser stack overflow"); | |
359 | if (yyfree_stacks) | |
360 | { | |
361 | free (yyss); | |
362 | free (yyvs); | |
363 | #ifdef YYLSP_NEEDED | |
364 | free (yyls); | |
365 | #endif | |
366 | } | |
367 | return 2; | |
368 | } | |
369 | yystacksize *= 2; | |
370 | if (yystacksize > YYMAXDEPTH) | |
371 | yystacksize = YYMAXDEPTH; | |
372 | #ifndef YYSTACK_USE_ALLOCA | |
373 | yyfree_stacks = 1; | |
374 | #endif | |
375 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); | |
376 | __yy_memcpy ((char *)yyss, (char *)yyss1, | |
377 | size * (unsigned int) sizeof (*yyssp)); | |
378 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); | |
379 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, | |
380 | size * (unsigned int) sizeof (*yyvsp)); | |
381 | #ifdef YYLSP_NEEDED | |
382 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); | |
383 | __yy_memcpy ((char *)yyls, (char *)yyls1, | |
384 | size * (unsigned int) sizeof (*yylsp)); | |
385 | #endif | |
386 | #endif /* no yyoverflow */ | |
387 | ||
388 | yyssp = yyss + size - 1; | |
389 | yyvsp = yyvs + size - 1; | |
390 | #ifdef YYLSP_NEEDED | |
391 | yylsp = yyls + size - 1; | |
392 | #endif | |
393 | ||
394 | #if YYDEBUG != 0 | |
395 | if (yydebug) | |
396 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); | |
397 | #endif | |
398 | ||
399 | if (yyssp >= yyss + yystacksize - 1) | |
400 | YYABORT; | |
401 | } | |
402 | ||
403 | #if YYDEBUG != 0 | |
404 | if (yydebug) | |
405 | fprintf(stderr, "Entering state %d\n", yystate); | |
406 | #endif | |
407 | ||
408 | goto yybackup; | |
409 | yybackup: | |
410 | ||
411 | /* Do appropriate processing given the current state. */ | |
412 | /* Read a lookahead token if we need one and don't already have one. */ | |
413 | /* yyresume: */ | |
414 | ||
415 | /* First try to decide what to do without reference to lookahead token. */ | |
416 | ||
417 | yyn = yypact[yystate]; | |
418 | if (yyn == YYFLAG) | |
419 | goto yydefault; | |
420 | ||
421 | /* Not known => get a lookahead token if don't already have one. */ | |
422 | ||
423 | /* yychar is either YYEMPTY or YYEOF | |
424 | or a valid token in external form. */ | |
425 | ||
426 | if (yychar == YYEMPTY) | |
427 | { | |
428 | #if YYDEBUG != 0 | |
429 | if (yydebug) | |
430 | fprintf(stderr, "Reading a token: "); | |
431 | #endif | |
432 | yychar = YYLEX; | |
433 | } | |
434 | ||
435 | /* Convert token to internal form (in yychar1) for indexing tables with */ | |
436 | ||
437 | if (yychar <= 0) /* This means end of input. */ | |
438 | { | |
439 | yychar1 = 0; | |
440 | yychar = YYEOF; /* Don't call YYLEX any more */ | |
441 | ||
442 | #if YYDEBUG != 0 | |
443 | if (yydebug) | |
444 | fprintf(stderr, "Now at end of input.\n"); | |
445 | #endif | |
446 | } | |
447 | else | |
448 | { | |
449 | yychar1 = YYTRANSLATE(yychar); | |
450 | ||
451 | #if YYDEBUG != 0 | |
452 | if (yydebug) | |
453 | { | |
454 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | |
455 | /* Give the individual parser a way to print the precise meaning | |
456 | of a token, for further debugging info. */ | |
457 | #ifdef YYPRINT | |
458 | YYPRINT (stderr, yychar, yylval); | |
459 | #endif | |
460 | fprintf (stderr, ")\n"); | |
461 | } | |
462 | #endif | |
463 | } | |
464 | ||
465 | yyn += yychar1; | |
466 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
467 | goto yydefault; | |
468 | ||
469 | yyn = yytable[yyn]; | |
470 | ||
471 | /* yyn is what to do for this token type in this state. | |
472 | Negative => reduce, -yyn is rule number. | |
473 | Positive => shift, yyn is new state. | |
474 | New state is final state => don't bother to shift, | |
475 | just return success. | |
476 | 0, or most negative number => error. */ | |
477 | ||
478 | if (yyn < 0) | |
479 | { | |
480 | if (yyn == YYFLAG) | |
481 | goto yyerrlab; | |
482 | yyn = -yyn; | |
483 | goto yyreduce; | |
484 | } | |
485 | else if (yyn == 0) | |
486 | goto yyerrlab; | |
487 | ||
488 | if (yyn == YYFINAL) | |
489 | YYACCEPT; | |
490 | ||
491 | /* Shift the lookahead token. */ | |
492 | ||
493 | #if YYDEBUG != 0 | |
494 | if (yydebug) | |
495 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | |
496 | #endif | |
497 | ||
498 | /* Discard the token being shifted unless it is eof. */ | |
499 | if (yychar != YYEOF) | |
500 | yychar = YYEMPTY; | |
501 | ||
502 | *++yyvsp = yylval; | |
503 | #ifdef YYLSP_NEEDED | |
504 | *++yylsp = yylloc; | |
505 | #endif | |
506 | ||
507 | /* count tokens shifted since error; after three, turn off error status. */ | |
508 | if (yyerrstatus) yyerrstatus--; | |
509 | ||
510 | yystate = yyn; | |
511 | goto yynewstate; | |
512 | ||
513 | /* Do the default action for the current state. */ | |
514 | yydefault: | |
515 | ||
516 | yyn = yydefact[yystate]; | |
517 | if (yyn == 0) | |
518 | goto yyerrlab; | |
519 | ||
520 | /* Do a reduction. yyn is the number of a rule to reduce with. */ | |
521 | yyreduce: | |
522 | yylen = yyr2[yyn]; | |
523 | if (yylen > 0) | |
524 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ | |
525 | ||
526 | #if YYDEBUG != 0 | |
527 | if (yydebug) | |
528 | { | |
529 | int i; | |
530 | ||
531 | fprintf (stderr, "Reducing via rule %d (line %d), ", | |
532 | yyn, yyrline[yyn]); | |
533 | ||
534 | /* Print the symbols being reduced, and their result. */ | |
535 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | |
536 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); | |
537 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
538 | } | |
539 | #endif | |
540 | ||
541 | $ /* the action file gets copied in in place of this dollarsign */ | |
542 | #line 543 "bison.simple" | |
543 | \f | |
544 | yyvsp -= yylen; | |
545 | yyssp -= yylen; | |
546 | #ifdef YYLSP_NEEDED | |
547 | yylsp -= yylen; | |
548 | #endif | |
549 | ||
550 | #if YYDEBUG != 0 | |
551 | if (yydebug) | |
552 | { | |
553 | short *ssp1 = yyss - 1; | |
554 | fprintf (stderr, "state stack now"); | |
555 | while (ssp1 != yyssp) | |
556 | fprintf (stderr, " %d", *++ssp1); | |
557 | fprintf (stderr, "\n"); | |
558 | } | |
559 | #endif | |
560 | ||
561 | *++yyvsp = yyval; | |
562 | ||
563 | #ifdef YYLSP_NEEDED | |
564 | yylsp++; | |
565 | if (yylen == 0) | |
566 | { | |
567 | yylsp->first_line = yylloc.first_line; | |
568 | yylsp->first_column = yylloc.first_column; | |
569 | yylsp->last_line = (yylsp-1)->last_line; | |
570 | yylsp->last_column = (yylsp-1)->last_column; | |
571 | yylsp->text = 0; | |
572 | } | |
573 | else | |
574 | { | |
575 | yylsp->last_line = (yylsp+yylen-1)->last_line; | |
576 | yylsp->last_column = (yylsp+yylen-1)->last_column; | |
577 | } | |
578 | #endif | |
579 | ||
580 | /* Now "shift" the result of the reduction. | |
581 | Determine what state that goes to, | |
582 | based on the state we popped back to | |
583 | and the rule number reduced by. */ | |
584 | ||
585 | yyn = yyr1[yyn]; | |
586 | ||
587 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
588 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
589 | yystate = yytable[yystate]; | |
590 | else | |
591 | yystate = yydefgoto[yyn - YYNTBASE]; | |
592 | ||
593 | goto yynewstate; | |
594 | ||
595 | yyerrlab: /* here on detecting error */ | |
596 | ||
597 | if (! yyerrstatus) | |
598 | /* If not already recovering from an error, report this error. */ | |
599 | { | |
600 | ++yynerrs; | |
601 | ||
602 | #ifdef YYERROR_VERBOSE | |
603 | yyn = yypact[yystate]; | |
604 | ||
605 | if (yyn > YYFLAG && yyn < YYLAST) | |
606 | { | |
607 | int size = 0; | |
608 | char *msg; | |
609 | int x, count; | |
610 | ||
611 | count = 0; | |
612 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | |
613 | for (x = (yyn < 0 ? -yyn : 0); | |
614 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
615 | if (yycheck[x + yyn] == x) | |
616 | size += strlen(yytname[x]) + 15, count++; | |
617 | msg = (char *) malloc(size + 15); | |
618 | if (msg != 0) | |
619 | { | |
620 | strcpy(msg, "parse error"); | |
621 | ||
622 | if (count < 5) | |
623 | { | |
624 | count = 0; | |
625 | for (x = (yyn < 0 ? -yyn : 0); | |
626 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
627 | if (yycheck[x + yyn] == x) | |
628 | { | |
629 | strcat(msg, count == 0 ? ", expecting `" : " or `"); | |
630 | strcat(msg, yytname[x]); | |
631 | strcat(msg, "'"); | |
632 | count++; | |
633 | } | |
634 | } | |
635 | yyerror(msg); | |
636 | free(msg); | |
637 | } | |
638 | else | |
639 | yyerror ("parse error; also virtual memory exceeded"); | |
640 | } | |
641 | else | |
642 | #endif /* YYERROR_VERBOSE */ | |
643 | yyerror("parse error"); | |
644 | } | |
645 | ||
646 | goto yyerrlab1; | |
647 | yyerrlab1: /* here on error raised explicitly by an action */ | |
648 | ||
649 | if (yyerrstatus == 3) | |
650 | { | |
651 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ | |
652 | ||
653 | /* return failure if at end of input */ | |
654 | if (yychar == YYEOF) | |
655 | YYABORT; | |
656 | ||
657 | #if YYDEBUG != 0 | |
658 | if (yydebug) | |
659 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | |
660 | #endif | |
661 | ||
662 | yychar = YYEMPTY; | |
663 | } | |
664 | ||
665 | /* Else will try to reuse lookahead token | |
666 | after shifting the error token. */ | |
667 | ||
668 | yyerrstatus = 3; /* Each real token shifted decrements this */ | |
669 | ||
670 | goto yyerrhandle; | |
671 | ||
672 | yyerrdefault: /* current state does not do anything special for the error token. */ | |
673 | ||
674 | #if 0 | |
675 | /* This is wrong; only states that explicitly want error tokens | |
676 | should shift them. */ | |
677 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | |
678 | if (yyn) goto yydefault; | |
679 | #endif | |
680 | ||
681 | yyerrpop: /* pop the current state because it cannot handle the error token */ | |
682 | ||
683 | if (yyssp == yyss) YYABORT; | |
684 | yyvsp--; | |
685 | yystate = *--yyssp; | |
686 | #ifdef YYLSP_NEEDED | |
687 | yylsp--; | |
688 | #endif | |
689 | ||
690 | #if YYDEBUG != 0 | |
691 | if (yydebug) | |
692 | { | |
693 | short *ssp1 = yyss - 1; | |
694 | fprintf (stderr, "Error: state stack now"); | |
695 | while (ssp1 != yyssp) | |
696 | fprintf (stderr, " %d", *++ssp1); | |
697 | fprintf (stderr, "\n"); | |
698 | } | |
699 | #endif | |
700 | ||
701 | yyerrhandle: | |
702 | ||
703 | yyn = yypact[yystate]; | |
704 | if (yyn == YYFLAG) | |
705 | goto yyerrdefault; | |
706 | ||
707 | yyn += YYTERROR; | |
708 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
709 | goto yyerrdefault; | |
710 | ||
711 | yyn = yytable[yyn]; | |
712 | if (yyn < 0) | |
713 | { | |
714 | if (yyn == YYFLAG) | |
715 | goto yyerrpop; | |
716 | yyn = -yyn; | |
717 | goto yyreduce; | |
718 | } | |
719 | else if (yyn == 0) | |
720 | goto yyerrpop; | |
721 | ||
722 | if (yyn == YYFINAL) | |
723 | YYACCEPT; | |
724 | ||
725 | #if YYDEBUG != 0 | |
726 | if (yydebug) | |
727 | fprintf(stderr, "Shifting error token, "); | |
728 | #endif | |
729 | ||
730 | *++yyvsp = yylval; | |
731 | #ifdef YYLSP_NEEDED | |
732 | *++yylsp = yylloc; | |
733 | #endif | |
734 | ||
735 | yystate = yyn; | |
736 | goto yynewstate; | |
737 | ||
738 | yyacceptlab: | |
739 | /* YYACCEPT comes here. */ | |
740 | if (yyfree_stacks) | |
741 | { | |
742 | free (yyss); | |
743 | free (yyvs); | |
744 | #ifdef YYLSP_NEEDED | |
745 | free (yyls); | |
746 | #endif | |
747 | } | |
748 | return 0; | |
749 | ||
750 | yyabortlab: | |
751 | /* YYABORT comes here. */ | |
752 | if (yyfree_stacks) | |
753 | { | |
754 | free (yyss); | |
755 | free (yyvs); | |
756 | #ifdef YYLSP_NEEDED | |
757 | free (yyls); | |
758 | #endif | |
759 | } | |
760 | return 1; | |
761 | } |