Re: [Spirit Development] Bug using operator >> and > in same sequence
Bryce Lelbach <[email protected]> Sun, 2 Jan 2011 16:03:22 -0500
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <20110102160322.435ad7cb@Pegasus> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey - I asked heller about this the other day, here's his reply: Begin forwarded message: Date: Sun, 2 Jan 2011 10:53:59 +0100 From: Thomas Heller <[email protected]> To: [email protected] Subject: spirit + flatten tree + SAs Hi Bryce, Sorry about yesterday ... needed to go real quick. Anyway, I looked into the issue. You are right, proto::flatten only flattens expressions with the same tag type, in a way, here is the excerpt from the docs: /// \brief A PolymorphicFunctionObject type that returns a "flattened" /// view of a Proto expression tree. /// /// A PolymorphicFunctionObject type that returns a "flattened" /// view of a Proto expression tree. For a tree with a top-most node /// tag of type \c T, the elements of the flattened sequence are /// determined by recursing into each child node with the same /// tag type and returning those nodes of different type. So for /// instance, the Proto expression tree corresponding to the /// expression <tt>a | b | c</tt> has a flattened view with elements /// [a, b, c], even though the tree is grouped as /// <tt>((a | b) | c)</tt>. However, i do not believe that this is a bug in spirit. It is more of a pitfall. Spirits automagic attribute calculation stuff seems to synthesize the attribute just fine. That means that this works as expected: rule<iterator, vector3<int, int, int>(void)> r = (int_ >> int_ > int_); Let me remind you that semantic actions disable this automatic attribute stuff. That means, that the above rule sees a different attribute (this is a little counter intuitive, but on a closer look just right). rule<iterator, vector3<int, int, int>(void)> r = (int_ >> int_ > int_) // "raw" synthesized attribute is of type: // boost::fusion::vector2<boost::fusion::vector2<int, int>, int> [ _val = construct<vector3<int, int, int> > ( // manually decompose it: phoenix::at_c<0>(_1) , phoenix::at_c<1>(_1) , _2 ) ]; Hope that helps, Thomas - -- Bryce Lelbach aka wash boost-spirit.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAk0g6BoACgkQO/fqqIuE2t6NhACg13A2GPl2RRNFs1CqSPZzn0Pl YIcAoND7jnpuQTr0dwmuOVaeYivGsp7e =7Mf7 -----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