Subject: Re: [boost] [spirit] semantic action for mismatches?
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2011-01-08 13:03:08
> > > I might give that a shot as I can't seem to get local variables to
> > > solve my problem. I would expect these two commands to have the same
> > > result (albeit unnecessarily assigning the _a variable, which just
> > > gets tossed away anyway), but apparently they are not?
> > >
> > > r = p[_a = _1]
> > > r = p
> > Automatic attribute propagation from the rhs expression to the lhs
> > rule is disabled as soon as semantic actions are involved. If you want
> > to enforce attribute propagation anyways, write:
> > rule<...> r;
> > r %= p[...];
> > If the rhs has no semantic actions attached, operator=() behaves
> > exactly like operator%=().
> That does the trick. Apologies for the previous top-post. I've been out of
> the mailing list game for a while now =)
> This style ended up working and I can finally move on to other things:
> r %= p1[_a = _1] >> ('*' | (eps[bind(&class::undo, &instance, _a)] >>
> >> p2
FWIW, this should do the same, but simpler:
r %= p1[_a = _1] >> ('*' | !eps[bind(&class::undo, &instance, _a)]) >>