Import gcc-2.8.1.tar.bz2
[official-gcc.git] / gcc / bi-parser.c
blobf673fc6c6d1c60d2db34c8b96beafe5e5b732364
2 /* A Bison parser, made from bi-parser.y
3 by Bison version A2.5 (Andrew Consortium)
4 */
6 #define YYBISON 1 /* Identify Bison output. */
8 #define DEFOP 258
9 #define STRING 259
11 #line 22 "bi-parser.y"
14 #include <stdio.h>
15 #include "hconfig.h"
16 #include "bi-defs.h"
18 extern char yytext[];
19 extern int yyleng;
22 /* Chain of all defs built by the parser. */
23 struct def *defs;
24 int ndefs;
26 static struct node *makenode ();
27 static struct variation *makevar ();
28 static struct def *makedef ();
30 void yyerror ();
33 #line 44 "bi-parser.y"
34 typedef union
36 char *string;
37 struct def *def;
38 struct variation *variation;
39 struct node *node;
40 } YYSTYPE;
41 #include <stdio.h>
43 #ifndef __cplusplus
44 #ifndef __STDC__
45 #define const
46 #endif
47 #endif
51 #define YYFINAL 39
52 #define YYFLAG -32768
53 #define YYNTBASE 8
55 #define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 17)
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, 5,
62 7, 2, 2, 6, 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
86 #if YYDEBUG != 0
87 static const short yyprhs[] = { 0,
88 0, 2, 4, 7, 18, 20, 24, 28, 34, 42,
89 52, 53, 55, 59, 60, 62, 66
92 static const short yyrhs[] = { 9,
93 0, 10, 0, 9, 10, 0, 3, 5, 4, 6,
94 13, 6, 5, 11, 7, 7, 0, 12, 0, 11,
95 6, 12, 0, 5, 13, 7, 0, 5, 13, 6,
96 14, 7, 0, 5, 13, 6, 14, 6, 14, 7,
97 0, 5, 13, 6, 14, 6, 14, 6, 14, 7,
98 0, 0, 4, 0, 5, 15, 7, 0, 0, 16,
99 0, 16, 6, 15, 0, 4, 0
102 #endif
104 #if YYDEBUG != 0
105 static const short yyrline[] = { 0,
106 60, 65, 67, 71, 76, 78, 82, 85, 87, 89,
107 93, 95, 98, 101, 105, 108, 112
109 #endif
112 #if YYDEBUG != 0
114 static const char * const yytname[] = { "$","error","$undefined.","DEFOP",
115 "STRING","'('","','","')'","top","defs","def","variations","variation","opt_string",
116 "list","items","item", NULL
118 #endif
120 static const short yyr1[] = { 0,
121 8, 9, 9, 10, 11, 11, 12, 12, 12, 12,
122 13, 13, 14, 14, 15, 15, 16
125 static const short yyr2[] = { 0,
126 1, 1, 2, 10, 1, 3, 3, 5, 7, 9,
127 0, 1, 3, 0, 1, 3, 1
130 static const short yydefact[] = { 0,
131 0, 1, 2, 0, 3, 0, 11, 12, 0, 0,
132 0, 11, 0, 5, 0, 0, 0, 14, 7, 6,
133 4, 0, 0, 17, 0, 15, 14, 8, 13, 0,
134 0, 16, 14, 9, 0, 10, 0, 0, 0
137 static const short yydefgoto[] = { 37,
138 2, 3, 13, 14, 9, 23, 25, 26
141 static const short yypact[] = { 2,
142 6, 2,-32768, 8,-32768, 7, 10,-32768, 9, 11,
143 12, 10, -5,-32768, -3, 12, 13, 14,-32768,-32768,
144 -32768, 17, 1,-32768, 15, 18, 14,-32768,-32768, 17,
145 3,-32768, 14,-32768, 16,-32768, 25, 26,-32768
148 static const short yypgoto[] = {-32768,
149 -32768, 27,-32768, 19, 20, -27, -12,-32768
153 #define YYLAST 35
156 static const short yytable[] = { 31,
157 16, 17, 18, 19, 1, 35, 27, 28, 33, 34,
158 4, 6, 7, 8, 10, 11, 12, 32, 22, 21,
159 24, 29, 36, 30, 38, 39, 0, 0, 5, 0,
160 0, 15, 0, 0, 20
163 static const short yycheck[] = { 27,
164 6, 7, 6, 7, 3, 33, 6, 7, 6, 7,
165 5, 4, 6, 4, 6, 5, 5, 30, 5, 7,
166 4, 7, 7, 6, 0, 0, -1, -1, 2, -1,
167 -1, 12, -1, -1, 16
169 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
170 #line 3 "/usr/share/bison.simple"
172 /* Skeleton output parser for bison,
173 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
175 This program is free software; you can redistribute it and/or modify
176 it under the terms of the GNU General Public License as published by
177 the Free Software Foundation; either version 2, or (at your option)
178 any later version.
180 This program is distributed in the hope that it will be useful,
181 but WITHOUT ANY WARRANTY; without even the implied warranty of
182 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183 GNU General Public License for more details.
185 You should have received a copy of the GNU General Public License
186 along with this program; if not, write to the Free Software
187 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
189 /* As a special exception, when this file is copied by Bison into a
190 Bison output file, you may use that output file without restriction.
191 This special exception was added by the Free Software Foundation
192 in version 1.24 of Bison. */
194 #ifndef alloca
195 #ifdef __GNUC__
196 #define alloca __builtin_alloca
197 #else /* not GNU C. */
198 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
199 #include <alloca.h>
200 #else /* not sparc */
201 #if defined (MSDOS) && !defined (__TURBOC__)
202 #include <malloc.h>
203 #else /* not MSDOS, or __TURBOC__ */
204 #if defined(_AIX)
205 #include <malloc.h>
206 #pragma alloca
207 #else /* not MSDOS, __TURBOC__, or _AIX */
208 #ifdef __hpux
209 #ifdef __cplusplus
210 extern "C" {
211 void *alloca (unsigned int);
213 #else /* not __cplusplus */
214 void *alloca ();
215 #endif /* not __cplusplus */
216 #endif /* __hpux */
217 #endif /* not _AIX */
218 #endif /* not MSDOS, or __TURBOC__ */
219 #endif /* not sparc. */
220 #endif /* not GNU C. */
221 #endif /* alloca not defined. */
223 /* This is the parser code that is written into each bison parser
224 when the %semantic_parser declaration is not specified in the grammar.
225 It was written by Richard Stallman by simplifying the hairy parser
226 used when %semantic_parser is specified. */
228 /* Note: there must be only one dollar sign in this file.
229 It is replaced by the list of actions, each action
230 as one case of the switch. */
232 #define yyerrok (yyerrstatus = 0)
233 #define yyclearin (yychar = YYEMPTY)
234 #define YYEMPTY -2
235 #define YYEOF 0
236 #define YYACCEPT return(0)
237 #define YYABORT return(1)
238 #define YYERROR goto yyerrlab1
239 /* Like YYERROR except do call yyerror.
240 This remains here temporarily to ease the
241 transition to the new meaning of YYERROR, for GCC.
242 Once GCC version 2 has supplanted version 1, this can go. */
243 #define YYFAIL goto yyerrlab
244 #define YYRECOVERING() (!!yyerrstatus)
245 #define YYBACKUP(token, value) \
246 do \
247 if (yychar == YYEMPTY && yylen == 1) \
248 { yychar = (token), yylval = (value); \
249 yychar1 = YYTRANSLATE (yychar); \
250 YYPOPSTACK; \
251 goto yybackup; \
253 else \
254 { yyerror ("syntax error: cannot back up"); YYERROR; } \
255 while (0)
257 #define YYTERROR 1
258 #define YYERRCODE 256
260 #ifndef YYPURE
261 #define YYLEX yylex()
262 #endif
264 #ifdef YYPURE
265 #ifdef YYLSP_NEEDED
266 #ifdef YYLEX_PARAM
267 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
268 #else
269 #define YYLEX yylex(&yylval, &yylloc)
270 #endif
271 #else /* not YYLSP_NEEDED */
272 #ifdef YYLEX_PARAM
273 #define YYLEX yylex(&yylval, YYLEX_PARAM)
274 #else
275 #define YYLEX yylex(&yylval)
276 #endif
277 #endif /* not YYLSP_NEEDED */
278 #endif
280 /* If nonreentrant, generate the variables here */
282 #ifndef YYPURE
284 int yychar; /* the lookahead symbol */
285 YYSTYPE yylval; /* the semantic value of the */
286 /* lookahead symbol */
288 #ifdef YYLSP_NEEDED
289 YYLTYPE yylloc; /* location data for the lookahead */
290 /* symbol */
291 #endif
293 int yynerrs; /* number of parse errors so far */
294 #endif /* not YYPURE */
296 #if YYDEBUG != 0
297 int yydebug; /* nonzero means print parse trace */
298 /* Since this is uninitialized, it does not stop multiple parsers
299 from coexisting. */
300 #endif
302 /* YYINITDEPTH indicates the initial size of the parser's stacks */
304 #ifndef YYINITDEPTH
305 #define YYINITDEPTH 200
306 #endif
308 /* YYMAXDEPTH is the maximum size the stacks can grow to
309 (effective only if the built-in stack extension method is used). */
311 #if YYMAXDEPTH == 0
312 #undef YYMAXDEPTH
313 #endif
315 #ifndef YYMAXDEPTH
316 #define YYMAXDEPTH 10000
317 #endif
319 /* Prevent warning if -Wstrict-prototypes. */
320 #ifdef __GNUC__
321 int yyparse (void);
322 #endif
324 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
325 #define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
326 #else /* not GNU C or C++ */
327 #ifndef __cplusplus
329 /* This is the most reliable way to avoid incompatibilities
330 in available built-in functions on various systems. */
331 static void
332 __yy_memcpy (from, to, count)
333 char *from;
334 char *to;
335 int count;
337 register char *f = from;
338 register char *t = to;
339 register int i = count;
341 while (i-- > 0)
342 *t++ = *f++;
345 #else /* __cplusplus */
347 /* This is the most reliable way to avoid incompatibilities
348 in available built-in functions on various systems. */
349 static void
350 __yy_memcpy (char *from, char *to, int count)
352 register char *f = from;
353 register char *t = to;
354 register int i = count;
356 while (i-- > 0)
357 *t++ = *f++;
360 #endif
361 #endif
363 #line 192 "/usr/share/bison.simple"
365 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
366 into yyparse. The argument should have type void *.
367 It should actually point to an object.
368 Grammar actions can access the variable by casting it
369 to the proper pointer type. */
371 #ifdef YYPARSE_PARAM
372 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
373 #else
374 #define YYPARSE_PARAM
375 #define YYPARSE_PARAM_DECL
376 #endif
379 yyparse(YYPARSE_PARAM)
380 YYPARSE_PARAM_DECL
382 register int yystate;
383 register int yyn;
384 register short *yyssp;
385 register YYSTYPE *yyvsp;
386 int yyerrstatus; /* number of tokens to shift before error messages enabled */
387 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
389 short yyssa[YYINITDEPTH]; /* the state stack */
390 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
392 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
393 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
395 #ifdef YYLSP_NEEDED
396 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
397 YYLTYPE *yyls = yylsa;
398 YYLTYPE *yylsp;
400 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
401 #else
402 #define YYPOPSTACK (yyvsp--, yyssp--)
403 #endif
405 int yystacksize = YYINITDEPTH;
407 #ifdef YYPURE
408 int yychar;
409 YYSTYPE yylval;
410 int yynerrs;
411 #ifdef YYLSP_NEEDED
412 YYLTYPE yylloc;
413 #endif
414 #endif
416 YYSTYPE yyval; /* the variable used to return */
417 /* semantic values from the action */
418 /* routines */
420 int yylen;
422 #if YYDEBUG != 0
423 if (yydebug)
424 fprintf(stderr, "Starting parse\n");
425 #endif
427 yystate = 0;
428 yyerrstatus = 0;
429 yynerrs = 0;
430 yychar = YYEMPTY; /* Cause a token to be read. */
432 /* Initialize stack pointers.
433 Waste one element of value and location stack
434 so that they stay on the same level as the state stack.
435 The wasted elements are never initialized. */
437 yyssp = yyss - 1;
438 yyvsp = yyvs;
439 #ifdef YYLSP_NEEDED
440 yylsp = yyls;
441 #endif
443 /* Push a new state, which is found in yystate . */
444 /* In all cases, when you get here, the value and location stacks
445 have just been pushed. so pushing a state here evens the stacks. */
446 yynewstate:
448 *++yyssp = yystate;
450 if (yyssp >= yyss + yystacksize - 1)
452 /* Give user a chance to reallocate the stack */
453 /* Use copies of these so that the &'s don't force the real ones into memory. */
454 YYSTYPE *yyvs1 = yyvs;
455 short *yyss1 = yyss;
456 #ifdef YYLSP_NEEDED
457 YYLTYPE *yyls1 = yyls;
458 #endif
460 /* Get the current used size of the three stacks, in elements. */
461 int size = yyssp - yyss + 1;
463 #ifdef yyoverflow
464 /* Each stack pointer address is followed by the size of
465 the data in use in that stack, in bytes. */
466 #ifdef YYLSP_NEEDED
467 /* This used to be a conditional around just the two extra args,
468 but that might be undefined if yyoverflow is a macro. */
469 yyoverflow("parser stack overflow",
470 &yyss1, size * sizeof (*yyssp),
471 &yyvs1, size * sizeof (*yyvsp),
472 &yyls1, size * sizeof (*yylsp),
473 &yystacksize);
474 #else
475 yyoverflow("parser stack overflow",
476 &yyss1, size * sizeof (*yyssp),
477 &yyvs1, size * sizeof (*yyvsp),
478 &yystacksize);
479 #endif
481 yyss = yyss1; yyvs = yyvs1;
482 #ifdef YYLSP_NEEDED
483 yyls = yyls1;
484 #endif
485 #else /* no yyoverflow */
486 /* Extend the stack our own way. */
487 if (yystacksize >= YYMAXDEPTH)
489 yyerror("parser stack overflow");
490 return 2;
492 yystacksize *= 2;
493 if (yystacksize > YYMAXDEPTH)
494 yystacksize = YYMAXDEPTH;
495 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
496 __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
497 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
498 __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
499 #ifdef YYLSP_NEEDED
500 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
501 __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
502 #endif
503 #endif /* no yyoverflow */
505 yyssp = yyss + size - 1;
506 yyvsp = yyvs + size - 1;
507 #ifdef YYLSP_NEEDED
508 yylsp = yyls + size - 1;
509 #endif
511 #if YYDEBUG != 0
512 if (yydebug)
513 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
514 #endif
516 if (yyssp >= yyss + yystacksize - 1)
517 YYABORT;
520 #if YYDEBUG != 0
521 if (yydebug)
522 fprintf(stderr, "Entering state %d\n", yystate);
523 #endif
525 goto yybackup;
526 yybackup:
528 /* Do appropriate processing given the current state. */
529 /* Read a lookahead token if we need one and don't already have one. */
530 /* yyresume: */
532 /* First try to decide what to do without reference to lookahead token. */
534 yyn = yypact[yystate];
535 if (yyn == YYFLAG)
536 goto yydefault;
538 /* Not known => get a lookahead token if don't already have one. */
540 /* yychar is either YYEMPTY or YYEOF
541 or a valid token in external form. */
543 if (yychar == YYEMPTY)
545 #if YYDEBUG != 0
546 if (yydebug)
547 fprintf(stderr, "Reading a token: ");
548 #endif
549 yychar = YYLEX;
552 /* Convert token to internal form (in yychar1) for indexing tables with */
554 if (yychar <= 0) /* This means end of input. */
556 yychar1 = 0;
557 yychar = YYEOF; /* Don't call YYLEX any more */
559 #if YYDEBUG != 0
560 if (yydebug)
561 fprintf(stderr, "Now at end of input.\n");
562 #endif
564 else
566 yychar1 = YYTRANSLATE(yychar);
568 #if YYDEBUG != 0
569 if (yydebug)
571 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
572 /* Give the individual parser a way to print the precise meaning
573 of a token, for further debugging info. */
574 #ifdef YYPRINT
575 YYPRINT (stderr, yychar, yylval);
576 #endif
577 fprintf (stderr, ")\n");
579 #endif
582 yyn += yychar1;
583 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
584 goto yydefault;
586 yyn = yytable[yyn];
588 /* yyn is what to do for this token type in this state.
589 Negative => reduce, -yyn is rule number.
590 Positive => shift, yyn is new state.
591 New state is final state => don't bother to shift,
592 just return success.
593 0, or most negative number => error. */
595 if (yyn < 0)
597 if (yyn == YYFLAG)
598 goto yyerrlab;
599 yyn = -yyn;
600 goto yyreduce;
602 else if (yyn == 0)
603 goto yyerrlab;
605 if (yyn == YYFINAL)
606 YYACCEPT;
608 /* Shift the lookahead token. */
610 #if YYDEBUG != 0
611 if (yydebug)
612 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
613 #endif
615 /* Discard the token being shifted unless it is eof. */
616 if (yychar != YYEOF)
617 yychar = YYEMPTY;
619 *++yyvsp = yylval;
620 #ifdef YYLSP_NEEDED
621 *++yylsp = yylloc;
622 #endif
624 /* count tokens shifted since error; after three, turn off error status. */
625 if (yyerrstatus) yyerrstatus--;
627 yystate = yyn;
628 goto yynewstate;
630 /* Do the default action for the current state. */
631 yydefault:
633 yyn = yydefact[yystate];
634 if (yyn == 0)
635 goto yyerrlab;
637 /* Do a reduction. yyn is the number of a rule to reduce with. */
638 yyreduce:
639 yylen = yyr2[yyn];
640 if (yylen > 0)
641 yyval = yyvsp[1-yylen]; /* implement default value of the action */
643 #if YYDEBUG != 0
644 if (yydebug)
646 int i;
648 fprintf (stderr, "Reducing via rule %d (line %d), ",
649 yyn, yyrline[yyn]);
651 /* Print the symbols being reduced, and their result. */
652 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
653 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
654 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
656 #endif
659 switch (yyn) {
661 case 1:
662 #line 62 "bi-parser.y"
663 { defs = yyvsp[0].def; ;
664 break;}
665 case 3:
666 #line 68 "bi-parser.y"
667 { yyvsp[0].def->next = yyvsp[-1].def; yyval.def = yyvsp[0].def; ;
668 break;}
669 case 4:
670 #line 73 "bi-parser.y"
671 { yyval.def = makedef (yyvsp[-7].string, yyvsp[-5].string, yyvsp[-2].variation); ;
672 break;}
673 case 6:
674 #line 79 "bi-parser.y"
675 { yyvsp[0].variation->next = yyvsp[-2].variation; yyval.variation = yyvsp[0].variation; ;
676 break;}
677 case 7:
678 #line 84 "bi-parser.y"
679 { yyval.variation = makevar (yyvsp[-1].string, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); ;
680 break;}
681 case 8:
682 #line 86 "bi-parser.y"
683 { yyval.variation = makevar (yyvsp[-3].string, yyvsp[-1].node, (struct node *) NULL, (struct node *) NULL); ;
684 break;}
685 case 9:
686 #line 88 "bi-parser.y"
687 { yyval.variation = makevar (yyvsp[-5].string, yyvsp[-3].node, yyvsp[-1].node, (struct node *) NULL); ;
688 break;}
689 case 10:
690 #line 90 "bi-parser.y"
691 { yyval.variation = makevar (yyvsp[-7].string, yyvsp[-5].node, yyvsp[-3].node, yyvsp[-1].node); ;
692 break;}
693 case 11:
694 #line 94 "bi-parser.y"
695 { yyval.string = ""; ;
696 break;}
697 case 12:
698 #line 95 "bi-parser.y"
699 { yyval.string = yyvsp[0].string; ;
700 break;}
701 case 13:
702 #line 100 "bi-parser.y"
703 { yyval.node = yyvsp[-1].node; ;
704 break;}
705 case 14:
706 #line 102 "bi-parser.y"
707 { yyval.node = NULL; ;
708 break;}
709 case 16:
710 #line 109 "bi-parser.y"
711 { yyvsp[-2].node->next = yyvsp[0].node; yyval.node = yyvsp[-2].node; ;
712 break;}
713 case 17:
714 #line 114 "bi-parser.y"
715 { yyval.node = makenode (yyvsp[0].string); ;
716 break;}
718 /* the action file gets copied in in place of this dollarsign */
719 #line 487 "/usr/share/bison.simple"
721 yyvsp -= yylen;
722 yyssp -= yylen;
723 #ifdef YYLSP_NEEDED
724 yylsp -= yylen;
725 #endif
727 #if YYDEBUG != 0
728 if (yydebug)
730 short *ssp1 = yyss - 1;
731 fprintf (stderr, "state stack now");
732 while (ssp1 != yyssp)
733 fprintf (stderr, " %d", *++ssp1);
734 fprintf (stderr, "\n");
736 #endif
738 *++yyvsp = yyval;
740 #ifdef YYLSP_NEEDED
741 yylsp++;
742 if (yylen == 0)
744 yylsp->first_line = yylloc.first_line;
745 yylsp->first_column = yylloc.first_column;
746 yylsp->last_line = (yylsp-1)->last_line;
747 yylsp->last_column = (yylsp-1)->last_column;
748 yylsp->text = 0;
750 else
752 yylsp->last_line = (yylsp+yylen-1)->last_line;
753 yylsp->last_column = (yylsp+yylen-1)->last_column;
755 #endif
757 /* Now "shift" the result of the reduction.
758 Determine what state that goes to,
759 based on the state we popped back to
760 and the rule number reduced by. */
762 yyn = yyr1[yyn];
764 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
765 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
766 yystate = yytable[yystate];
767 else
768 yystate = yydefgoto[yyn - YYNTBASE];
770 goto yynewstate;
772 yyerrlab: /* here on detecting error */
774 if (! yyerrstatus)
775 /* If not already recovering from an error, report this error. */
777 ++yynerrs;
779 #ifdef YYERROR_VERBOSE
780 yyn = yypact[yystate];
782 if (yyn > YYFLAG && yyn < YYLAST)
784 int size = 0;
785 char *msg;
786 int x, count;
788 count = 0;
789 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
790 for (x = (yyn < 0 ? -yyn : 0);
791 x < (sizeof(yytname) / sizeof(char *)); x++)
792 if (yycheck[x + yyn] == x)
793 size += strlen(yytname[x]) + 15, count++;
794 msg = (char *) malloc(size + 15);
795 if (msg != 0)
797 strcpy(msg, "parse error");
799 if (count < 5)
801 count = 0;
802 for (x = (yyn < 0 ? -yyn : 0);
803 x < (sizeof(yytname) / sizeof(char *)); x++)
804 if (yycheck[x + yyn] == x)
806 strcat(msg, count == 0 ? ", expecting `" : " or `");
807 strcat(msg, yytname[x]);
808 strcat(msg, "'");
809 count++;
812 yyerror(msg);
813 free(msg);
815 else
816 yyerror ("parse error; also virtual memory exceeded");
818 else
819 #endif /* YYERROR_VERBOSE */
820 yyerror("parse error");
823 goto yyerrlab1;
824 yyerrlab1: /* here on error raised explicitly by an action */
826 if (yyerrstatus == 3)
828 /* if just tried and failed to reuse lookahead token after an error, discard it. */
830 /* return failure if at end of input */
831 if (yychar == YYEOF)
832 YYABORT;
834 #if YYDEBUG != 0
835 if (yydebug)
836 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
837 #endif
839 yychar = YYEMPTY;
842 /* Else will try to reuse lookahead token
843 after shifting the error token. */
845 yyerrstatus = 3; /* Each real token shifted decrements this */
847 goto yyerrhandle;
849 yyerrdefault: /* current state does not do anything special for the error token. */
851 #if 0
852 /* This is wrong; only states that explicitly want error tokens
853 should shift them. */
854 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
855 if (yyn) goto yydefault;
856 #endif
858 yyerrpop: /* pop the current state because it cannot handle the error token */
860 if (yyssp == yyss) YYABORT;
861 yyvsp--;
862 yystate = *--yyssp;
863 #ifdef YYLSP_NEEDED
864 yylsp--;
865 #endif
867 #if YYDEBUG != 0
868 if (yydebug)
870 short *ssp1 = yyss - 1;
871 fprintf (stderr, "Error: state stack now");
872 while (ssp1 != yyssp)
873 fprintf (stderr, " %d", *++ssp1);
874 fprintf (stderr, "\n");
876 #endif
878 yyerrhandle:
880 yyn = yypact[yystate];
881 if (yyn == YYFLAG)
882 goto yyerrdefault;
884 yyn += YYTERROR;
885 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
886 goto yyerrdefault;
888 yyn = yytable[yyn];
889 if (yyn < 0)
891 if (yyn == YYFLAG)
892 goto yyerrpop;
893 yyn = -yyn;
894 goto yyreduce;
896 else if (yyn == 0)
897 goto yyerrpop;
899 if (yyn == YYFINAL)
900 YYACCEPT;
902 #if YYDEBUG != 0
903 if (yydebug)
904 fprintf(stderr, "Shifting error token, ");
905 #endif
907 *++yyvsp = yylval;
908 #ifdef YYLSP_NEEDED
909 *++yylsp = yylloc;
910 #endif
912 yystate = yyn;
913 goto yynewstate;
915 #line 117 "bi-parser.y"
918 static struct node *
919 makenode (s)
920 char *s;
922 struct node *n;
924 n = (struct node *) malloc (sizeof (struct node));
925 n->text = s;
926 n->next = NULL;
927 return n;
930 static struct variation *
931 makevar (name, inputs, outputs, literals)
932 char *name;
933 struct node *inputs, *outputs, *literals;
935 struct variation *v;
937 v = (struct variation *) malloc (sizeof (struct variation));
938 v->name = name;
939 v->code = ndefs++;
940 v->inputs = inputs;
941 v->outputs = outputs;
942 v->literals = literals;
943 v->next = NULL;
944 return v;
947 static struct def *
948 makedef (name, template, vars)
949 char *name, *template;
950 struct variation *vars;
952 struct def *d;
954 d = (struct def *) malloc (sizeof (struct def));
955 d->basename = name;
956 d->template = template;
957 d->variations = vars;
958 d->next = NULL;
959 return d;
962 void
963 yyerror (s)
964 char *s;
966 fprintf (stderr, "syntax error in input\n");
967 exit (FATAL_EXIT_CODE);