2 /* A Bison parser, made from syntax.y with Bison version GNU Bison version 1.21
5 #define YYBISON 1 /* Identify Bison output. */
35 #define YYLTYPE yyltype
55 #define YYTRANSLATE(x) ((unsigned)(x) <= 264 ? yytranslate[x] : 15)
57 static const char yytranslate[] = { 0,
58 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
59 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
60 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
61 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
62 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
63 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
69 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
71 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
72 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
73 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
74 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
75 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
76 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
82 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
83 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
88 static const short yyprhs[] = { 0,
89 0, 7, 9, 12, 19, 25, 27, 30
92 static const short yyrhs[] = { 4,
93 3, 5, 11, 7, 5, 0, 12, 0, 11, 12,
94 0, 3, 6, 8, 13, 9, 5, 0, 3, 6,
95 8, 9, 5, 0, 14, 0, 13, 14, 0, 3,
102 static const short yyrline[] = { 0,
103 10, 16, 20, 26, 30, 36, 40, 46
106 static const char * const yytname[] = { "$","error","$illegal.","ID","TYPE",
107 "SEMICOL","COLON","END","STDEF","ENDDEF","typdef","deflist","def","itemlist",
112 static const short yyr1[] = { 0,
113 10, 11, 11, 12, 12, 13, 13, 14
116 static const short yyr2[] = { 0,
117 6, 1, 2, 6, 5, 1, 2, 4
120 static const short yydefact[] = { 0,
121 0, 0, 0, 0, 0, 2, 0, 0, 3, 0,
122 1, 0, 0, 0, 6, 0, 5, 0, 7, 0,
126 static const short yydefgoto[] = { 23,
130 static const short yypact[] = { -1,
131 2, 4, 7, -4, 1,-32768, 3, 8,-32768, -3,
132 -32768, 6, 9, -2,-32768, 12,-32768, 11,-32768, 13,
133 -32768,-32768, 17, 19,-32768
136 static const short yypgoto[] = {-32768,
137 -32768, 15,-32768, 10
144 static const short yytable[] = { 12,
145 12, 7, 1, 4, 2, 13, 18, 8, 3, 4,
146 10, 16, 11, 17, 20, 21, 24, 22, 25, 9,
150 static const short yycheck[] = { 3,
151 3, 6, 4, 3, 3, 9, 9, 7, 5, 3,
152 8, 6, 5, 5, 3, 5, 0, 5, 0, 5,
155 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
156 #line 3 "/usr/local/gnu/lib/bison.simple"
158 /* Skeleton output parser for bison,
159 Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
161 This program is free software; you can redistribute it and/or modify
162 it under the terms of the GNU General Public License as published by
163 the Free Software Foundation; either version 1, or (at your option)
166 This program is distributed in the hope that it will be useful,
167 but WITHOUT ANY WARRANTY; without even the implied warranty of
168 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169 GNU General Public License for more details.
171 You should have received a copy of the GNU General Public License
172 along with this program; if not, write to the Free Software
173 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
178 #define alloca __builtin_alloca
179 #else /* not GNU C. */
180 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
182 #else /* not sparc */
183 #if defined (MSDOS) && !defined (__TURBOC__)
185 #else /* not MSDOS, or __TURBOC__ */
189 #else /* not MSDOS, __TURBOC__, or _AIX */
193 void *alloca (unsigned int);
195 #else /* not __cplusplus */
196 void *alloca (unsigned int);
197 #endif /* not __cplusplus */
199 #endif /* not _AIX */
200 #endif /* not MSDOS, or __TURBOC__ */
201 #endif /* not sparc. */
202 #endif /* not GNU C. */
203 #endif /* alloca not defined. */
205 /* This is the parser code that is written into each bison parser
206 when the %semantic_parser declaration is not specified in the grammar.
207 It was written by Richard Stallman by simplifying the hairy parser
208 used when %semantic_parser is specified. */
210 /* Note: there must be only one dollar sign in this file.
211 It is replaced by the list of actions, each action
212 as one case of the switch. */
214 #define yyerrok (yyerrstatus = 0)
215 #define yyclearin (yychar = YYEMPTY)
218 #define YYACCEPT return(0)
219 #define YYABORT return(1)
220 #define YYERROR goto yyerrlab1
221 /* Like YYERROR except do call yyerror.
222 This remains here temporarily to ease the
223 transition to the new meaning of YYERROR, for GCC.
224 Once GCC version 2 has supplanted version 1, this can go. */
225 #define YYFAIL goto yyerrlab
226 #define YYRECOVERING() (!!yyerrstatus)
227 #define YYBACKUP(token, value) \
229 if (yychar == YYEMPTY && yylen == 1) \
230 { yychar = (token), yylval = (value); \
231 yychar1 = YYTRANSLATE (yychar); \
236 { yyerror ("syntax error: cannot back up"); YYERROR; } \
240 #define YYERRCODE 256
243 #define YYLEX yylex()
248 #define YYLEX yylex(&yylval, &yylloc)
250 #define YYLEX yylex(&yylval)
254 /* If nonreentrant, generate the variables here */
258 int yychar; /* the lookahead symbol */
259 YYSTYPE yylval; /* the semantic value of the */
260 /* lookahead symbol */
263 YYLTYPE yylloc; /* location data for the lookahead */
267 int yynerrs; /* number of parse errors so far */
268 #endif /* not YYPURE */
271 int yydebug; /* nonzero means print parse trace */
272 /* Since this is uninitialized, it does not stop multiple parsers
276 /* YYINITDEPTH indicates the initial size of the parser's stacks */
279 #define YYINITDEPTH 200
282 /* YYMAXDEPTH is the maximum size the stacks can grow to
283 (effective only if the built-in stack extension method is used). */
290 #define YYMAXDEPTH 10000
293 /* Prevent warning if -Wstrict-prototypes. */
298 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
299 #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
300 #else /* not GNU C or C++ */
303 /* This is the most reliable way to avoid incompatibilities
304 in available built-in functions on various systems. */
306 __yy_bcopy (from, to, count)
311 register char *f = from;
312 register char *t = to;
313 register int i = count;
319 #else /* __cplusplus */
321 /* This is the most reliable way to avoid incompatibilities
322 in available built-in functions on various systems. */
324 __yy_bcopy (char *from, char *to, int count)
326 register char *f = from;
327 register char *t = to;
328 register int i = count;
337 #line 184 "/usr/local/gnu/lib/bison.simple"
341 register int yystate;
343 register short *yyssp;
344 register YYSTYPE *yyvsp;
345 int yyerrstatus; /* number of tokens to shift before error messages enabled */
346 int yychar1; /* lookahead token as an internal (translated) token number */
348 short yyssa[YYINITDEPTH]; /* the state stack */
349 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
351 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
352 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
355 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
356 YYLTYPE *yyls = yylsa;
359 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
361 #define YYPOPSTACK (yyvsp--, yyssp--)
364 int yystacksize = YYINITDEPTH;
375 YYSTYPE yyval; /* the variable used to return */
376 /* semantic values from the action */
383 fprintf(stderr, "Starting parse\n");
389 yychar = YYEMPTY; /* Cause a token to be read. */
391 /* Initialize stack pointers.
392 Waste one element of value and location stack
393 so that they stay on the same level as the state stack.
394 The wasted elements are never initialized. */
402 /* Push a new state, which is found in yystate . */
403 /* In all cases, when you get here, the value and location stacks
404 have just been pushed. so pushing a state here evens the stacks. */
409 if (yyssp >= yyss + yystacksize - 1)
411 /* Give user a chance to reallocate the stack */
412 /* Use copies of these so that the &'s don't force the real ones into memory. */
413 YYSTYPE *yyvs1 = yyvs;
416 YYLTYPE *yyls1 = yyls;
419 /* Get the current used size of the three stacks, in elements. */
420 int size = yyssp - yyss + 1;
423 /* Each stack pointer address is followed by the size of
424 the data in use in that stack, in bytes. */
425 yyoverflow("parser stack overflow",
426 &yyss1, size * sizeof (*yyssp),
427 &yyvs1, size * sizeof (*yyvsp),
429 &yyls1, size * sizeof (*yylsp),
433 yyss = yyss1; yyvs = yyvs1;
437 #else /* no yyoverflow */
438 /* Extend the stack our own way. */
439 if (yystacksize >= YYMAXDEPTH)
441 yyerror("parser stack overflow");
445 if (yystacksize > YYMAXDEPTH)
446 yystacksize = YYMAXDEPTH;
447 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
448 __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
449 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
450 __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
452 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
453 __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
455 #endif /* no yyoverflow */
457 yyssp = yyss + size - 1;
458 yyvsp = yyvs + size - 1;
460 yylsp = yyls + size - 1;
465 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
468 if (yyssp >= yyss + yystacksize - 1)
474 fprintf(stderr, "Entering state %d\n", yystate);
480 /* Do appropriate processing given the current state. */
481 /* Read a lookahead token if we need one and don't already have one. */
484 /* First try to decide what to do without reference to lookahead token. */
486 yyn = yypact[yystate];
490 /* Not known => get a lookahead token if don't already have one. */
492 /* yychar is either YYEMPTY or YYEOF
493 or a valid token in external form. */
495 if (yychar == YYEMPTY)
499 fprintf(stderr, "Reading a token: ");
504 /* Convert token to internal form (in yychar1) for indexing tables with */
506 if (yychar <= 0) /* This means end of input. */
509 yychar = YYEOF; /* Don't call YYLEX any more */
513 fprintf(stderr, "Now at end of input.\n");
518 yychar1 = YYTRANSLATE(yychar);
523 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
524 /* Give the individual parser a way to print the precise meaning
525 of a token, for further debugging info. */
527 YYPRINT (stderr, yychar, yylval);
529 fprintf (stderr, ")\n");
535 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
540 /* yyn is what to do for this token type in this state.
541 Negative => reduce, -yyn is rule number.
542 Positive => shift, yyn is new state.
543 New state is final state => don't bother to shift,
545 0, or most negative number => error. */
560 /* Shift the lookahead token. */
564 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
567 /* Discard the token being shifted unless it is eof. */
576 /* count tokens shifted since error; after three, turn off error status. */
577 if (yyerrstatus) yyerrstatus--;
582 /* Do the default action for the current state. */
585 yyn = yydefact[yystate];
589 /* Do a reduction. yyn is the number of a rule to reduce with. */
592 yyval = yyvsp[1-yylen]; /* implement default value of the action */
599 fprintf (stderr, "Reducing via rule %d (line %d), ",
602 /* Print the symbols being reduced, and their result. */
603 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
604 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
605 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
615 root = mktypdef(yyvsp[-4], yyvsp[-2]);
627 yyval = (long) mkdeflist(yyvsp[-1], yyvsp[0]);
633 yyval = (long) mkdef(yyvsp[-5], yyvsp[-2]);
639 yyval = (long) mkdef(yyvsp[-4], mkemitemlist());
651 yyval = (long) mkitemlist(yyvsp[-1], yyvsp[0]);
657 yyval = (long) mkitem(yyvsp[-3], yyvsp[-1]);
661 /* the action file gets copied in in place of this dollarsign */
662 #line 457 "/usr/local/gnu/lib/bison.simple"
673 short *ssp1 = yyss - 1;
674 fprintf (stderr, "state stack now");
675 while (ssp1 != yyssp)
676 fprintf (stderr, " %d", *++ssp1);
677 fprintf (stderr, "\n");
687 yylsp->first_line = yylloc.first_line;
688 yylsp->first_column = yylloc.first_column;
689 yylsp->last_line = (yylsp-1)->last_line;
690 yylsp->last_column = (yylsp-1)->last_column;
695 yylsp->last_line = (yylsp+yylen-1)->last_line;
696 yylsp->last_column = (yylsp+yylen-1)->last_column;
700 /* Now "shift" the result of the reduction.
701 Determine what state that goes to,
702 based on the state we popped back to
703 and the rule number reduced by. */
707 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
708 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
709 yystate = yytable[yystate];
711 yystate = yydefgoto[yyn - YYNTBASE];
715 yyerrlab: /* here on detecting error */
718 /* If not already recovering from an error, report this error. */
722 #ifdef YYERROR_VERBOSE
723 yyn = yypact[yystate];
725 if (yyn > YYFLAG && yyn < YYLAST)
732 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
733 for (x = (yyn < 0 ? -yyn : 0);
734 x < (sizeof(yytname) / sizeof(char *)); x++)
735 if (yycheck[x + yyn] == x)
736 size += strlen(yytname[x]) + 15, count++;
737 msg = (char *) malloc(size + 15);
740 strcpy(msg, "parse error");
745 for (x = (yyn < 0 ? -yyn : 0);
746 x < (sizeof(yytname) / sizeof(char *)); x++)
747 if (yycheck[x + yyn] == x)
749 strcat(msg, count == 0 ? ", expecting `" : " or `");
750 strcat(msg, yytname[x]);
759 yyerror ("parse error; also virtual memory exceeded");
762 #endif /* YYERROR_VERBOSE */
763 yyerror("parse error");
767 yyerrlab1: /* here on error raised explicitly by an action */
769 if (yyerrstatus == 3)
771 /* if just tried and failed to reuse lookahead token after an error, discard it. */
773 /* return failure if at end of input */
779 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
785 /* Else will try to reuse lookahead token
786 after shifting the error token. */
788 yyerrstatus = 3; /* Each real token shifted decrements this */
792 yyerrdefault: /* current state does not do anything special for the error token. */
795 /* This is wrong; only states that explicitly want error tokens
796 should shift them. */
797 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
798 if (yyn) goto yydefault;
801 yyerrpop: /* pop the current state because it cannot handle the error token */
803 if (yyssp == yyss) YYABORT;
813 short *ssp1 = yyss - 1;
814 fprintf (stderr, "Error: state stack now");
815 while (ssp1 != yyssp)
816 fprintf (stderr, " %d", *++ssp1);
817 fprintf (stderr, "\n");
823 yyn = yypact[yystate];
828 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
847 fprintf(stderr, "Shifting error token, ");