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