-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Paul Corbett.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)output.c 5.6 (Berkeley) 1/20/91";
-#endif /* not lint */
-
#include "defs.h"
static int nvectors;
free_itemsets();
free_shifts();
free_reductions();
+ output_prefix();
output_stored_text();
output_defines();
output_rule_data();
}
+output_prefix()
+{
+ if (symbol_prefix == NULL)
+ symbol_prefix = "yy";
+ else
+ {
+ ++outline;
+ fprintf(code_file, "#define yyparse %sparse\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yylex %slex\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyerror %serror\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yychar %schar\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyval %sval\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yylval %slval\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yydebug %sdebug\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yynerrs %snerrs\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyerrflag %serrflag\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyss %sss\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyssp %sssp\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyvs %svs\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyvsp %svsp\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yylhs %slhs\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yylen %slen\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yydefred %sdefred\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yydgoto %sdgoto\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yysindex %ssindex\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyrindex %srindex\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yygindex %sgindex\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yytable %stable\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yycheck %scheck\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyname %sname\n", symbol_prefix);
+ ++outline;
+ fprintf(code_file, "#define yyrule %srule\n", symbol_prefix);
+ }
+ ++outline;
+ fprintf(code_file, "#define YYPREFIX \"%s\"\n", symbol_prefix);
+}
+
+
output_rule_data()
{
register int i;
register int j;
- fprintf(output_file, "short yylhs[] = {%42d,",
+ fprintf(output_file, "short %slhs[] = {%42d,", symbol_prefix,
symbol_value[start_symbol]);
j = 10;
if (!rflag) outline += 2;
fprintf(output_file, "\n};\n");
- fprintf(output_file, "short yylen[] = {%42d,", 2);
+ fprintf(output_file, "short %slen[] = {%42d,", symbol_prefix, 2);
j = 10;
for (i = 3; i < nrules; i++)
{
register int i, j;
- fprintf(output_file, "short yydefred[] = {%39d,",
+ fprintf(output_file, "short %sdefred[] = {%39d,", symbol_prefix,
(defred[0] ? defred[0] - 2 : 0));
j = 10;
state_count = NEW2(nstates, short);
k = default_goto(start_symbol + 1);
- fprintf(output_file, "short yydgoto[] = {%40d,", k);
+ fprintf(output_file, "short %sdgoto[] = {%40d,", symbol_prefix, k);
save_column(start_symbol + 1, k);
j = 10;
{
register int i, j;
- fprintf(output_file, "short yysindex[] = {%39d,", base[0]);
+ fprintf(output_file, "short %ssindex[] = {%39d,", symbol_prefix, base[0]);
j = 10;
for (i = 1; i < nstates; i++)
}
if (!rflag) outline += 2;
- fprintf(output_file, "\n};\nshort yyrindex[] = {%39d,",
+ fprintf(output_file, "\n};\nshort %srindex[] = {%39d,", symbol_prefix,
base[nstates]);
j = 10;
}
if (!rflag) outline += 2;
- fprintf(output_file, "\n};\nshort yygindex[] = {%39d,",
+ fprintf(output_file, "\n};\nshort %sgindex[] = {%39d,", symbol_prefix,
base[2*nstates]);
j = 10;
++outline;
fprintf(code_file, "#define YYTABLESIZE %d\n", high);
- fprintf(output_file, "short yytable[] = {%40d,", table[0]);
+ fprintf(output_file, "short %stable[] = {%40d,", symbol_prefix,
+ table[0]);
j = 10;
for (i = 1; i <= high; i++)
register int i;
register int j;
- fprintf(output_file, "short yycheck[] = {%40d,", check[0]);
+ fprintf(output_file, "short %scheck[] = {%40d,", symbol_prefix,
+ check[0]);
j = 10;
for (i = 1; i <= high; i++)
if (union_file == NULL) open_error(union_file_name);
while ((c = getc(union_file)) != EOF)
putc(c, defines_file);
- fprintf(defines_file, " YYSTYPE;\nextern YYSTYPE yylval;\n");
+ fprintf(defines_file, " YYSTYPE;\nextern YYSTYPE %slval;\n",
+ symbol_prefix);
}
}
symnam[0] = "end-of-file";
if (!rflag) ++outline;
- fprintf(output_file, "#if YYDEBUG\nchar *yyname[] = {");
+ fprintf(output_file, "#if YYDEBUG\nchar *%sname[] = {", symbol_prefix);
j = 80;
for (i = 0; i <= max; ++i)
{
FREE(symnam);
if (!rflag) ++outline;
- fprintf(output_file, "char *yyrule[] = {\n");
+ fprintf(output_file, "char *%srule[] = {\n", symbol_prefix);
for (i = 2; i < nrules; ++i)
{
fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]);