Boost.Spirit Karma: debug() alters result
Hello,
I am using boost 1.58 and I see the following.
template <class Iterator>
struct test_generator:
karma::grammar
That looks like a bug, however I don't have an immediate solution for that. I'll try to look into this as soon as I find some free time. Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Matwey V. Kornilov Sent: Friday, March 4, 2016 9:02 AM To: boost-users@lists.boost.org Subject: [Boost-users] Boost.Spirit Karma: debug() alters result
Hello,
I am using boost 1.58 and I see the following.
template <class Iterator> struct test_generator: karma::grammar
{ test_generator(): test_generator::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template <class Iterator> struct test_generator2: karma::grammar { test_generator2(): test_generator2::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; debug(value); start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template<class It> bool do_generate(It it, const std::string& x) { test_generator<It> g; return karma::generate(it, g, x); } template<class It> bool do_generate2(It it, const std::string& x) { test_generator2<It> g; return karma::generate(it, g, x); }
//...
std::string x2,x3; do_generate(std::back_inserter(x2), std::string("")); do_generate2(std::back_inserter(x3), std::string("")); std::cerr << "|" << x2 << "|" << std::endl; std::cerr << "|" << x3 << "|" << std::endl;
//...
The code prints:
<unnamed-rule> <try> <attributes>[[]]</attributes> </try> <fail/> </unnamed-rule> |=| ||
I.e. introduction of debug() alters result of the generator. Could you please explain me where I am wrong? I am stuck now.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
It feels like debug() implicitly does buffer[] on the specific term. 04.03.2016 18:48, Hartmut Kaiser пишет:
That looks like a bug, however I don't have an immediate solution for that. I'll try to look into this as soon as I find some free time.
Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Matwey V. Kornilov Sent: Friday, March 4, 2016 9:02 AM To: boost-users@lists.boost.org Subject: [Boost-users] Boost.Spirit Karma: debug() alters result
Hello,
I am using boost 1.58 and I see the following.
template <class Iterator> struct test_generator: karma::grammar
{ test_generator(): test_generator::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template <class Iterator> struct test_generator2: karma::grammar { test_generator2(): test_generator2::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; debug(value); start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template<class It> bool do_generate(It it, const std::string& x) { test_generator<It> g; return karma::generate(it, g, x); } template<class It> bool do_generate2(It it, const std::string& x) { test_generator2<It> g; return karma::generate(it, g, x); }
//...
std::string x2,x3; do_generate(std::back_inserter(x2), std::string("")); do_generate2(std::back_inserter(x3), std::string("")); std::cerr << "|" << x2 << "|" << std::endl; std::cerr << "|" << x3 << "|" << std::endl;
//...
The code prints:
<unnamed-rule> <try> <attributes>[[]]</attributes> </try> <fail/> </unnamed-rule> |=| ||
I.e. introduction of debug() alters result of the generator. Could you please explain me where I am wrong? I am stuck now.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
It feels like debug() implicitly does buffer[] on the specific term.
Any information or diagnosis you can provide would help speeding up fixing it. I might not be able to dedicate too much time any time soon. But I'll try. Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
That looks like a bug, however I don't have an immediate solution for
04.03.2016 18:48, Hartmut Kaiser пишет: that.
I'll try to look into this as soon as I find some free time.
Regards Hartmut --------------- http://boost-spirit.com http://stellar.cct.lsu.edu
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Matwey V. Kornilov Sent: Friday, March 4, 2016 9:02 AM To: boost-users@lists.boost.org Subject: [Boost-users] Boost.Spirit Karma: debug() alters result
Hello,
I am using boost 1.58 and I see the following.
template <class Iterator> struct test_generator: karma::grammar
{ test_generator(): test_generator::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template <class Iterator> struct test_generator2: karma::grammar { test_generator2(): test_generator2::base_type(start) { using karma::ascii::string; using boost::spirit::ascii::char_; using karma::lit; using karma::buffer; using karma::debug;
value2 = +(~char_(' ')); value1 = value2; value = lit('=') << value1; debug(value); start = buffer[-value]; }
karma::rule
start; karma::rule value; karma::rule value1; karma::rule value2; }; template<class It> bool do_generate(It it, const std::string& x) { test_generator<It> g; return karma::generate(it, g, x); } template<class It> bool do_generate2(It it, const std::string& x) { test_generator2<It> g; return karma::generate(it, g, x); }
//...
std::string x2,x3; do_generate(std::back_inserter(x2), std::string("")); do_generate2(std::back_inserter(x3), std::string("")); std::cerr << "|" << x2 << "|" << std::endl; std::cerr << "|" << x3 << "|" << std::endl;
//...
The code prints:
<unnamed-rule> <try> <attributes>[[]]</attributes> </try> <fail/> </unnamed-rule> |=| ||
I.e. introduction of debug() alters result of the generator. Could you please explain me where I am wrong? I am stuck now.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Hartmut Kaiser
-
Matwey V. Kornilov