Boost logo

Boost :

Subject: Re: [boost] [Spirit/Qi] Sequential-or attribute access in semantic action
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-12-13 17:24:47


> >> This lead me on to the following, rather pedantic, musing on the
> >> provision of the identity[] directive in the core library to
> 'flatten'
> >> composed attributes.
> >> [snip]
> >> I wondered if providing
> >> identity[] for situations like these may result in more logical user
> >> code.
> >
> > That sounds good to me. Would you be willing to contribute the
> > identity[] directive? In this case we would need some docs, tests,
> > and an example or two as well.
> >
> Yes no problem. The implementation was attached to my original mail
> but when I get the time I will have a look at adding some
> docs/tests/example also. I've been meaning to learn QuickBook for
> some time -- this may be just the excuse.

I was thinking more about your identity[] component and I realized that we
actually don't need it. Spirit already has the special placeholder
spirit::_0 which refers to the whole attribute of the expression the
semantic action is attached to. So your code could be rewritten as:

      idxspec = '[' >> (start || (':' >> -start))
                    _val = access_index (_r1, lvalue, _0)
>> ']';

where _0 refers to the whole tuple<optional<S>, optional<optional<S>>>.

Sorry for not remembering this earlier...

Regards Hartmut

Meet me at BoostCon

Boost list run by bdawes at, gregod at, cpdaniel at, john at