Opened 12 months ago

Last modified 12 months ago

#13313 new Bugs

Problem when mixing repeat with epsilon parser

Reported by: Sebastien Matte Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.65.0 Severity: Problem
Keywords: repeat eps Cc:

Description

Mixing lazy repeats with epsilon parser (with action) is not working as expected. The attributes are not synthesized as expected. The following example fails:


std::string s;
size_t c = 0;

BOOST_TEST(test_attr("aaaaaaaa", repeat(val(8))[char_ >> eps[ref(c)++]], s) && s == "aaaaaaaa" && c == 8);

It failed because s is empty (which I don't think it should)

I have made some variation of the same operations (no actions, no lazy operations) and they all works except for this particular case.

See the complete example that I have made from the repeat.cpp test (only the last test fails):

    {
        using boost::spirit::qi::eps;
        using boost::phoenix::val;
        using boost::phoenix::ref;

        std::string s;
        size_t c = 0;

        s.clear();
        BOOST_TEST(test_attr("aaaaaaaa", repeat[char_ >> eps], s) && s == "aaaaaaaa");

        s.clear();
        BOOST_TEST(test_attr("aaaaaaaa", repeat(8)[char_ >> eps], s) && s == "aaaaaaaa");

        s.clear();
        BOOST_TEST(test_attr("aaaaaaaa", repeat(val(8))[char_ >> eps], s) && s == "aaaaaaaa");

        s.clear();
        c = 0;
        BOOST_TEST(test_attr("aaaaaaaa", repeat[char_ >> eps[ref(c)++]], s) && s == "aaaaaaaa" && c == 8);

        s.clear();
        c = 0;
        BOOST_TEST(test_attr("aaaaaaaa", repeat(8)[char_ >> eps[ref(c)++]], s) && s == "aaaaaaaa" && c == 8);

        s.clear();
        c = 0;
        BOOST_TEST(test_attr("aaaaaaaa", repeat(val(8))[char_ >> eps[ref(c)++]], s) && s == "aaaaaaaa" && c == 8);
    }

Attachments (1)

repeat.cpp (9.7 KB) - added by Sebastien Matte <sebastien.matte83@…> 12 months ago.
Modified repeat.cpp test with the included problem

Download all attachments as: .zip

Change History (2)

Changed 12 months ago by Sebastien Matte <sebastien.matte83@…>

Attachment: repeat.cpp added

Modified repeat.cpp test with the included problem

Note: See TracTickets for help on using tickets.