diff options
author | steve <steve@FreeBSD.org> | 1997-01-06 03:03:46 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1997-01-06 03:03:46 +0000 |
commit | beac0fa7593b2de5358a5252676047537756a233 (patch) | |
tree | 5017c296eec0d37ebc757fce6f7bac60a4ac9ece /usr.bin | |
parent | e59ddf16290f36ba8e70c9729c7abedd9a52c11e (diff) | |
download | FreeBSD-src-beac0fa7593b2de5358a5252676047537756a233.zip FreeBSD-src-beac0fa7593b2de5358a5252676047537756a233.tar.gz |
Import of Lite2 version.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/yacc/skeleton.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/usr.bin/yacc/skeleton.c b/usr.bin/yacc/skeleton.c index 1e51b2e..7de5599 100644 --- a/usr.bin/yacc/skeleton.c +++ b/usr.bin/yacc/skeleton.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)skeleton.c 5.7 (Berkeley) 5/24/93"; +static char sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95"; #endif /* not lint */ #include "defs.h" @@ -57,6 +57,7 @@ char *banner[] = "#ifndef lint", "static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";", "#endif", + "#include <stdlib.h>", "#define YYBYACC 1", "#define YYMAJOR 1", "#define YYMINOR 9", @@ -95,10 +96,11 @@ char *header[] = "#ifdef YYMAXDEPTH", "#define YYSTACKSIZE YYMAXDEPTH", "#else", - "#define YYSTACKSIZE 500", - "#define YYMAXDEPTH 500", + "#define YYSTACKSIZE 10000", + "#define YYMAXDEPTH 10000", "#endif", "#endif", + "#define YYINITSTACKSIZE 200", "int yydebug;", "int yynerrs;", "int yyerrflag;", @@ -107,15 +109,43 @@ char *header[] = "YYSTYPE *yyvsp;", "YYSTYPE yyval;", "YYSTYPE yylval;", - "short yyss[YYSTACKSIZE];", - "YYSTYPE yyvs[YYSTACKSIZE];", - "#define yystacksize YYSTACKSIZE", + "short *yyss;", + "short *yysslim;", + "YYSTYPE *yyvs;", + "int yystacksize;", 0 }; char *body[] = { + "/* allocate initial stack or double stack size, up to YYMAXDEPTH */", + "static int yygrowstack()", + "{", + " int newsize, i;", + " short *newss;", + " YYSTYPE *newvs;", + "", + " if ((newsize = yystacksize) == 0)", + " newsize = YYINITSTACKSIZE;", + " else if (newsize >= YYMAXDEPTH)", + " return -1;", + " else if ((newsize *= 2) > YYMAXDEPTH)", + " newsize = YYMAXDEPTH;", + " i = yyssp - yyss;", + " if ((newss = realloc(yyss, newsize * sizeof *newss)) == NULL)", + " return -1;", + " yyss = newss;", + " yyssp = newss + i;", + " if ((newvs = realloc(yyvs, newsize * sizeof *newvs)) == NULL)", + " return -1;", + " yyvs = newvs;", + " yyvsp = newvs + i;", + " yystacksize = newsize;", + " yysslim = yyss + newsize - 1;", + " return 0;", + "}", + "", "#define YYABORT goto yyabort", "#define YYREJECT goto yyabort", "#define YYACCEPT goto yyaccept", @@ -140,6 +170,7 @@ char *body[] = " yyerrflag = 0;", " yychar = (-1);", "", + " if (yyss == NULL && yygrowstack()) goto yyoverflow;", " yyssp = yyss;", " yyvsp = yyvs;", " *yyssp = yystate = 0;", @@ -168,7 +199,7 @@ char *body[] = " printf(\"%sdebug: state %d, shifting to state %d\\n\",", " YYPREFIX, yystate, yytable[yyn]);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", @@ -209,7 +240,7 @@ char *body[] = " printf(\"%sdebug: state %d, error recovery shifting\\", " to state %d\\n\", YYPREFIX, *yyssp, yytable[yyn]);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", @@ -306,7 +337,7 @@ char *trailer[] = " printf(\"%sdebug: after reduction, shifting from state %d \\", "to state %d\\n\", YYPREFIX, *yyssp, yystate);", "#endif", - " if (yyssp >= yyss + yystacksize - 1)", + " if (yyssp >= yysslim && yygrowstack())", " {", " goto yyoverflow;", " }", |