pon., 26 lut 2024 o 17:05 Christian Mazakas via Boost
I would recommend putting something like the above in the docs, where the motivation for using rule parsers is listed. Currently it states "fix the attribute type produced by a parser to something other than the default" but what you sayin above is more: "prevent the parsers from doing things that they would otherwise do".
Ha, came online to say exactly this. I think that description of the problem being solved is more than satisfactory and illuminates the issue quite well.
I note that parsing a homogenous sequence to a std::set does work, at least without rules: https://godbolt.org/z/x57j1dq5T
I was surprised to find that, in the context of other precautions, feeding parsed data to a collection is performed via `insert` rather than `push_back`. This is probably a holdover from the X3 days as this is who Spirit treats
collections generically and, ironically, is done for the exact reason that `std::set` supports `insert(pos, val)`.
In principle, I don't think that a free-form grammar like the above parsing into a `set` is problematic. Instead, I agree more with Zach that when you're formally defining rules, you're really telling the library, "Hey, this is exactly what I want to be parsing into."
I would be fine with this approach, except that I found the behavior in Boost.Parser is more complicated than that. I had a parser in Boost.Spirit V2 that does not use a single rule: https://github.com/akrzemi1/wdungeon/blob/master/parser.cpp#L47 This does no longer work in Boost.Parser, because it imposes stricter rules on attribute conversions *even when I do not use rules*. So, I cannot build a simple conceptual model here. Regards, &rzej;
- Christian
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost