]>
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 RS |
25 | |
26 | #ifndef alloca | |
27 | #ifdef __GNUC__ | |
28 | #define alloca __builtin_alloca | |
29 | #else /* not GNU C. */ | |
30 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) | |
31 | #include <alloca.h> | |
32 | #else /* not sparc */ | |
db245ba8 RS |
33 | /* This used to test MSDOS, but that is a bad idea |
34 | since that is in the user namespace. */ | |
35 | #if defined (_MSDOS_) && !defined (__TURBOC__) | |
10fa2066 | 36 | #include <malloc.h> |
db245ba8 | 37 | #else /* not _MSDOS_, or __TURBOC__ */ |
10fa2066 RS |
38 | #if defined(_AIX) |
39 | #include <malloc.h> | |
40 | #pragma alloca | |
41 | #else /* not MSDOS, __TURBOC__, or _AIX */ | |
42 | #ifdef __hpux | |
43 | #ifdef __cplusplus | |
44 | extern "C" { | |
45 | void *alloca (unsigned int); | |
46 | }; | |
47 | #else /* not __cplusplus */ | |
48 | void *alloca (); | |
49 | #endif /* not __cplusplus */ | |
50 | #endif /* __hpux */ | |
51 | #endif /* not _AIX */ | |
db245ba8 | 52 | #endif /* not _MSDOS_, or __TURBOC__ */ |
10fa2066 RS |
53 | #endif /* not sparc. */ |
54 | #endif /* not GNU C. */ | |
55 | #endif /* alloca not defined. */ | |
56 | ||
57 | /* This is the parser code that is written into each bison parser | |
58 | when the %semantic_parser declaration is not specified in the grammar. | |
59 | It was written by Richard Stallman by simplifying the hairy parser | |
60 | used when %semantic_parser is specified. */ | |
61 | ||
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 | |
152 | ||
153 | /* Prevent warning if -Wstrict-prototypes. */ | |
154 | #ifdef __GNUC__ | |
155 | int yyparse (void); | |
156 | #endif | |
157 | \f | |
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; |
10fa2066 RS |
169 | int count; |
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 | |
c245d0d3 | 184 | __yy_memcpy (char *to, char *from, 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 | |
10fa2066 | 218 | int |
30f5b1cc | 219 | yyparse(YYPARSE_PARAM_ARG) |
b658bf92 | 220 | YYPARSE_PARAM_DECL |
10fa2066 RS |
221 | { |
222 | register int yystate; | |
223 | register int yyn; | |
224 | register short *yyssp; | |
225 | register YYSTYPE *yyvsp; | |
226 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ | |
c6c88451 | 227 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
10fa2066 RS |
228 | |
229 | short yyssa[YYINITDEPTH]; /* the state stack */ | |
230 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | |
231 | ||
232 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | |
233 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ | |
234 | ||
235 | #ifdef YYLSP_NEEDED | |
236 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | |
237 | YYLTYPE *yyls = yylsa; | |
238 | YYLTYPE *yylsp; | |
239 | ||
240 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
241 | #else | |
242 | #define YYPOPSTACK (yyvsp--, yyssp--) | |
243 | #endif | |
244 | ||
245 | int yystacksize = YYINITDEPTH; | |
246 | ||
247 | #ifdef YYPURE | |
248 | int yychar; | |
249 | YYSTYPE yylval; | |
250 | int yynerrs; | |
251 | #ifdef YYLSP_NEEDED | |
252 | YYLTYPE yylloc; | |
253 | #endif | |
254 | #endif | |
255 | ||
256 | YYSTYPE yyval; /* the variable used to return */ | |
257 | /* semantic values from the action */ | |
258 | /* routines */ | |
259 | ||
260 | int yylen; | |
261 | ||
262 | #if YYDEBUG != 0 | |
263 | if (yydebug) | |
264 | fprintf(stderr, "Starting parse\n"); | |
265 | #endif | |
266 | ||
267 | yystate = 0; | |
268 | yyerrstatus = 0; | |
269 | yynerrs = 0; | |
270 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
271 | ||
272 | /* Initialize stack pointers. | |
273 | Waste one element of value and location stack | |
274 | so that they stay on the same level as the state stack. | |
275 | The wasted elements are never initialized. */ | |
276 | ||
277 | yyssp = yyss - 1; | |
278 | yyvsp = yyvs; | |
279 | #ifdef YYLSP_NEEDED | |
280 | yylsp = yyls; | |
281 | #endif | |
282 | ||
283 | /* Push a new state, which is found in yystate . */ | |
284 | /* In all cases, when you get here, the value and location stacks | |
285 | have just been pushed. so pushing a state here evens the stacks. */ | |
286 | yynewstate: | |
287 | ||
288 | *++yyssp = yystate; | |
289 | ||
290 | if (yyssp >= yyss + yystacksize - 1) | |
291 | { | |
292 | /* Give user a chance to reallocate the stack */ | |
293 | /* Use copies of these so that the &'s don't force the real ones into memory. */ | |
294 | YYSTYPE *yyvs1 = yyvs; | |
295 | short *yyss1 = yyss; | |
296 | #ifdef YYLSP_NEEDED | |
297 | YYLTYPE *yyls1 = yyls; | |
298 | #endif | |
299 | ||
300 | /* Get the current used size of the three stacks, in elements. */ | |
301 | int size = yyssp - yyss + 1; | |
302 | ||
303 | #ifdef yyoverflow | |
304 | /* Each stack pointer address is followed by the size of | |
305 | the data in use in that stack, in bytes. */ | |
be4bf877 RS |
306 | #ifdef YYLSP_NEEDED |
307 | /* This used to be a conditional around just the two extra args, | |
308 | but that might be undefined if yyoverflow is a macro. */ | |
10fa2066 RS |
309 | yyoverflow("parser stack overflow", |
310 | &yyss1, size * sizeof (*yyssp), | |
311 | &yyvs1, size * sizeof (*yyvsp), | |
10fa2066 | 312 | &yyls1, size * sizeof (*yylsp), |
10fa2066 | 313 | &yystacksize); |
be4bf877 RS |
314 | #else |
315 | yyoverflow("parser stack overflow", | |
316 | &yyss1, size * sizeof (*yyssp), | |
317 | &yyvs1, size * sizeof (*yyvsp), | |
318 | &yystacksize); | |
319 | #endif | |
10fa2066 RS |
320 | |
321 | yyss = yyss1; yyvs = yyvs1; | |
322 | #ifdef YYLSP_NEEDED | |
323 | yyls = yyls1; | |
324 | #endif | |
325 | #else /* no yyoverflow */ | |
326 | /* Extend the stack our own way. */ | |
327 | if (yystacksize >= YYMAXDEPTH) | |
328 | { | |
329 | yyerror("parser stack overflow"); | |
330 | return 2; | |
331 | } | |
332 | yystacksize *= 2; | |
333 | if (yystacksize > YYMAXDEPTH) | |
334 | yystacksize = YYMAXDEPTH; | |
335 | yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); | |
c245d0d3 | 336 | __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); |
10fa2066 | 337 | yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); |
c245d0d3 | 338 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); |
10fa2066 RS |
339 | #ifdef YYLSP_NEEDED |
340 | yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); | |
c245d0d3 | 341 | __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); |
10fa2066 RS |
342 | #endif |
343 | #endif /* no yyoverflow */ | |
344 | ||
345 | yyssp = yyss + size - 1; | |
346 | yyvsp = yyvs + size - 1; | |
347 | #ifdef YYLSP_NEEDED | |
348 | yylsp = yyls + size - 1; | |
349 | #endif | |
350 | ||
351 | #if YYDEBUG != 0 | |
352 | if (yydebug) | |
353 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); | |
354 | #endif | |
355 | ||
356 | if (yyssp >= yyss + yystacksize - 1) | |
357 | YYABORT; | |
358 | } | |
359 | ||
360 | #if YYDEBUG != 0 | |
361 | if (yydebug) | |
362 | fprintf(stderr, "Entering state %d\n", yystate); | |
363 | #endif | |
364 | ||
365 | goto yybackup; | |
366 | yybackup: | |
367 | ||
368 | /* Do appropriate processing given the current state. */ | |
369 | /* Read a lookahead token if we need one and don't already have one. */ | |
370 | /* yyresume: */ | |
371 | ||
372 | /* First try to decide what to do without reference to lookahead token. */ | |
373 | ||
374 | yyn = yypact[yystate]; | |
375 | if (yyn == YYFLAG) | |
376 | goto yydefault; | |
377 | ||
378 | /* Not known => get a lookahead token if don't already have one. */ | |
379 | ||
380 | /* yychar is either YYEMPTY or YYEOF | |
381 | or a valid token in external form. */ | |
382 | ||
383 | if (yychar == YYEMPTY) | |
384 | { | |
385 | #if YYDEBUG != 0 | |
386 | if (yydebug) | |
387 | fprintf(stderr, "Reading a token: "); | |
388 | #endif | |
389 | yychar = YYLEX; | |
390 | } | |
391 | ||
392 | /* Convert token to internal form (in yychar1) for indexing tables with */ | |
393 | ||
394 | if (yychar <= 0) /* This means end of input. */ | |
395 | { | |
396 | yychar1 = 0; | |
397 | yychar = YYEOF; /* Don't call YYLEX any more */ | |
398 | ||
399 | #if YYDEBUG != 0 | |
400 | if (yydebug) | |
401 | fprintf(stderr, "Now at end of input.\n"); | |
402 | #endif | |
403 | } | |
404 | else | |
405 | { | |
406 | yychar1 = YYTRANSLATE(yychar); | |
407 | ||
408 | #if YYDEBUG != 0 | |
409 | if (yydebug) | |
410 | { | |
411 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | |
412 | /* Give the individual parser a way to print the precise meaning | |
413 | of a token, for further debugging info. */ | |
414 | #ifdef YYPRINT | |
415 | YYPRINT (stderr, yychar, yylval); | |
416 | #endif | |
417 | fprintf (stderr, ")\n"); | |
418 | } | |
419 | #endif | |
420 | } | |
421 | ||
422 | yyn += yychar1; | |
423 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
424 | goto yydefault; | |
425 | ||
426 | yyn = yytable[yyn]; | |
427 | ||
428 | /* yyn is what to do for this token type in this state. | |
429 | Negative => reduce, -yyn is rule number. | |
430 | Positive => shift, yyn is new state. | |
431 | New state is final state => don't bother to shift, | |
432 | just return success. | |
433 | 0, or most negative number => error. */ | |
434 | ||
435 | if (yyn < 0) | |
436 | { | |
437 | if (yyn == YYFLAG) | |
438 | goto yyerrlab; | |
439 | yyn = -yyn; | |
440 | goto yyreduce; | |
441 | } | |
442 | else if (yyn == 0) | |
443 | goto yyerrlab; | |
444 | ||
445 | if (yyn == YYFINAL) | |
446 | YYACCEPT; | |
447 | ||
448 | /* Shift the lookahead token. */ | |
449 | ||
450 | #if YYDEBUG != 0 | |
451 | if (yydebug) | |
452 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | |
453 | #endif | |
454 | ||
455 | /* Discard the token being shifted unless it is eof. */ | |
456 | if (yychar != YYEOF) | |
457 | yychar = YYEMPTY; | |
458 | ||
459 | *++yyvsp = yylval; | |
460 | #ifdef YYLSP_NEEDED | |
461 | *++yylsp = yylloc; | |
462 | #endif | |
463 | ||
464 | /* count tokens shifted since error; after three, turn off error status. */ | |
465 | if (yyerrstatus) yyerrstatus--; | |
466 | ||
467 | yystate = yyn; | |
468 | goto yynewstate; | |
469 | ||
470 | /* Do the default action for the current state. */ | |
471 | yydefault: | |
472 | ||
473 | yyn = yydefact[yystate]; | |
474 | if (yyn == 0) | |
475 | goto yyerrlab; | |
476 | ||
477 | /* Do a reduction. yyn is the number of a rule to reduce with. */ | |
478 | yyreduce: | |
479 | yylen = yyr2[yyn]; | |
fb75fa82 RS |
480 | if (yylen > 0) |
481 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ | |
10fa2066 RS |
482 | |
483 | #if YYDEBUG != 0 | |
484 | if (yydebug) | |
485 | { | |
486 | int i; | |
487 | ||
488 | fprintf (stderr, "Reducing via rule %d (line %d), ", | |
489 | yyn, yyrline[yyn]); | |
490 | ||
491 | /* Print the symbols being reduced, and their result. */ | |
492 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | |
493 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); | |
494 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
495 | } | |
496 | #endif | |
497 | ||
498 | $ /* the action file gets copied in in place of this dollarsign */ | |
a8a7082e | 499 | #line 498 "bison.simple" |
10fa2066 RS |
500 | \f |
501 | yyvsp -= yylen; | |
502 | yyssp -= yylen; | |
503 | #ifdef YYLSP_NEEDED | |
504 | yylsp -= yylen; | |
505 | #endif | |
506 | ||
507 | #if YYDEBUG != 0 | |
508 | if (yydebug) | |
509 | { | |
510 | short *ssp1 = yyss - 1; | |
511 | fprintf (stderr, "state stack now"); | |
512 | while (ssp1 != yyssp) | |
513 | fprintf (stderr, " %d", *++ssp1); | |
514 | fprintf (stderr, "\n"); | |
515 | } | |
516 | #endif | |
517 | ||
518 | *++yyvsp = yyval; | |
519 | ||
520 | #ifdef YYLSP_NEEDED | |
521 | yylsp++; | |
522 | if (yylen == 0) | |
523 | { | |
524 | yylsp->first_line = yylloc.first_line; | |
525 | yylsp->first_column = yylloc.first_column; | |
526 | yylsp->last_line = (yylsp-1)->last_line; | |
527 | yylsp->last_column = (yylsp-1)->last_column; | |
528 | yylsp->text = 0; | |
529 | } | |
530 | else | |
531 | { | |
532 | yylsp->last_line = (yylsp+yylen-1)->last_line; | |
533 | yylsp->last_column = (yylsp+yylen-1)->last_column; | |
534 | } | |
535 | #endif | |
536 | ||
537 | /* Now "shift" the result of the reduction. | |
538 | Determine what state that goes to, | |
539 | based on the state we popped back to | |
540 | and the rule number reduced by. */ | |
541 | ||
542 | yyn = yyr1[yyn]; | |
543 | ||
544 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
545 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
546 | yystate = yytable[yystate]; | |
547 | else | |
548 | yystate = yydefgoto[yyn - YYNTBASE]; | |
549 | ||
550 | goto yynewstate; | |
551 | ||
552 | yyerrlab: /* here on detecting error */ | |
553 | ||
554 | if (! yyerrstatus) | |
555 | /* If not already recovering from an error, report this error. */ | |
556 | { | |
557 | ++yynerrs; | |
558 | ||
559 | #ifdef YYERROR_VERBOSE | |
560 | yyn = yypact[yystate]; | |
561 | ||
562 | if (yyn > YYFLAG && yyn < YYLAST) | |
563 | { | |
564 | int size = 0; | |
565 | char *msg; | |
566 | int x, count; | |
567 | ||
568 | count = 0; | |
569 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | |
570 | for (x = (yyn < 0 ? -yyn : 0); | |
571 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
572 | if (yycheck[x + yyn] == x) | |
573 | size += strlen(yytname[x]) + 15, count++; | |
574 | msg = (char *) malloc(size + 15); | |
575 | if (msg != 0) | |
576 | { | |
577 | strcpy(msg, "parse error"); | |
578 | ||
579 | if (count < 5) | |
580 | { | |
581 | count = 0; | |
582 | for (x = (yyn < 0 ? -yyn : 0); | |
583 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
584 | if (yycheck[x + yyn] == x) | |
585 | { | |
586 | strcat(msg, count == 0 ? ", expecting `" : " or `"); | |
587 | strcat(msg, yytname[x]); | |
588 | strcat(msg, "'"); | |
589 | count++; | |
590 | } | |
591 | } | |
592 | yyerror(msg); | |
593 | free(msg); | |
594 | } | |
595 | else | |
596 | yyerror ("parse error; also virtual memory exceeded"); | |
597 | } | |
598 | else | |
599 | #endif /* YYERROR_VERBOSE */ | |
600 | yyerror("parse error"); | |
601 | } | |
602 | ||
603 | goto yyerrlab1; | |
604 | yyerrlab1: /* here on error raised explicitly by an action */ | |
605 | ||
606 | if (yyerrstatus == 3) | |
607 | { | |
608 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ | |
609 | ||
610 | /* return failure if at end of input */ | |
611 | if (yychar == YYEOF) | |
612 | YYABORT; | |
613 | ||
614 | #if YYDEBUG != 0 | |
615 | if (yydebug) | |
616 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | |
617 | #endif | |
618 | ||
619 | yychar = YYEMPTY; | |
620 | } | |
621 | ||
622 | /* Else will try to reuse lookahead token | |
623 | after shifting the error token. */ | |
624 | ||
625 | yyerrstatus = 3; /* Each real token shifted decrements this */ | |
626 | ||
627 | goto yyerrhandle; | |
628 | ||
629 | yyerrdefault: /* current state does not do anything special for the error token. */ | |
630 | ||
631 | #if 0 | |
632 | /* This is wrong; only states that explicitly want error tokens | |
633 | should shift them. */ | |
634 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | |
635 | if (yyn) goto yydefault; | |
636 | #endif | |
637 | ||
638 | yyerrpop: /* pop the current state because it cannot handle the error token */ | |
639 | ||
640 | if (yyssp == yyss) YYABORT; | |
641 | yyvsp--; | |
642 | yystate = *--yyssp; | |
643 | #ifdef YYLSP_NEEDED | |
644 | yylsp--; | |
645 | #endif | |
646 | ||
647 | #if YYDEBUG != 0 | |
648 | if (yydebug) | |
649 | { | |
650 | short *ssp1 = yyss - 1; | |
651 | fprintf (stderr, "Error: state stack now"); | |
652 | while (ssp1 != yyssp) | |
653 | fprintf (stderr, " %d", *++ssp1); | |
654 | fprintf (stderr, "\n"); | |
655 | } | |
656 | #endif | |
657 | ||
658 | yyerrhandle: | |
659 | ||
660 | yyn = yypact[yystate]; | |
661 | if (yyn == YYFLAG) | |
662 | goto yyerrdefault; | |
663 | ||
664 | yyn += YYTERROR; | |
665 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
666 | goto yyerrdefault; | |
667 | ||
668 | yyn = yytable[yyn]; | |
669 | if (yyn < 0) | |
670 | { | |
671 | if (yyn == YYFLAG) | |
672 | goto yyerrpop; | |
673 | yyn = -yyn; | |
674 | goto yyreduce; | |
675 | } | |
676 | else if (yyn == 0) | |
677 | goto yyerrpop; | |
678 | ||
679 | if (yyn == YYFINAL) | |
680 | YYACCEPT; | |
681 | ||
682 | #if YYDEBUG != 0 | |
683 | if (yydebug) | |
684 | fprintf(stderr, "Shifting error token, "); | |
685 | #endif | |
686 | ||
687 | *++yyvsp = yylval; | |
688 | #ifdef YYLSP_NEEDED | |
689 | *++yylsp = yylloc; | |
690 | #endif | |
691 | ||
692 | yystate = yyn; | |
693 | goto yynewstate; | |
694 | } |