
On 14 October 2010 22:36, Hartmut Kaiser <hartmut.kaiser@gmail.com> wrote:
That should be easy, see below.
start = a_rule | b_rule | c_rule;
qi::rule<Iterator, std::vector<int>()> a_rule; qi::rule<Iterator, std::vector<int>()> b_rule; qi::rule<Iterator, std::vector<int>()> c_rule;
HTH Regards Hartmut --------------- http://boost-spirit.com
I think I tried something like that, but it didn't work. Unless I'm mistaken, each of those rules will create their own std::vector<int> instance, so the values will not end up inserted into the vector specified in the grammar parameter. I was able to eventually achieve my goal by specifying each of the rules like so: qi::rule<Iterator, std::vector<int> &> a_rule; and in the main grammar I passed the _val into them. start = a_rule(_val) | b_rule(_val) | c_rule(_val) Then I referenced the arguments with _r1 in the sub-rules. Does that look correct? Is there a better way?