[Spirit2X] raw[...] with unused attribute

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Spirit2X] raw[...] with unused attribute

Francois Barel
Hi,

With svn-r1077, the following test would fail to compile:
    BOOST_TEST((test("x", raw[alpha])));
as raw[...] does not handle being passed an unused_type attribute (it
tries to construct it with the begin and end iterators).

I know it doesn't make that much sense to write that... but during
development, I run into this regularly when temporarily commenting out
a raw[...]'s action for tests. I think for consistency, raw[...]
should accept an unused_type attribute, just like other parsers.


The following patch fixes it by replacing direct attribute assignment
with qi::detail::assign_to, existing tests still pass:

Index: boost/spirit/home/qi/directive/raw.hpp
===================================================================
--- boost/spirit/home/qi/directive/raw.hpp      (revision 1077)
+++ boost/spirit/home/qi/directive/raw.hpp      (working copy)
@@ -14,6 +14,7 @@
 #include <boost/spirit/home/qi/meta_compiler.hpp>
 #include <boost/spirit/home/qi/skip_over.hpp>
 #include <boost/spirit/home/qi/parser.hpp>
+#include <boost/spirit/home/qi/detail/assign_to.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/common_terminals.hpp>
@@ -56,7 +57,7 @@
             Iterator i = first;
             if (subject.parse(i, last, context, skipper, unused))
             {
-                attr = Attribute(first, i);
+                detail::assign_to(first, i, attr);
                 first = i;
                 return true;
             }

OK to commit?

Thanks,
Fran├žois

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Spirit2X] raw[...] with unused attribute

Hartmut Kaiser
> With svn-r1077, the following test would fail to compile:
>     BOOST_TEST((test("x", raw[alpha])));
> as raw[...] does not handle being passed an unused_type attribute (it
> tries to construct it with the begin and end iterators).
>
> I know it doesn't make that much sense to write that... but during
> development, I run into this regularly when temporarily commenting out
> a raw[...]'s action for tests. I think for consistency, raw[...]
> should accept an unused_type attribute, just like other parsers.
>
>
> The following patch fixes it by replacing direct attribute assignment
> with qi::detail::assign_to, existing tests still pass:
>
> Index: boost/spirit/home/qi/directive/raw.hpp
> ===================================================================
> --- boost/spirit/home/qi/directive/raw.hpp      (revision 1077)
> +++ boost/spirit/home/qi/directive/raw.hpp      (working copy)
> @@ -14,6 +14,7 @@
>  #include <boost/spirit/home/qi/meta_compiler.hpp>
>  #include <boost/spirit/home/qi/skip_over.hpp>
>  #include <boost/spirit/home/qi/parser.hpp>
> +#include <boost/spirit/home/qi/detail/assign_to.hpp>
>  #include <boost/spirit/home/support/unused.hpp>
>  #include <boost/spirit/home/support/info.hpp>
>  #include <boost/spirit/home/support/common_terminals.hpp>
> @@ -56,7 +57,7 @@
>              Iterator i = first;
>              if (subject.parse(i, last, context, skipper, unused))
>              {
> -                attr = Attribute(first, i);
> +                detail::assign_to(first, i, attr);
>                  first = i;
>                  return true;
>              }
>
> OK to commit?

Looks fine to me.

Thanks!
Regards Hartmut



------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Spirit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-devel