help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bison with C++


From: John Clinton
Subject: Bison with C++
Date: Sat, 18 Jan 2003 12:16:28 +0100

Hans,

I've been working to use the Bison version 1.875 to create
a new parser as a C++ class.  I've been tweaking the lalr1.cc
skeleton to try to accomplish my goals.  I thought I'd share
these goals and see if you've been heading in a similar
direction.  Then depending on my success I can soon share
what I've accomplished.

My primary goal is to have Bison generate a base class
for the parser.  Then I will derive my own class from this
base.  My derived class adds all the application specific
methods and data members.  One of my tweaks to the
skeleton was to have the "int parse()" function be defined
as a member of the derived class even though all the
rest of the Bison generated code is part of the base
class.  This permits my parsers reduction action code to
use the methods and data in the derived class.

Now my main issue is cleanly resolving the circular
dependencies of the parser base and derived class'
header files.

I happen to also be using Flex to generate a class for
the scanner.  I chose to make the scanner be a nested class
of the parser.  The derived parser class has an instance
of this scanner and takes care of setting up the scanner so
that any client of the parser merely gives a stream object
to the parser and knows nothing of the scanner details.

Another issue I have is some of the #define in the generated
parser's header file that may be an issue if having multiple
parser header files included from one module (.cpp file).

If you have some ideas on other approaches and/or any solutions
I'd appreciate hearing.

Thanks,

--John
address@hidden






reply via email to

[Prev in Thread] Current Thread [Next in Thread]