From: Lee C. <fo...@le...> - 2015-02-13 16:37:55
|
On Fri, Feb 13, 2015 at 7:05 AM, Nikita Kniazev <nok...@gm...> wrote: > I hit problem with attributes propagation when using semantic actions, > even with using enforcing operator %=. > Following test case shows inconsistent in behavior of directives with lazy > parameters vs normal. > > /******************************************************************************/ > > #include <boost/spirit/include/phoenix_core.hpp> > > #include <boost/spirit/include/qi.hpp> > > > namespace qi = boost::spirit::qi; > > > template <typename T> > > void test(const T& rule) > > { > > const std::string in = "123"; > > std::vector<int> out; > > > std::string::const_iterator iter = in.begin(); > > const std::string::const_iterator end = in.end(); > > > const bool r = qi::parse(iter, end, rule, out); > > > std::cout << out.size() << std::endl; > > > BOOST_ASSERT(r && iter == end); > > } > > > int main() > > { > > using qi::int_; > > using qi::_1; > > using boost::phoenix::val; > > // Lazy Semantic > > test(qi::repeat(1)[int_]); // OK No No > > test(qi::repeat(1)[int_[_1]]); // OK No Yes > > test(qi::repeat(val(1))[int_]); // OK Yes No > > test(qi::repeat(val(1))[int_[_1]]); // FAIL Yes Yes > > > return 0; > > } > > /******************************************************************************/ > > > I'm not sure, but as for me this is a bug (which interfere me at using my > own custom directive). > The expression int_[_1] creates an integer parser with an attached semantic action that does nothing, so its not exactly clear to me what you are trying to do. Did you mean to do a push_back(ref(vector), _1) or something? Lee |