Boost logo

Boost :

Subject: [boost] Help with boost spirit
From: Theodore Papadopoulo (Theodore.Papadopoulo_at_[hidden])
Date: 2014-10-14 08:44:24


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sorry, this is probably a beginner question, but I'm stuck on it for
quite some time.

        I'm trying to write a small string like parser in which the size of
the string is first given. Some thing like:

int_ >> repeat(_1)[ char_ ]

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.

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.

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.

    Thank's in advance for any help.

        Theo.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlQ9GqgACgkQEr8WrU8nPV0b2gCeNFzQXwm1Uux4Eua2+jq8LcZk
DW0AoKBKY9KN5kGxYoPbnxwncwFSyH3M
=L0bR
-----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