
On 6/16/2010 3:04 AM, Alex Dubov wrote:
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.
It should if it is a lazy function. How is do_something defined? Can you send a self-contained program that demonstrates the problem you're having?
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.
xpressive will do that for you.
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.
Yes, that should work.
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.
I don't understand that last sentence. Can you clarify? -- Eric Niebler BoostPro Computing http://www.boostpro.com