386BSD 0.1 development
[unix-history] / usr / src / usr.bin / yacc / skeleton.c
index f3729d9..bccdfc9 100644 (file)
@@ -5,28 +5,43 @@
  * This code is derived from software contributed to Berkeley by
  * Robert Paul Corbett.
  *
  * This code is derived from software contributed to Berkeley by
  * Robert Paul Corbett.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 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
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)skeleton.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)skeleton.c 5.6 (Berkeley) 1/27/91";
 #endif /* not lint */
 
 #include "defs.h"
 
 #endif /* not lint */
 
 #include "defs.h"
 
-/*  The three line banner used here should be replaced with a one line */
-/*  #ident directive if the target C compiler supports #ident          */
-/*  directives.                                                                */
+/*  The banner used here should be replaced with an #ident directive   */
+/*  if the target C compiler supports #ident directives.               */
 /*                                                                     */
 /*  If the skeleton is changed, the banner should be changed so that   */
 /*  the altered version can easily be distinguished from the original. */
 /*                                                                     */
 /*  If the skeleton is changed, the banner should be changed so that   */
 /*  the altered version can easily be distinguished from the original. */
@@ -34,7 +49,27 @@ static char sccsid[] = "@(#)skeleton.c       5.3 (Berkeley) %G%";
 char *banner[] =
 {
     "#ifndef lint",
 char *banner[] =
 {
     "#ifndef lint",
-    "char yysccsid[] = \"@(#)yaccpar   1.1 (Berkeley) 12/10/89\";",
+    "static char yysccsid[] = \"@(#)yaccpar    1.8 (Berkeley) 01/20/90\";",
+    "#endif",
+    "#define YYBYACC 1",
+    0
+};
+
+
+char *tables[] =
+{
+    "extern short yylhs[];",
+    "extern short yylen[];",
+    "extern short yydefred[];",
+    "extern short yydgoto[];",
+    "extern short yysindex[];",
+    "extern short yyrindex[];",
+    "extern short yygindex[];",
+    "extern short yytable[];",
+    "extern short yycheck[];",
+    "#if YYDEBUG",
+    "extern char *yyname[];",
+    "extern char *yyrule[];",
     "#endif",
     0
 };
     "#endif",
     0
 };
@@ -44,11 +79,16 @@ char *header[] =
 {
     "#define yyclearin (yychar=(-1))",
     "#define yyerrok (yyerrflag=0)",
 {
     "#define yyclearin (yychar=(-1))",
     "#define yyerrok (yyerrflag=0)",
-    "#ifndef YYSTACKSIZE",
+    "#ifdef YYSTACKSIZE",
+    "#ifndef YYMAXDEPTH",
+    "#define YYMAXDEPTH YYSTACKSIZE",
+    "#endif",
+    "#else",
     "#ifdef YYMAXDEPTH",
     "#define YYSTACKSIZE YYMAXDEPTH",
     "#else",
     "#ifdef YYMAXDEPTH",
     "#define YYSTACKSIZE YYMAXDEPTH",
     "#else",
-    "#define YYSTACKSIZE 300",
+    "#define YYSTACKSIZE 500",
+    "#define YYMAXDEPTH 500",
     "#endif",
     "#endif",
     "int yydebug;",
     "#endif",
     "#endif",
     "int yydebug;",
@@ -59,9 +99,9 @@ char *header[] =
     "YYSTYPE *yyvsp;",
     "YYSTYPE yyval;",
     "YYSTYPE yylval;",
     "YYSTYPE *yyvsp;",
     "YYSTYPE yyval;",
     "YYSTYPE yylval;",
-    "#define yystacksize YYSTACKSIZE",
     "short yyss[YYSTACKSIZE];",
     "YYSTYPE yyvs[YYSTACKSIZE];",
     "short yyss[YYSTACKSIZE];",
     "YYSTYPE yyvs[YYSTACKSIZE];",
+    "#define yystacksize YYSTACKSIZE",
     0
 };
 
     0
 };
 
@@ -222,7 +262,7 @@ char *trailer[] =
     "    yym = yylhs[yyn];",
     "    if (yystate == 0 && yym == 0)",
     "    {",
     "    yym = yylhs[yyn];",
     "    if (yystate == 0 && yym == 0)",
     "    {",
-    "#ifdef YYDEBUG",
+    "#if YYDEBUG",
     "        if (yydebug)",
     "            printf(\"yydebug: after reduction, shifting from state 0 to\\",
     " state %d\\n\", YYFINAL);",
     "        if (yydebug)",
     "            printf(\"yydebug: after reduction, shifting from state 0 to\\",
     " state %d\\n\", YYFINAL);",
@@ -252,7 +292,7 @@ char *trailer[] =
     "        yystate = yytable[yyn];",
     "    else",
     "        yystate = yydgoto[yym];",
     "        yystate = yytable[yyn];",
     "    else",
     "        yystate = yydgoto[yym];",
-    "#ifdef YYDEBUG",
+    "#if YYDEBUG",
     "    if (yydebug)",
     "        printf(\"yydebug: after reduction, shifting from state %d \\",
     "to state %d\\n\", *yyssp, yystate);",
     "    if (yydebug)",
     "        printf(\"yydebug: after reduction, shifting from state %d \\",
     "to state %d\\n\", *yyssp, yystate);",
@@ -279,10 +319,12 @@ write_section(section)
 char *section[];
 {
     register int i;
 char *section[];
 {
     register int i;
+    register FILE *fp;
 
 
+    fp = code_file;
     for (i = 0; section[i]; ++i)
     {
        ++outline;
     for (i = 0; section[i]; ++i)
     {
        ++outline;
-       fprintf(output_file, "%s\n", section[i]);
+       fprintf(fp, "%s\n", section[i]);
     }
 }
     }
 }