bug-bison
[Top][All Lists]
Advanced

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

Re: Bison C++ mid-rule value lost with variants


From: Kaz Kylheku
Subject: Re: Bison C++ mid-rule value lost with variants
Date: Thu, 29 Jun 2017 11:07:50 -0700
User-agent: Roundcube Webmail/0.9.2

On 29.06.2017 06:55, Piotr Marcińczyk wrote:
I supposedly found a bug in lalr1.cc skeleton with variant semantic type.
When using mid-rule action { $<type>$ = value; } to return a value that
will be used in further semantic actions, it appears that the value on
stack becomes zero. Tested with Bison version 3.0.4.

You probably need your code to work with Bison installations
that don't have a fix for this (which is all of them, currently,
except maybe yours).

Could the workaround be as simple as:

   /* plain old local variable, injected into yyparse */

   { int whatever = 42; } + NUM { std::cout << whatever << std::endl; }

Also, you can have a scratch space in your parser structure
for carrying a value from one mid-rule action to another.

   /* assumes %parse-param{your_parser_type *parser} */

{ parser->stash = 42; } + NUM { std::cout << parser->stash << std::endl: }

I've done this latter sort of of thing.

The parser structure is basically your "this" object in the entire
parse job, and yyparse is its "method". :)

Cheers ...




reply via email to

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