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