Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Spirit Karma: debug() alters result
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2016-03-05 13:13:33


> 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

>
> 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_at_[hidden]] On
> Behalf
> >> Of Matwey V. Kornilov
> >> Sent: Friday, March 4, 2016 9:02 AM
> >> To: boost-users_at_[hidden]
> >> 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<Iterator, std::string()> {
> >>
> >> 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<Iterator, std::string()> start;
> >> karma::rule<Iterator, std::string()> value;
> >> karma::rule<Iterator, std::string()> value1;
> >> karma::rule<Iterator, std::string()> value2;
> >> };
> >> template <class Iterator>
> >> struct test_generator2:
> >> karma::grammar<Iterator, std::string()> {
> >>
> >> 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<Iterator, std::string()> start;
> >> karma::rule<Iterator, std::string()> value;
> >> karma::rule<Iterator, std::string()> value1;
> >> karma::rule<Iterator, std::string()> 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_at_[hidden]
> >> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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