bug-bison
[Top][All Lists]
Advanced

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

Re: Bison 1.30f broke my C++ parser


From: Hans Aberg
Subject: Re: Bison 1.30f broke my C++ parser
Date: Sun, 27 Jan 2002 12:18:39 +0100

At 11:40 +0100 2002/01/27, Akim Demaille wrote:
>...  We are close to have
>a functional beta of our C++ parsers, stay tuned.

The relatively minor changes I had to do (which took me only a few days to
do) was to first introduce macros to write out the $n values in the actions:
  YYVAL(x) = A reference to the $$ semantic value.
  YYVSP(x, n, rule_length) = A reference to the $n semantic value

Then, for use with Bison's type system, union's will not work with C++
types having non-trivial constructors, so introduce a macro to apply:
  YYCAST(x, cast_name) = Cast the a semantic value reference using cast_name.
In C, cast_name is a union field, but under the C++ polymorphy I use, it is
a type name.

Finally, bison.simple uses separate state/semantic/location stacks. In
order to be able t merge them into a single one, I had to introduce a macro
  YYLOC(x) = A reference to the location value.
When using a single stack, YYVAL and YYLOC would select different fields in
the stack objects.

This is really only what was needed. But since %union is not so useful
under C++, I made a %typed option. Also, I moved some stuff out from Bison
into the skeleton file, such as the "switch". -- Carrying this on would
start to prepare for output in other languages. Then it looks that keeping
the deprecated semantic parse would be a hurdle, so I think it's time to
remove it.

  Hans Aberg





reply via email to

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