[Proto] Turnign grammar into primitive transform : _default is being naughty with me :(

I'm polisihng some generic recursive descent grammar to evaluate various sort of expression that only differ on how nodes and leaf are treated. I was trying, once the grammar was set up using combo of transform to make a single primitive transform to speed up compile-time. Everythign worked until I hit a brick wall while trying to put the last non-generic part (the call to proto::_default) inside my own transform. Here is link to the working.cpp and not_working.cpp stand alone source file for inspection. test were done on 1.42 release. http://www.lri.fr/~falcou/tmp/working.cpp http://www.lri.fr/~falcou/tmp/not_working.cpp The error is : http://www.lri.fr/~falcou/tmp/errors.txt thanks for any pointer on this issue which, I think, is a stupid mistake on my side. -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35

On 3/18/2010 7:58 AM, joel falcou wrote:
Here is link to the working.cpp and not_working.cpp stand alone source file for inspection. test were done on 1.42 release.
http://www.lri.fr/~falcou/tmp/working.cpp http://www.lri.fr/~falcou/tmp/not_working.cpp
The error is :
http://www.lri.fr/~falcou/tmp/errors.txt
thanks for any pointer on this issue which, I think, is a stupid mistake on my side.
Hi Joel, This isn't a stupid mistake on your side; it's a bug in Proto. To explain: all transforms including _default take their expression parameter as ... template<class E> ... operator()(E &e) That is, the expression must either be an lvalue or a const-qualified rvalue. It's done this way to reduce the number of overloads and improve compile times. All the temporary expression objects Proto creates are const-qualified rvalues so they can be passed to transforms. Well, *almost* all, the exception being functional::make_expr and functional::unpack_expr. That's an oversight. I just fixed it on trunk. To work around your problem, you need to change line 109 of not_working.cpp to first save the result of unpack to a temporary and then pass that to rec. HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
All the temporary expression objects Proto creates are const-qualified rvalues so they can be passed to transforms. Well, *almost* all, the exception being functional::make_expr and functional::unpack_expr. That's an oversight. I just fixed it on trunk.
To work around your problem, you need to change line 109 of not_working.cpp to first save the result of unpack to a temporary and then pass that to rec. That's perfect Eric, everything work like a charm now :)
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
participants (2)
-
Eric Niebler
-
joel falcou