|YACCable C and C++ grammars; C++ scanner flex input file; yacc debugg jar@io.UUCP (1990-06-20)|
|From:||jar@io.UUCP (Jim Roskind x5570)|
|Date:||Wed, 20 Jun 90 04:19:58 GMT|
|Organization:||Interleaf Inc, Cambridge, MA|
|Keywords:||yacc, parse, C, C++|
The actual files were already posted (at least I tried) to comp.lang.c++.
Doug Lea and Doug Schmidtt have graciously offered to provide anonymous
ftp sites for the 6 files, as well as the Berkeley YACC source (if you
ics.uci.edu (188.8.131.52) in the ftp/pub directory as
c++-grammar.tar.Z and byacc.tar.Z
mach1.npac.syr.edu in the ftp/pub/C++ directory as cgrammar1.1.tar.Z
To summarize the contents of the files:
FREEGRM4.TXT An introductory file
GRAMMAR4.TXT Parsing ambiguities in C++, and in my grammar
CPP4.Y My YACC compatible C++ grammar
C4.Y My YACC compatible, ANSI C conformant grammar
CPP4.L Flex input file defining a C++ lexical analyzer
SKELGRPH.C A hacked file from the Berkeley YACC distribution.
Note that both of the grammar files avoid using %prec and %assoc, and
hence are brutally open in identifying complexities/ambiguities in the
languages. I believe the C grammar is very ANSI compliant, and have
made no changes (despite wide circulation) in the past 6 months. The
C grammar has exactly 1 shift/reduce conflict (if-if-else). The C++
grammar currently has 25 S/R conflicts, and 7 R/R conflicts. All of
these conflicts are part of equivalence classes that are carefully
documented in GRAMMAR.TXT.
The FLEX input file is bare bones, as it does not include a symbol
table. The bottom line is that it is good for experimenting, but the
user must distinguish between TYPEDEFname (or class name etc) and a
standard identifier (or undeclared identifier).
The enhancement to Berkeley YACC provides a YACC debugging mode that
prints a graphical parse tree during a parse. This enhancement can
be used with any grammar, but in the company of the grammar and flex
source that are provided in this package, a simple demonstration of
a parser based on the C++ grammar can be constructed (with no source
The *.TXT files provide history, and documentation. Specifically the
GRAMMAR4.TXT documents many of the complexities of the C++ grammar
that is provided.
...!uunet!leafusa!jar or email@example.com
Return to the
Search the comp.compilers archives again.