Boost logo

Boost Users :

Subject: Re: [Boost-users] [xpressive] questions about semantic actions
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-08-06 04:39:12


> >>>>> 2. Is there a way to access the regex_id of the regex to which a semantic
> >>>>> action belongs from the semantic action? More generally, can a semantic
> >>>>> action be written as a custom function object that takes as argument
> >>>>> some sort of environment (perhaps a match_results<>)?
> >>
> >> <snip>
> >>
> >> The action does not receive the match_results. The only way to get data
> >> into and out of an action is the way described in the docs. You will
> >> have to use xpressive::value, xpressive::reference or
> >> xpressive::placeholder to hold either the regex_id, a reference to the
> >> regex_id, or a promise to return a regex_id respectively. You can use
> >> those within the action.
> >
> > All of these require providing the regex_id *manually*.
> <snip>
>
> Right.
>
> > What I would like to do is this:
> >
> > sregex rx = xpr[cout << _regex_id_]; // _regex_id_ is a special symbol
> >
> > smatch what;
> > // no need to provide anything here! _regex_id_ will be replaced by the
> > // regex_id of rx
> > regex_match(str, what, rx);
> >
> > The reason this is important is because the action may be attached to a
> > subregex of the regex on which the match is being done. For example:
> >
> > placeholder<regex_id_type> _regex_id;
> > sregex sub = xpr[cout << _regex_id];
> > sregex rx = sub >> another_xpr;
> >
> > smatch what;
> > what.let(_regex_id = ???); // sub.regex_id() needs to go here, but this
> > // code knows only about rx, not about sub!
> > regex_match(str, what, rx);
> >
> > Is there no way to accomplish this?
>
> Not at present, no. I don't think it would be hard to add. Could you
> file a feature request?

I filed https://svn.boost.org/trac/boost/ticket/7197 .

Thanks,
Nate
                                               


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