C++ and parser generators

Jan Peter de Ruiter <janpeter@mpi.kun.nl>
Fri, 4 Feb 1994 16:57:48 GMT

          From comp.compilers

Related articles
C++ and parser generators janpeter@mpi.kun.nl (Jan Peter de Ruiter) (1994-02-04)
Re: C++ parser generators, PCCTS parrt@s1.arc.umn.edu (Terence Parr) (1994-02-05)
Re: C++ and parser generators helz@ecn.purdue.edu (1994-02-06)
C++ and parser generators BBURSHTE@us.oracle.com (BBURSHTE.US.ORACLE.COM) (1994-02-07)
Muskox report available for FTP johnl@iecc.com (John Levine) (1994-02-10)
| List of all articles for this month |
Newsgroups: comp.compilers
From: Jan Peter de Ruiter <janpeter@mpi.kun.nl>
Keywords: C++, parse, tools, PCCTS
Organization: Compilers Central
Date: Fri, 4 Feb 1994 16:57:48 GMT

There are now I believe many people who want to have their parser
generators (and other code generators) to produce edible C++ output.


At first, I tried to use Alain Coetmeur's bison++/flex++, package, which is
a bison/flex that generates a parser class, and neat header files with it.


Although this is surely an improvement, there are still problems with
memory allocation. One problem is that a %union cannot handle classes with
constructors (because C++ does not want unions with constructors). One
could generate a struct instead, but then (according to Alain) you run
into other problems because the "%union" structs are allocated using C
heap routines. This will not work (i.e. usually crash) if your classes
happen to destroy themselves using delete.


Now I have an advice and a question. The advice (for people wanting to
build compilers in C++) is to have a look at the PCCTS system. It's not
only a *very good* parser generator, but it can be easily adapted to
generate C++ actions painlessly. Also, it gives you more control over the
construction / destruction of attributes. If you're interested, get the
archive by ftp from en.ecn.purdue.edu.


The question is this: To me it seems to be the case that C++ would be a
very convenient language to build a parser generator in. Using the strong
static typing of C++ and well organised data hiding principles it might
even be possible that such a parser generator had a certain didactical
value, in the sense that the LALR parser table algorithm could be
expressed in a highly readable way. So: is there somebody out there who is
working on yacc-like tools, written in and for C++?


Greetings,


Jan Peter de Ruiter
Max Planck Institute for Psycholinguistics
Nijmegen
The Netherlands
--


Post a followup to this message

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