Your error message tells you that you want to assign a variant command means that the returned type of a command will be an ExpressionAST (i.e. A MockExpressionNode in your case). Similarly qi::rule tag means that tag will be of type string Combining this with instruction = (command | tag) means that an instruction is either a string or a MockExpressionNode This is internally stored as a variant instruction implies that the returned type of instruction is again an ExpressionAST (i.e.
A MockExpressionNode ). This requires the failing assignment from the variant held internally to a MockExpressionNode To sum up, you have to provide types in your qi::rule s that somewhat "match" the types implied by your grammar in the sense that assignment is possible. Despite all the Boost.
Spirit magic, C++ is still a statically typed language after all. For the issue at hand, you either have to supply a fitting operator or you have to assign the results of the different rules to different types that support implicit conversion. BTW, you have similar type issues for block and command at the moment.
Take a careful look at the mini_xml example in the documentation: how to define types for a recursive structure and how different rules assign to different types depending on the defined grammar (especially rules xml and node ).
Your error message tells you that you want to assign a variant to a MockExpressionNode The relevant lines are 33 and 34; ... error: no match for ‘operator=’ ... boost::variant command; means that the returned type of a command will be an ExpressionAST (i.e. A MockExpressionNode in your case). Similarly qi::rule tag; means that tag will be of type string.
Combining this with instruction = (command | tag) means that an instruction is either a string or a MockExpressionNode. This is internally stored as a variant. Finally, qi::rule instruction; implies that the returned type of instruction is again an ExpressionAST (i.e.
A MockExpressionNode). This requires the failing assignment from the variant held internally to a MockExpressionNode. To sum up, you have to provide types in your qi::rules that somewhat "match" the types implied by your grammar in the sense that assignment is possible.
Despite all the Boost. Spirit magic, C++ is still a statically typed language after all. For the issue at hand, you either have to supply a fitting operator=, or you have to assign the results of the different rules to different types that support implicit conversion.
BTW, you have similar type issues for block and command at the moment. Take a careful look at the mini_xml example in the documentation: how to define types for a recursive structure and how different rules assign to different types depending on the defined grammar (especially rules xml and node).
Thanks! That explanation at the end help me clarify what is really going on – lurscher Jun 16 '10 at 22:09.
To sum up, you have to provide types in your qi::rules that somewhat "match" the types implied by your grammar in the sense that assignment is possible. Despite all the Boost. Spirit magic, C++ is still a statically typed language after all.
For the issue at hand, you either have to supply a fitting operator=, or you have to assign the results of the different rules to different types that support implicit conversion. BTW, you have similar type issues for block and command at the moment. Take a careful look at the mini_xml example in the documentation: how to define types for a recursive structure and how different rules assign to different types depending on the defined grammar (especially rules xml and node).
The second form using phoenix::push_back is the suggested one. The problem is where the semantic action is defined. The (whatever % ",") construct has an attribute value type of vector.
Push_back(vector) You can see this in the third line of the last error block you posted: home/.../container. Hpp:492: error: no matching function for call to ‘std::vector::push_back(const std::vector&)’ Debugging compile errors with this stuff sometimes requires reading between the lines, literally ;) Instead, attach the push_back action to the parameter parser directly, since this parser has the attribute type MockExpressionNode Try: command = identifier at_c(qi::_val) = qi::_1, phoenix::bind( &ExpressionAST::setAsCommand , qi::_val ) >> "(" >> -( parameter phoenix::push_back(at_c(qi::_val) , qi::_1 ) % "," ) >> ").
The second form using phoenix::push_back is the suggested one. The problem is where the semantic action is defined. The -(whatever % ",") construct has an attribute value type of vector, which you then pass as the parameter of push_back called on the vector.In other words, spirit is not switching the arguments, the code is essentially vector.
Push_back(vector). You can see this in the third line of the last error block you posted: /home/.../container. Hpp:492: error: no matching function for call to ‘std::vector::push_back(const std::vector&)’ Debugging compile errors with this stuff sometimes requires reading between the lines, literally ;) Instead, attach the push_back action to the parameter parser directly, since this parser has the attribute type MockExpressionNode .
Try: command = identifier at_c(qi::_val) = qi::_1, phoenix::bind( &ExpressionAST::setAsCommand , qi::_val ) >> "(" >> -( parameter phoenix::push_back(at_c(qi::_val) , qi::_1 ) % "," ) >> ").
Thanks! I read this doc boost. Org/doc/libs/1_43_0/libs/spirit/doc/html/spirit/qi/… but I didn't notice that Vector is the attribute return by the composite, I have to read about Compound attribute notation!
Thanks! – lurscher Jun 25 '10 at 21:21 I added a follow up question here stackoverflow. Com/questions/3125582/… – lurscher Jun 26 '10 at 21:42.
In other words, spirit is not switching the arguments, the code is essentially vector. Instead, attach the push_back action to the parameter parser directly, since this parser has the attribute type MockExpressionNode .
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.