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