|
Boost : |
Subject: Re: [boost] Help with boost spirit
From: Theodore Papadopoulo (Theodore.Papadopoulo_at_[hidden])
Date: 2014-10-22 05:00:50
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/14/2014 03:32 PM, TONGARI J wrote:
> 2014-10-14 20:44 GMT+08:00 Theodore Papadopoulo <
> Theodore.Papadopoulo_at_[hidden]>:
>
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>> But I cannot figure out the right way of doing this. The
>> natural:
>>
>> const bool result = boost::spirit::qi::parse(it,str.end(),int_
>> >> repeat(_1)[ char_ ]);
>>
>> fails to compile (and I tried many variations of val, etc) with
>> no success. If I replace _1 by 10, everything works fine.
>>
>
> _1 doesn't makes sense here, it's only for use in semantic action,
> e.g. `int_[_a = _1]`.
Ah OK. I did not realize that. Maybe it should be better explained in
the documentation. On the other hand, it would be nice if it had
worked.... less surprising.
> Another question is that of the associated attribute. From the
>> documentation, I would have expected it to be:
>>
>> typedef std::pair<int,std::vector<unsigned char>> Attribute;
>>
>> but that does not work. I have managed to work around this using
>> a second rule, using an attribute std::vector<char>(int) but then
>> again I do not know how to pass the parameter. 10 works but _1
>> does not.
>>
>
> perhaps you need to include the Fusion header that adapts
> std::pair.
Indeed I forgot that one, and I knew it (using it elsewhere).
>>
>> Any help will be appreciated. Some test code is attached, compile
>> with: g++ -g -std=c++11 -dboost_spirit_use_phoenix_v3 Test.C.
>> Variants are in comment.
>>
>
> A working version is attached.
Thank's it helped me, even though I cannot really use it in this form
(in particular the local variable do not fit as my rule is split in
severeal ones.
But it helped me design a solution (going through a variable local to
the method).
Again thank's a lot.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEARECAAYFAlRHckEACgkQEr8WrU8nPV1ZlwCfQ5dGpT7kmMBzAn2P0HRsBiJk
5DAAn3IYz5GlrLQ4UglMRgop3RoQSeGi
=OoJQ
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk