Opened 9 years ago

Closed 5 years ago

#8556 closed Bugs (fixed)

Cannot combine synthesized attributes with semantic actions in some cases

Reported by: Jeff Trull (@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

The use of "%=" in rule definitions appears intended to permit simultaneous use of semantic actions and synthesized attributes. However, in some cases I find I can choose only one. In particular a rule of this form:

rule<Iterator, std::vector<std::string>()> r; r = qi::string >> qi::string >> qi::string;

successfully synthesizes its attribute, while the same rule defined this way:

r = (qi::string >> qi::string >> qi::string)[SA]

successfully compiles and runs its semantic action. However, combining them fails:

r %= (qi::string >> qi::string >> qi::string)[SA]

produces a compile error. Test case attached.

Attachments (1)

actiontest.cpp (2.5 KB ) - added by Jeff Trull (@… 9 years ago.
standalone test case

Download all attachments as: .zip

Change History (3)

by Jeff Trull (@…, 9 years ago

Attachment: actiontest.cpp added

standalone test case

comment:1 by Nikita Kniazev <nok.raven@…>, 5 years ago

You should use #define BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT if you want your code to compile.

The behavior you encountered is preserved to maintain the backward compatibility. http://boost.2283326.n4.nabble.com/fusion-vector2-std-pair-compatibility-td3529649i20.html

There are also other ways to solve your problem https://stackoverflow.com/questions/40723341/using-semantic-action-together-with-attribute-propagation-in-spirit

comment:2 by Joel de Guzman, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.