Boost logo

Boost Users :

From: kila (semeegozy_at_[hidden])
Date: 2019-10-12 16:35:01

I also open the same question on stackoverflow. For better formatting of
code, please refer to

I want to parse something like


which is separated by eol into a *vector<vector&lt;wchar_t>> *:
({xxxx},{xxxx}) so that "{" and "}" stays with internal characters together.
Note there are only two elements on the outer vector. My code is:


#include <iostream>

using namespace std;
namespace sw=boost::spirit::standard_wide;
namespace qi= boost::spirit::qi;
using boost::spirit::standard_wide::char_;

int main()
    wstring s =
    qi::rule<wstring::iterator, vector&lt;vector&lt;wchar_t>>(),
sw::blank_type> ru;
    ru = (qi::char_(L"{") >> *(char_-char_(L"}")) >> char_(L"}")) % qi::eol;
    vector<vector&lt;wchar_t>> result;
    qi::phrase_parse(s.begin(), s.end(), ru, sw::blank, result);

    for (auto& v : result) {
        //cout << "Size of string: " << v.size() << endl;
        for (auto& s : v) {
            wcout << s;
        cout << endl;
    std::cout << "Size of result"<<result.size()&lt;&lt;endl ;
However ouput is:

Size of result6

It looks like that &quot;{&quot; becomes a single element of type
vector&lt;wchar_t> for the outer vector.

Then consider the rule:

*ru = (qi::char_(L"{") >> *(char_-char_(L"}")) >> char_(L"}")) % qi::eol;*

According to the documentation, *(char_-char_(L"}")) should be vector . And
because *a: A, b: vector --> (a >> b): vector *, then I think that
*(qi::char_(L"{") >> *(char_-char_(L"}")) >> char_(L"}"))* should be
*vector<wchar_t>*. This is contracdicted to the result.

Where I'm wrong?

Sent from:

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at