YACCable C and C++ grammars; C++ scanner flex input file; yacc debugging tool.

jar@io.UUCP (Jim Roskind x5570)
Wed, 20 Jun 90 04:19:58 GMT

          From comp.compilers

Related articles
YACCable C and C++ grammars; C++ scanner flex input file; yacc debugg jar@io.UUCP (1990-06-20)
| List of all articles for this month |
Newsgroups: comp.lang.c++,comp.lang.c,comp.compilers
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
need it).


ics.uci.edu (128.195.1.1) 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
and byacc.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
code modifications).


The *.TXT files provide history, and documentation. Specifically the
GRAMMAR4.TXT documents many of the complexities of the C++ grammar
that is provided.




Jim Roskind
Independent Consultant
...!uunet!leafusa!jar or jar@ileaf.com
(407)729-4348
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.