On 1/4/2010 5:15 AM, David A. Greene wrote:
On Saturday 02 January 2010 16:17:03 Eric Niebler wrote:
The attached code compiles. You weren't handling the if_ case correctly. You had specialized ConstructGrammarCases on IfTag, but you weren't using IfTag anywhere, so that specialization wasn't getting picked up. There were a few other small problems, but on the whole, you were pretty close.
If I wanted to keep the IfRule case as a specialization, what should it be specialized on? IfTag was a leftover remnant, so that was a coding error. What I intended to do is this:
template<> struct ConstructGrammarCases::case_keyword::if_ : boost::proto::when< IfRule, ConstructBinary<If>(ConstructGrammar(boost::proto::_right(boost::proto::_left)), ConstructGrammar(boost::proto::_right))> {};
But this leads to the compiler error seen earlier. Something like if_ is going to have to use a case_ specialization, so it's necessary to know how this is supposed to work.
You already know the answer, but you don't know you know it. ;-) You correctly defined IfRule as: typedef boost::proto::subscript< boost::proto::function< IfTerminal, ConstructGrammar >, ConstructGrammar
IfRule;
So you know that the topmost node of an if_ statement has a tag type of boost::proto::tag::subscript. So you should create a case_ specialization on that tag type, as follows: template<> struct ConstructGrammarCases::case_boost::proto::tag::subscript : boost::proto::when< IfRule, ConstructBinary< If, boost::shared_ptr<Base>
(ConstructGrammar(boost::proto::_right(boost::proto::_left)), ConstructGrammar(boost::proto::_right))> {};
Hope that helps. -- Eric Niebler BoostPro Computing http://www.boostpro.com