On 8/4/2012 11:57 PM, Nathan Ridge wrote:
Hello,
I am trying to use semantic actions in Boost.Xpressive, and I have a couple of questions:
1. When a semantic action is attached to a subexpression of a regex, what is the meaning of _, s1, s2 etc. in the semantic action? For example, suppose you have the following regex: ((s1 = xpr1)[action]) >> (s2 = xpr2) Inside 'action': - is it valid to use '_'? - if so does it refer to just the portion matched by xpr1? - is it valid to use 's1'? - is it valid to use 's2'?
Yes, this is all described in the docs. http://www.boost.org/doc/libs/1_50_0/doc/html/xpressive/user_s_guide.html#bo...
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<>)?
Please see the sections in the docs on refering to local and non-local variables from within semantic actions. Non-local variables will do what you want, I think. http://www.boost.org/doc/libs/1_50_0/doc/html/xpressive/user_s_guide.html#bo... -- Eric Niebler BoostPro Computing http://www.boostpro.com