|
Boost Users : |
Subject: [Boost-users] boost.xpressive: using placeholders with custom (check()) assertions
From: Alex Dubov (oakad_at_[hidden])
Date: 2010-06-16 03:04:53
Greetings.
Xpressive allows the use of object placeholders in semantic actions, which are being replaced by actual object references during the match, like in this simple example:
placeholder<string> p_string;
sregex r = (expr)[do_something(p_string, _)];
When executed, do_something() functor will receive a reference to string, as expected.
However, if functor is wrapped with assertion, this won't work:
sregex r = (expr)[check(do_something(p_string, _))];
Compilation will fail, because do_something has no method which accepts xpressive::placeholder<> objects. And even if such method was to be added, there's no obvious way to obtain a run-time reference to actual object out of placeholder.
This leads to some question:
1. Is there any trick allowing to use placeholders within check() assertions?
2. Alternatively, may there be a way to declare a semantic action functor, returning bool, in such a way, that it will act as custom assertion? It seems to me, that some cunning trick involving boost::proto construct may exist, even though I can't think of any particular way to do so.
In light of the above, I also thought about sort of feature request:
3. Sometimes, custom assertion applies only to a part of the match, something like:
*((expr)[check(cond)] | _)
That is, a desire is to consume everything, until some specific "expr" token matches a precondition. However, raised assertion will not stop the matching, because it only applies to one branch of the regexp. It could be very handy if there was a way to signal from assertion that a larger containing expression matched it results.
Thanks.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net