On Fri, Mar 1, 2024 at 1:16 PM Дмитрий Архипов via Boost
Much of the wealth of research into parser combinators wasn't incorporated into this library. I didn't see in the documentation, for example, an easy way to "map" one parser's attribute into another. This kind of thing should be a basis operation provided by the library.
Could you explain what you mean by this? This happens implicitly usually, and you can explicitly do it in semantic actions. Do you mean something else?
I actually wanted to ask for a similar thing, but then forgot about it. Basically, sometimes you have to create a rule simply because you want to convert the attribute from type A to type B, and you use a semantic action. Semantic actions result in parser's attribute becoming none. But if instead semantic action's result type would be the parser's attribute, then using an action would become a mapping operation. E.g.
(+bp::digit)[( [](auto& attr){ return std::stol(attr); } )]; // mapping string -> long
If the library would also unwrap tuples in attributes, you could even do things like
(double_ >> double_)[ std::plus<>() ]
Hopefully I answered this elsewhere in this thread, or partially in https://github.com/tzlaine/parser/issues/106 . There's an implementation for that already, but I'm certain to change it. As-is, it's too hard to use, because too often your lambas need constraining. Anyway, if those two sources don't answer this, just let me know. Zach