2 /* A Bison parser, made from bi-parser.y
3 by Bison version A2.5 (Andrew Consortium)
6 #define YYBISON 1 /* Identify Bison output. */
11 #line 22 "bi-parser.y"
22 /* Chain of all defs built by the parser. */
26 static struct node
*makenode ();
27 static struct variation
*makevar ();
28 static struct def
*makedef ();
33 #line 44 "bi-parser.y"
38 struct variation
*variation
;
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
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,
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
114 static const char * const yytname
[] = { "$","error","$undefined.","DEFOP",
115 "STRING","'('","','","')'","top","defs","def","variations","variation","opt_string",
116 "list","items","item", NULL
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,
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
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,
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,
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)
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. */
196 #define alloca __builtin_alloca
197 #else /* not GNU C. */
198 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
200 #else /* not sparc */
201 #if defined (MSDOS) && !defined (__TURBOC__)
203 #else /* not MSDOS, or __TURBOC__ */
207 #else /* not MSDOS, __TURBOC__, or _AIX */
211 void *alloca (unsigned int);
213 #else /* not __cplusplus */
215 #endif /* not __cplusplus */
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)
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) \
247 if (yychar == YYEMPTY && yylen == 1) \
248 { yychar = (token), yylval = (value); \
249 yychar1 = YYTRANSLATE (yychar); \
254 { yyerror ("syntax error: cannot back up"); YYERROR; } \
258 #define YYERRCODE 256
261 #define YYLEX yylex()
267 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
269 #define YYLEX yylex(&yylval, &yylloc)
271 #else /* not YYLSP_NEEDED */
273 #define YYLEX yylex(&yylval, YYLEX_PARAM)
275 #define YYLEX yylex(&yylval)
277 #endif /* not YYLSP_NEEDED */
280 /* If nonreentrant, generate the variables here */
284 int yychar
; /* the lookahead symbol */
285 YYSTYPE yylval
; /* the semantic value of the */
286 /* lookahead symbol */
289 YYLTYPE yylloc
; /* location data for the lookahead */
293 int yynerrs
; /* number of parse errors so far */
294 #endif /* not YYPURE */
297 int yydebug
; /* nonzero means print parse trace */
298 /* Since this is uninitialized, it does not stop multiple parsers
302 /* YYINITDEPTH indicates the initial size of the parser's stacks */
305 #define YYINITDEPTH 200
308 /* YYMAXDEPTH is the maximum size the stacks can grow to
309 (effective only if the built-in stack extension method is used). */
316 #define YYMAXDEPTH 10000
319 /* Prevent warning if -Wstrict-prototypes. */
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++ */
329 /* This is the most reliable way to avoid incompatibilities
330 in available built-in functions on various systems. */
332 __yy_memcpy (from
, to
, count
)
337 register char *f
= from
;
338 register char *t
= to
;
339 register int i
= count
;
345 #else /* __cplusplus */
347 /* This is the most reliable way to avoid incompatibilities
348 in available built-in functions on various systems. */
350 __yy_memcpy (char *from
, char *to
, int count
)
352 register char *f
= from
;
353 register char *t
= to
;
354 register int i
= count
;
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. */
372 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
374 #define YYPARSE_PARAM
375 #define YYPARSE_PARAM_DECL
379 yyparse(YYPARSE_PARAM
)
382 register int yystate
;
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 */
396 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
397 YYLTYPE
*yyls
= yylsa
;
400 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
402 #define YYPOPSTACK (yyvsp--, yyssp--)
405 int yystacksize
= YYINITDEPTH
;
416 YYSTYPE yyval
; /* the variable used to return */
417 /* semantic values from the action */
424 fprintf(stderr
, "Starting parse\n");
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. */
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. */
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
;
457 YYLTYPE
*yyls1
= yyls
;
460 /* Get the current used size of the three stacks, in elements. */
461 int size
= yyssp
- yyss
+ 1;
464 /* Each stack pointer address is followed by the size of
465 the data in use in that stack, in bytes. */
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
),
475 yyoverflow("parser stack overflow",
476 &yyss1
, size
* sizeof (*yyssp
),
477 &yyvs1
, size
* sizeof (*yyvsp
),
481 yyss
= yyss1
; yyvs
= yyvs1
;
485 #else /* no yyoverflow */
486 /* Extend the stack our own way. */
487 if (yystacksize
>= YYMAXDEPTH
)
489 yyerror("parser stack overflow");
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
));
500 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
501 __yy_memcpy ((char *)yyls1
, (char *)yyls
, size
* sizeof (*yylsp
));
503 #endif /* no yyoverflow */
505 yyssp
= yyss
+ size
- 1;
506 yyvsp
= yyvs
+ size
- 1;
508 yylsp
= yyls
+ size
- 1;
513 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
516 if (yyssp
>= yyss
+ yystacksize
- 1)
522 fprintf(stderr
, "Entering state %d\n", yystate
);
528 /* Do appropriate processing given the current state. */
529 /* Read a lookahead token if we need one and don't already have one. */
532 /* First try to decide what to do without reference to lookahead token. */
534 yyn
= yypact
[yystate
];
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
)
547 fprintf(stderr
, "Reading a token: ");
552 /* Convert token to internal form (in yychar1) for indexing tables with */
554 if (yychar
<= 0) /* This means end of input. */
557 yychar
= YYEOF
; /* Don't call YYLEX any more */
561 fprintf(stderr
, "Now at end of input.\n");
566 yychar1
= YYTRANSLATE(yychar
);
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. */
575 YYPRINT (stderr
, yychar
, yylval
);
577 fprintf (stderr
, ")\n");
583 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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,
593 0, or most negative number => error. */
608 /* Shift the lookahead token. */
612 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
615 /* Discard the token being shifted unless it is eof. */
624 /* count tokens shifted since error; after three, turn off error status. */
625 if (yyerrstatus
) yyerrstatus
--;
630 /* Do the default action for the current state. */
633 yyn
= yydefact
[yystate
];
637 /* Do a reduction. yyn is the number of a rule to reduce with. */
641 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
648 fprintf (stderr
, "Reducing via rule %d (line %d), ",
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
]]);
662 #line 62 "bi-parser.y"
663 { defs
= yyvsp
[0].def
; ;
666 #line 68 "bi-parser.y"
667 { yyvsp
[0].def
->next
= yyvsp
[-1].def
; yyval
.def
= yyvsp
[0].def
; ;
670 #line 73 "bi-parser.y"
671 { yyval
.def
= makedef (yyvsp
[-7].string
, yyvsp
[-5].string
, yyvsp
[-2].variation
); ;
674 #line 79 "bi-parser.y"
675 { yyvsp
[0].variation
->next
= yyvsp
[-2].variation
; yyval
.variation
= yyvsp
[0].variation
; ;
678 #line 84 "bi-parser.y"
679 { yyval
.variation
= makevar (yyvsp
[-1].string
, (struct node
*) NULL
, (struct node
*) NULL
, (struct node
*) NULL
); ;
682 #line 86 "bi-parser.y"
683 { yyval
.variation
= makevar (yyvsp
[-3].string
, yyvsp
[-1].node
, (struct node
*) NULL
, (struct node
*) NULL
); ;
686 #line 88 "bi-parser.y"
687 { yyval
.variation
= makevar (yyvsp
[-5].string
, yyvsp
[-3].node
, yyvsp
[-1].node
, (struct node
*) NULL
); ;
690 #line 90 "bi-parser.y"
691 { yyval
.variation
= makevar (yyvsp
[-7].string
, yyvsp
[-5].node
, yyvsp
[-3].node
, yyvsp
[-1].node
); ;
694 #line 94 "bi-parser.y"
695 { yyval
.string
= ""; ;
698 #line 95 "bi-parser.y"
699 { yyval
.string
= yyvsp
[0].string
; ;
702 #line 100 "bi-parser.y"
703 { yyval
.node
= yyvsp
[-1].node
; ;
706 #line 102 "bi-parser.y"
707 { yyval
.node
= NULL
; ;
710 #line 109 "bi-parser.y"
711 { yyvsp
[-2].node
->next
= yyvsp
[0].node
; yyval
.node
= yyvsp
[-2].node
; ;
714 #line 114 "bi-parser.y"
715 { yyval
.node
= makenode (yyvsp
[0].string
); ;
718 /* the action file gets copied in in place of this dollarsign */
719 #line 487 "/usr/share/bison.simple"
730 short *ssp1
= yyss
- 1;
731 fprintf (stderr
, "state stack now");
732 while (ssp1
!= yyssp
)
733 fprintf (stderr
, " %d", *++ssp1
);
734 fprintf (stderr
, "\n");
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
;
752 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
753 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
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. */
764 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
765 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
766 yystate
= yytable
[yystate
];
768 yystate
= yydefgoto
[yyn
- YYNTBASE
];
772 yyerrlab
: /* here on detecting error */
775 /* If not already recovering from an error, report this error. */
779 #ifdef YYERROR_VERBOSE
780 yyn
= yypact
[yystate
];
782 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
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);
797 strcpy(msg
, "parse error");
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
]);
816 yyerror ("parse error; also virtual memory exceeded");
819 #endif /* YYERROR_VERBOSE */
820 yyerror("parse error");
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 */
836 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
842 /* Else will try to reuse lookahead token
843 after shifting the error token. */
845 yyerrstatus
= 3; /* Each real token shifted decrements this */
849 yyerrdefault
: /* current state does not do anything special for the error token. */
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
;
858 yyerrpop
: /* pop the current state because it cannot handle the error token */
860 if (yyssp
== yyss
) YYABORT
;
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");
880 yyn
= yypact
[yystate
];
885 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
904 fprintf(stderr
, "Shifting error token, ");
915 #line 117 "bi-parser.y"
924 n
= (struct node
*) malloc (sizeof (struct node
));
930 static struct variation
*
931 makevar (name
, inputs
, outputs
, literals
)
933 struct node
*inputs
, *outputs
, *literals
;
937 v
= (struct variation
*) malloc (sizeof (struct variation
));
941 v
->outputs
= outputs
;
942 v
->literals
= literals
;
948 makedef (name
, template, vars
)
949 char *name
, *template;
950 struct variation
*vars
;
954 d
= (struct def
*) malloc (sizeof (struct def
));
956 d
->template = template;
957 d
->variations
= vars
;
966 fprintf (stderr
, "syntax error in input\n");
967 exit (FATAL_EXIT_CODE
);