[comp.lang.c++] YACCable grammars available for C++ and C

schmidt@crimee.ics.uci.edu (Doug Schmidt) (03/10/90)

This was posted for Jim Roskind (jar@ileaf.com) because his news
posting facilities were not delivering outgoings messages consistently:

I (Jim) have written a pair of YACC able grammars for C++ and C, and
posted them to the net (or at least tried).  The posting consists of 4
items, including the 2 grammars, a paper on the ambiguities in the C++
syntax, and an introductory letter.  Since these items total 160K of
text, I am reluctant to "re-post" until I am sure that the first
posting has fallen into the bit bucket.  In the mean time, Doug Lea
and Doug Schmidt have graciously offer to provide anonymous ftp
sites for these 4 files.

Note that the grammars are VERY clean, and make no use of the YACC
%prec and %assoc constructs.  The C++ grammar also supports old style
function definitions (a feat that no other parser I am aware of
offers).  The associated paper identifies a number of fundamental
ambiguities in C++ that have not received public exposure (read: they
represent buggy areas of all existing compilers and translators that I
know of).  The grammars have copyrights that should allow for their
use in any commercial or non-commercial releases, and there are no
fees involved with their use (nor are these items copylefted).

The files can be obtained from:

ics.uci.edu (128.195.1.1) in the ftp/pub directory as
c++-grammar.1.0.tar.Z.

c++gram.tar.Z, holding them all available for anonymous ftp at
mach1.npac.syr.edu:~ftp/pub/C++ and labrea.stanford.edu:~ftp/pub

Jim Roskind
jar@ileaf.com

--
facilis descensus avernus
----------------------------------------
schmidt@ics.uci.edu (ARPA)
office: (714) 856-4043

shap@delrey.sgi.com (Jonathan Shapiro) (03/12/90)

In article <25F844F7.28923@paris.ics.uci.edu> schmidt@crimee.ics.uci.edu (Doug Schmidt) writes:
>
>Jim Roskind
>jar@ileaf.com
>
>--
>facilis descensus avernus
>----------------------------------------
>schmidt@ics.uci.edu (ARPA)
>office: (714) 856-4043

Jim, I think your grammar is terrific.  I, too, would be interested in
getting a PD lexer to go along with it if you know of one - there are
lots of tools that could be built from this basis.  If one doesn't
show up in the next day or so, however, perhaps I'll just post the one
I've been building here.

I also want to report a bug in both grammars (or rather, an
oversight): they don't accept the empty file, which should be legal.
In my copy, I fixed this by changing

    prog.start:
	    translation.unit
	    ;

to

    prog.start:
	    |
	    translation.unit
	    ;

Doing it in translation.unit led to shift-reduce errors.


Jonathan Shapiro
Silicon Graphics, Inc.