Boost logo

Boost Users :

Subject: Re: [Boost-users] boost.xpressive: using placeholders with custom (check()) assertions
From: Alex Dubov (oakad_at_[hidden])
Date: 2010-06-25 07:35:16


Eric Niebler <eric <at> boostpro.com> writes:

>
> On 6/16/2010 3:04 AM, Alex Dubov wrote:
> > Greetings.
> >
> >
> > 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?

In the particular case I was working on, I was forced to stop on every match
anyway, so I'm not using check() right now. I'll, however, try to recreate the
problematic example to see if I keep encountering the problem.

> > 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?
>

I thought about something on the lines of:

sregex large_expr(*((expr)[check(cond())] | _));

With cond() being able to use a statement

<something>.set_matched(large_expr)

to signal that "large_expr" as a whole can be considered matched for now.


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