help-bison
[Top][All Lists]
Advanced

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

Re: Token types with constructor


From: Hans Aberg
Subject: Re: Token types with constructor
Date: Fri, 3 Sep 2004 19:20:46 +0200

At 11:35 +0200 2004/09/03, Akim Demaille wrote:
>>>> "Martin" == Martin Trautmann <address@hidden> writes:
>
> > According to your opinion this two defines should be inserted in the
> > official version of yacc.c?
>
>No.  No further efforts will be made to have C++ fit into a C parser.
>C has its own constraints, incompatible with C++'s.

And I can add that this was discussed for quite some time in the Bug-Bison
list, until we finally realized that it was rather hopeless to develop a
decent C parser and at the same time have an eye on a proper C++-compile
option.

> > So may I summon the currently discussed possibilities to use bison in a
> > C++ Framework:
> > 1) Use a real C++ skeleton (Hans: how can one specify a user defined
> > skeleton in bison?)
>
>Well, did you try Bison's C++ parser?  There's work to do, but I've
>been using it for years.

I recall that I was not able to get it working, so wrote my own.

One other problem is though, that under C++, one can put code in several
more places. And it should be properly synced with Flex. I order to control
that properly from the .y file, I would need a %code <name> option (see my
other email to the list).

>Nevertheless, it is still based on unions so
>you will have the same problem.  Because the problem is in the
>language, not in Bison.

I experimented with a %type option, that allowed me to use something else
than a union for implementation. Exactly what will depend on the chosen C++
setup (static/dynamic), but can easily changed nowadays with the M4
approach by altering the skeleton file.

>You should runaway from yacc.c.  Or once for all accept that you have
>to handle pointers for C++ classes.

Take a look at the example posted by Wolfgang Wieser, which might be
combined with the stack handler that Martin Trautmann found, not as a
standard C++ setup, but as a quick fix. It might be working with
con-/de-structors/assignments under C++. It might be useful, if one wants
to experiment with say the GLR parser under C++.

  Hans Aberg






reply via email to

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