#!/usr/bin/perl -w
# mung the output of yacc so it uses PerTask values instead of static.
# clean up a few other nits along the way.

$sub = 0;
while (<>) {
    if (/^#ifndef YYSTYPE/) {
	# start substituting text now
	$sub = 1;
    } 
    if (/^#define yystacksize YYSTACKSIZE/) {
	# replace it with this, then go back to copying
print <<'xEOFx1';
#define yynerrs         pti.yyp.yynerrs
#define yyerrflag       pti.yyp.yyerrflag
#define yychar          pti.yyp.yychar
#define yyssp           pti.yyp.yyssp
#define yyvsp           pti.yyp.yyvsp
#define yyval           pti.yyp.yyval
#define yylval          pti.yyp.yylval
#define yyss            pti.yyp.yyss
#define yyvs            pti.yyp.yyvs
#define maxnyyvs	pti.yyp.maxnyyvs
void maxnyys(void) { int n = yyvsp - yyvs; if (n > maxnyyvs) maxnyyvs = n; }
xEOFx1
	$sub = 0;
    }

    # pick up a few other little changes
    if (!$sub) {
	if (/\+\+yyvsp/) { print; print "maxnyys();\n"; }
	elsif (/^yyparse/) { print "yyparse(void)\n"; }
	elsif (! /yysccsid/) { print };
    }
}

# For RCS Only -- Do Not Edit
# @(#) $RCSfile: yymung,v $ $Date: 2003/04/15 20:46:54 $ $Revision: 1.1.1.1 $ $Name:  $
