Re: [Spirit Development] Bug using operator >> and > in same sequence

Bryce Lelbach <[email protected]> Sat, 1 Jan 2011 01:35:56 -0500
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <20110101013556.4edb4fe6@Pegasus>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Your test case compiles fine for me, with or without my local modifications.
 I did have to add a definition for your point ctor.

In the future, please compile test cases before submitting them. It seems your
problem is elsewhere. Are you using lazy parsers or lazy directives? These are
currently broken in trunk, but a fix for them is coming.

On Fri, 31 Dec 2010 16:24:51 -0700
Robert Nelson <[email protected]> wrote:

> In the current version of trunk, and probably all recent versions,
> tuples are not merged properly when the >> and > operator are mixed.
> This has the effect of passing a type [[int,int],int] to phoenix,
> instead of the expected [int,int,int]  While I did mention before that
> I wanted this, I don't want it in this particular situation :)  This
> is clearly a bug.
> int_ > int_ int_ is a [int,int,int]
> int_ >> int_ >> int_ is a [int,int,int]
> int_ >> int_ > int_ is a [[int,int],int]
> int_ > int_ >> int_ is a [[int,int],int]
> 
> The bug is likely in /spirit/home/qi/operator/expect.hpp and
> /spirit/home/qi/operator/sequence.hpp
> 
> The problem occurs because proto::flatten_tree only flattens trees
> constructed with the same symbol.  So mixing symbols results in a
> partially flattened tree which does not fit well with the phoenix
> placeholders _1, _2, _3, etc that access a specific element of the
> tuple.
> 
> Here is a program demonstrating the error.
> 
> #include <boost/spirit/include/qi.hpp>
> #include <boost/fusion/adapted/struct/adapt_struct.hpp>
> #include <boost/spirit/include/phoenix_operator.hpp>
> #include <boost/spirit/home/phoenix/object/construct.hpp>
> #include <string>
> 
> struct point
> {
>   int x;
>   int y;
>   int z;
>  point(const int&,const int&,const int&);
> };
> 
> BOOST_FUSION_ADAPT_STRUCT(point,(int, x) (int, y) (int, z))
> 
> int main()
> {
>   {
>     using namespace boost::spirit::qi;
>     using namespace boost::phoenix;
>     rule<std::string::const_iterator,point()> rule = (int_ >  int_ >>
> int_)[_val = construct<point>(_1,_2,_3)];
>   }
> }



- -- 
Bryce Lelbach aka wash
boost-spirit.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAk0ey0wACgkQO/fqqIuE2t4SFACgyGuAdm1iT3findlFWG9YG/4I
oR0An3uIgVGrwSFKbwbzeI5dj/6wuhPK
=svzM
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel