bug-bison
[Top][All Lists]
Advanced

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

Re: Action blocks may not refer to their own value with number


From: akim
Subject: Re: Action blocks may not refer to their own value with number
Date: Sat, 19 Oct 2002 16:40:40 +0200
User-agent: Mutt/1.3.28i

On Sat, Oct 19, 2002 at 03:16:15PM +0200, Henrik Grubbstr?m wrote:
> On Sat, 19 Oct 2002, address@hidden wrote:
> 
> > On Sat, Oct 19, 2002 at 12:29:02PM +0200, Henrik Grubbstr?m wrote:
> > > Found another bug when backporting bison 1.50 kludges:
> > > 
> > > In bison 1.50 and 1.75 the following construct is no longer accepted:
> > > 
> > > %union{
> > >   int field;
> > > %}
> > > 
> > > %type <field> nonterm
> > > 
> > > %%
> > > 
> > > nonterm: { $<field>1 = 0; } ;
> > > 
> > > %%
> > > 
> > > The following error is produced:
> > > 
> > > foo.yacc:9.10-20: invalid value: $1
> > > 
> > > It works fine in bison 1.35.
> > > 
> > > The obvious workaround is to refer to the value with $$.
> > 
> > I disagree: this is the obvious fix to the action.  I hope you never
> > relied on this code, coz you can be sure it was never properly honored.
> > Not even by pre 1.50, they were just buggy and unable to report the error.
> 
> True, my example was a bit short; in the code where I encountered the
> problem the use was for clarity.
> 
> nonterm: TERM { $<field>2 = val; } more stuff
>          { $<field>5 = val2; } even more stuff
>        { $$ = funcall($<field>2, $<field>5); }

I'm not sure what I should understand here: this example does not work either.
As soon that the first action was executed, its $$ (which is left unspecified
by your action) overwrites it.  An action can never refer to its slot via
$n: it makes no difference that it's mid-rule or not.




reply via email to

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