[comp.lang.perl] YACC-generated parsers in Perl

lisch@lisch.mentor.com (Ray Lischner) (08/22/90)

There was a brief discussion earlier of the difficulties in
writing a recursive descent parser in Perl.  Now, your troubles
are over!  I modified Corbett's Berkeley YACC to produce Perl
as well as C.  Perl is, of course, not as fast as C, and this
is particularly noticable for large grammars, such as that of C++,
but it can be very useful for prototyping a grammar.

As a test, I tried the YACC-able C++ grammar, written by
James A. Roskind, that was posted a short while ago. I wrote a lexer
in Perl to go with it.  It works, but slowly.  Undumping helps the
initialization time, but I end up with a 3.3 Mbyte executable
because of the huge YACC arrays.  The debug information takes up
only 0.2Mbytes of that.

I have diffs for the latest version of byacc (obtainable from osu-cis,
and probably elsewhere).  They are about 50Kbytes uncompressed, and
32Kbytes compressed & uuencoded.  Included is a simple calculator, as
an example.

Mail a request to mntgfx!lisch for your very own copy.
-- 
Ray Lischner        UUCP: {uunet,apollo,decwrl}!mntgfx!lisch

lisch@dad.mentor.com (Ray Lischner) (08/22/90)

There was a brief discussion earlier of the difficulties in
writing a recursive descent parser in Perl.  Now, your troubles
are over!  I modified Corbett's Berkeley YACC to produce Perl
as well as C.  Perl is, of course, not as fast as C, and this
is particularly noticable for large grammars, such as that of C++,
but it can be very useful for prototyping a grammar.

As a test, I tried the YACC-able C++ grammar, written by
James A. Roskind, that was posted a short while ago. I wrote a lexer
in Perl to go with it.  It works, but slowly.  Undumping helps the
initialization time, but I end up with a 3.3 Mbyte executable
because of the huge YACC arrays.  The debug information takes up
only 0.2Mbytes of that.

I have diffs for the latest version of byacc (obtainable from osu-cis,
and probably elsewhere).  They are about 50Kbytes uncompressed, and
32Kbytes compressed & uuencoded.  Included is a simple calculator, as
an example.

Mail a request to mntgfx!lisch for your very own copy.
--
Ray Lischner        UUCP: {uunet,apollo,decwrl}!mntgfx!lisch