|
Boost : |
Subject: Re: [boost] [spirit] semantic action for mismatches?
From: caustik (caustik_at_[hidden])
Date: 2011-01-08 12:39:38
On Sat, Jan 8, 2011 at 9:19 AM, Hartmut Kaiser <hartmut.kaiser_at_[hidden]>wrote:
> > 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)] >> !eps))
>> p2
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk