2 * Copyright (c) 1989 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char const sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95";
43 /* The definition of yysccsid in the banner should be replaced with */
44 /* a #pragma ident directive if the target C compiler supports */
45 /* #pragma ident directives. */
47 /* If the skeleton is changed, the banner should be changed so that */
48 /* the altered version can be easily distinguished from the original. */
50 /* The #defines included with the banner are there because they are */
51 /* useful in subsequent code. The macros #defined in the header or */
52 /* the body either are not useful outside of semantic actions or */
53 /* are conditional. */
59 "yyrcsid[] = \"$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28.2.1 2001/07/19 05:46:39 peter Exp $\";",
61 "#include <stdlib.h>",
65 "#define YYLEX yylex()",
67 "#define yyclearin (yychar=(YYEMPTY))",
68 "#define yyerrok (yyerrflag=0)",
69 "#define YYRECOVERING() (yyerrflag!=0)",
70 "#if defined(__cplusplus) || __STDC__",
71 "static int yygrowstack(void);",
73 "static int yygrowstack();",
81 "extern const short yylhs[];",
82 "extern const short yylen[];",
83 "extern const short yydefred[];",
84 "extern const short yydgoto[];",
85 "extern const short yysindex[];",
86 "extern const short yyrindex[];",
87 "extern const short yygindex[];",
88 "extern const short yytable[];",
89 "extern const short yycheck[];",
91 "extern char *yyname[];",
92 "extern char *yyrule[];",
101 "#include <stdio.h>",
103 "#ifdef YYSTACKSIZE",
105 "#define YYMAXDEPTH YYSTACKSIZE",
108 "#define YYSTACKSIZE YYMAXDEPTH",
110 "#define YYSTACKSIZE 10000",
111 "#define YYMAXDEPTH 10000",
114 "#define YYINITSTACKSIZE 200",
133 "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
134 "static int yygrowstack()",
140 " if ((newsize = yystacksize) == 0)",
141 " newsize = YYINITSTACKSIZE;",
142 " else if (newsize >= YYMAXDEPTH)",
144 " else if ((newsize *= 2) > YYMAXDEPTH)",
145 " newsize = YYMAXDEPTH;",
146 " i = yyssp - yyss;",
147 " newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :",
148 " (short *)malloc(newsize * sizeof *newss);",
149 " if (newss == NULL)",
152 " yyssp = newss + i;",
153 " newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :",
154 " (YYSTYPE *)malloc(newsize * sizeof *newvs);",
155 " if (newvs == NULL)",
158 " yyvsp = newvs + i;",
159 " yystacksize = newsize;",
160 " yysslim = yyss + newsize - 1;",
164 "#define YYABORT goto yyabort",
165 "#define YYREJECT goto yyabort",
166 "#define YYACCEPT goto yyaccept",
167 "#define YYERROR goto yyerrlab",
169 "#ifndef YYPARSE_PARAM",
170 "#if defined(__cplusplus) || __STDC__",
171 "#define YYPARSE_PARAM_ARG void",
172 "#define YYPARSE_PARAM_DECL",
173 "#else /* ! ANSI-C/C++ */",
174 "#define YYPARSE_PARAM_ARG",
175 "#define YYPARSE_PARAM_DECL",
176 "#endif /* ANSI-C/C++ */",
177 "#else /* YYPARSE_PARAM */",
178 "#ifndef YYPARSE_PARAM_TYPE",
179 "#define YYPARSE_PARAM_TYPE void *",
181 "#if defined(__cplusplus) || __STDC__",
182 "#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM",
183 "#define YYPARSE_PARAM_DECL",
184 "#else /* ! ANSI-C/C++ */",
185 "#define YYPARSE_PARAM_ARG YYPARSE_PARAM",
186 "#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;",
187 "#endif /* ANSI-C/C++ */",
188 "#endif /* ! YYPARSE_PARAM */",
191 "yyparse (YYPARSE_PARAM_ARG)",
192 " YYPARSE_PARAM_DECL",
194 " register int yym, yyn, yystate;",
196 " register const char *yys;",
198 " if ((yys = getenv(\"YYDEBUG\")))",
201 " if (yyn >= '0' && yyn <= '9')",
202 " yydebug = yyn - '0';",
210 " if (yyss == NULL && yygrowstack()) goto yyoverflow;",
213 " *yyssp = yystate = 0;",
216 " if ((yyn = yydefred[yystate])) goto yyreduce;",
219 " if ((yychar = yylex()) < 0) yychar = 0;",
224 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
225 " if (!yys) yys = \"illegal-symbol\";",
226 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
227 " YYPREFIX, yystate, yychar, yys);",
231 " if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&",
232 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
236 " printf(\"%sdebug: state %d, shifting to state %d\\n\",",
237 " YYPREFIX, yystate, yytable[yyn]);",
239 " if (yyssp >= yysslim && yygrowstack())",
243 " *++yyssp = yystate = yytable[yyn];",
244 " *++yyvsp = yylval;",
246 " if (yyerrflag > 0) --yyerrflag;",
249 " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&",
250 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
252 " yyn = yytable[yyn];",
255 " if (yyerrflag) goto yyinrecovery;",
256 "#if defined(lint) || defined(__GNUC__)",
260 " yyerror(\"syntax error\");",
261 "#if defined(lint) || defined(__GNUC__)",
267 " if (yyerrflag < 3)",
272 " if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&",
273 " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
277 " printf(\"%sdebug: state %d, error recovery shifting\\",
278 " to state %d\\n\", YYPREFIX, *yyssp, yytable[yyn]);",
280 " if (yyssp >= yysslim && yygrowstack())",
284 " *++yyssp = yystate = yytable[yyn];",
285 " *++yyvsp = yylval;",
292 " printf(\"%sdebug: error recovery discarding state %d\
294 " YYPREFIX, *yyssp);",
296 " if (yyssp <= yyss) goto yyabort;",
304 " if (yychar == 0) goto yyabort;",
309 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
310 " if (!yys) yys = \"illegal-symbol\";",
311 " printf(\"%sdebug: state %d, error recovery discards token %d\
313 " YYPREFIX, yystate, yychar, yys);",
322 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",",
323 " YYPREFIX, yystate, yyn, yyrule[yyn]);",
325 " yym = yylen[yyn];",
326 " yyval = yyvsp[1-yym];",
337 " yystate = *yyssp;",
339 " yym = yylhs[yyn];",
340 " if (yystate == 0 && yym == 0)",
344 " printf(\"%sdebug: after reduction, shifting from state 0 to\\",
345 " state %d\\n\", YYPREFIX, YYFINAL);",
347 " yystate = YYFINAL;",
348 " *++yyssp = YYFINAL;",
349 " *++yyvsp = yyval;",
352 " if ((yychar = yylex()) < 0) yychar = 0;",
357 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
358 " if (!yys) yys = \"illegal-symbol\";",
359 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
360 " YYPREFIX, YYFINAL, yychar, yys);",
364 " if (yychar == 0) goto yyaccept;",
367 " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
368 " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)",
369 " yystate = yytable[yyn];",
371 " yystate = yydgoto[yym];",
374 " printf(\"%sdebug: after reduction, shifting from state %d \\",
375 "to state %d\\n\", YYPREFIX, *yyssp, yystate);",
377 " if (yyssp >= yysslim && yygrowstack())",
381 " *++yyssp = yystate;",
382 " *++yyvsp = yyval;",
385 " yyerror(\"yacc stack overflow\");",
396 write_section(section)
405 for (i = 0; (s = section[i]); ++i)