Re: [Spirit Devel] ADAPT_ADT causes recursive grammars to not compile

Christopher Schmidt <[email protected]> Fri, 19 Nov 2010 09:19:51 +0100
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <[email protected]>
Robert Nelson schrieb:
> Why does the following fail to compile?
> 
> struct y
> {
>   const std::vector<y>& get() const;
>   void set(const std::vector<y>&); 
> };
> 
> BOOST_FUSION_ADAPT_ADT(y,(std::vector<y>,std::vector<y>,obj.get(),obj.set(val)))
> 
> int main()
> {
>   using namespace boost::spirit::qi;
>   using namespace boost::phoenix;
>   boost::spirit::qi::rule<std::string::const_iterator,y()> b;
>   b = (*b)[at_c<0>(_val) = _1]; //ERROR is here
> }
> 
> It seems to be a result of fusion loop unrolling or something.  The
> libraries don't like the fact we are parsing a vector of y's and storing
> them in y.  The above code works with seemingly slight modification, but
> I need the above implementation in my application or a workaround.
>  Attached is main.cpp, a file with only the offending code and
> three_main.cpp which has 2 other similar grammars, both of which will
> compile.  I think the error is the result of a bug/feature in the fusion
> and/or spirit::qi library.  Please help.
> 
> Thanks
> --Robert Nelson

You forgot to include

<boost/spirit/home/support/adapt_adt_attributes.hpp>

Unfortunately that file has three bugs in it, which are fixed by the
attached patch.
Damn. I am sorry :( I do not really understand spirit, and so, at the
time of adapting adapt_adt_attributes.hpp to the fusion changes, I just
did a basic regex replace in adapt_adt_attributes. Then I ran Spirit's
tests and fixed all compiling errors. These three bits of old code
didn't trigger a compile error :(
I do not know what to do. Hartmut, is there any chance to get this fix
in 1.45? The code is definitely wrong, there is no
fusion::extension::access::adt_attribute_proxy and the Const template
type can definitely not be deduced.

I apologize for the inconvenience.

Best regards,
Christopher

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev

_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
adapt_adt_attributes.patch (text/plain, 1.1 KB)
Index: adapt_adt_attributes.hpp
===================================================================
--- adapt_adt_attributes.hpp	(revision 66572)
+++ adapt_adt_attributes.hpp	(working copy)
@@ -30,7 +30,7 @@
     template <typename T, int N, bool Const>
     struct container_value<fusion::extension::adt_attribute_proxy<T, N, Const> >
       : container_value<
-            typename fusion::extension::access::adt_attribute_proxy<
+            typename fusion::extension::adt_attribute_proxy<
                 T, N, Const
             >::type
         >
@@ -63,7 +63,7 @@
     {};
 
     ///////////////////////////////////////////////////////////////////////////
-    template <typename T, int N, bool Const, typename Val>
+    template <typename T, int N, typename Val>
     struct assign_to_attribute_from_value<
         fusion::extension::adt_attribute_proxy<T, N, false>
       , Val>
@@ -107,7 +107,7 @@
             val = attr;
         }
         static void 
-        fail(fusion::extension::access::adt_attribute_proxy<T, N, false>&)
+        fail(fusion::extension::adt_attribute_proxy<T, N, false>&)
         {
         }
     };