Perl on Xenix (yaccing perl.y)

Nick Crossley nick at ccicpg.UUCP
Tue Jul 26 10:26:25 AEST 1988


In article <2320 at sugar.uu.net> peter at sugar.uu.net (Peter da Silva) writes:
>Well, I tried building perl on Xenix 3.5, and I can't get perl.y/perl.c
>to compile. I finally yacced it on a 68000 system, but the resulting
>'c' source won't compile: the compiler runs out of heap space near
>the beginning of the big actions switch in the yacc output. Has anyone
>gotten perl to compile on Xenix 286 3.5?
>-- 
>		Peter da Silva  `-_-'  peter at sugar.uu.net
> 		 Have you hugged  U  your wolf today?

Have you tried editing the output of yacc to split the single case statement
into several smaller ones?  I have had to do this on some systems where cc
could not handle switches with more than, say, 255 cases.

I have the following two shell scripts which may be of use/interest.  They
are dependent on the format of the y.tab.c skeleton and y.output, respectively,
so might need some tailoring to other systems.


----------------------  Script 1  -------------------------------------
: '	This Shell script separates the output of YACC (y.tab.c)
	into two files, parse.c and parstab.c

	parse.c holds the actual parser code, including all the
	reduction actions.

	parstab.c holds only the parsing tables, and no code.
	This file is compiled into assembler, and the result is
	edited to change any data directives into text directives,
	so the pure parsing tables may be placed in shared code.
'

awk <y.tab.c >parse.c -e '
/yytabelem/		{  if (state==0)
			   {
				print ""
				print "/*  Tables removed here ...  */"
				print ""
				state=1
			   }
			}
/yaccpar	1.9/	{  print ""
			   print "extern yytabelem yyexca[], yyact[];"
			   print "extern yytabelem yypact[], yypgo[];"
			   print "extern yytabelem yyr1[], yyr2[];"
			   print "extern yytabelem yychk[], yydef[];"
			   print "extern yytoktype yytoks[];"
			   print "extern char * yyreds[];"
			   print ""
			   print "/*  ... End of table removal  */"
			   state=2
			}
/^typedef/		{  if (state==1) print  }
/^#/			{  if (state==1) print  }
			{  if (state==1) print >"parstab.c"  }

#  Next action and END are only needed for Portable C Compiler
#  as that cannot take more than about 200 case labels in
#  one switch.
#  The Green Hills Compiler does not need this (but it does
#  no harm to leave it, and it might speed compilation).

/^case/			{  x++;  y++
			   if	(y == 200)
			   {
				y=0
				z=z+1
				printf "default: goto fred%d; }\n",z
				printf "goto yystack;\n"
				printf "fred%d: switch(yytmp) {\n",z;
			   }
			}
			{  if  (state != 1)  print  }
END			{  printf "/* count of cases %d */\n", x  }'
-----------------------------------------------------------------------

----------------------  Script 2  -------------------------------------
: '	This script uses awk to extract interesting lines from
	the yacc listing file y.output.
'

awk '
BEGIN			{ state = 0; }
/^state/		{ --state; }
/shift\/reduce/		{ state = 2; }
/reduce\/reduce/	{ state = 2; }
/^Rule not/		{ state = 2; }
/terminals,/		{ state = 2; }
			{ if (state > 0) print }
' y.output >yacclist
-----------------------------------------------------------------------

-- 

<<< standard disclaimers >>>
Nick Crossley, CCI, 9801 Muirlands, Irvine, CA 92718-2521, USA
Tel. (714) 458-7282,  uucp: ...!uunet!ccicpg!nick



More information about the Comp.sources.bugs mailing list