Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56579 - in trunk/boost/spirit/home: karma/nonterminal qi/nonterminal support
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-04 16:37:26


Author: hkaiser
Date: 2009-10-04 16:37:25 EDT (Sun, 04 Oct 2009)
New Revision: 56579
URL: http://svn.boost.org/trac/boost/changeset/56579

Log:
Spirit: rule's have intrinsic attribute transformation now
Text files modified:
   trunk/boost/spirit/home/karma/nonterminal/rule.hpp | 7 ++++---
   trunk/boost/spirit/home/qi/nonterminal/rule.hpp | 22 +++++++++++++++++++---
   trunk/boost/spirit/home/support/container.hpp | 4 ++++
   3 files changed, 27 insertions(+), 6 deletions(-)

Modified: trunk/boost/spirit/home/karma/nonterminal/rule.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/nonterminal/rule.hpp (original)
+++ trunk/boost/spirit/home/karma/nonterminal/rule.hpp 2009-10-04 16:37:25 EDT (Sun, 04 Oct 2009)
@@ -227,7 +227,8 @@
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
                 // attributes, without passing values for them.
- context_type context(make_attribute::call(attr));
+ context_type context(traits::pre_transform<attr_type>(
+ make_attribute::call(attr)));
 
                 // If you are seeing a compilation error here stating that the
                 // third parameter can't be converted to a karma::reference
@@ -256,8 +257,8 @@
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
                 // attributes, passing values of incompatible types for them.
- context_type context(make_attribute::call(attr)
- , params, caller_context);
+ context_type context(traits::pre_transform<attr_type>(
+ make_attribute::call(attr)), params, caller_context);
 
                 // If you are seeing a compilation error here stating that the
                 // third parameter can't be converted to a karma::reference

Modified: trunk/boost/spirit/home/qi/nonterminal/rule.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/nonterminal/rule.hpp (original)
+++ trunk/boost/spirit/home/qi/nonterminal/rule.hpp 2009-10-04 16:37:25 EDT (Sun, 04 Oct 2009)
@@ -211,12 +211,17 @@
           , Attribute& attr) const
         {
             //$$$ do a preskip if this is an implied lexeme $$$
-
+
             if (f)
             {
                 typedef traits::make_attribute<attr_type, Attribute> make_attribute;
 
- typename make_attribute::type attr_ = make_attribute::call(attr);
+ // do down-stream transformation, provides attribute for
+ // rhs parser
+ typename traits::result_of::pre_transform<
+ typename make_attribute::type, attr_type
+ >::type attr_ =
+ traits::pre_transform<attr_type>(make_attribute::call(attr));
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
@@ -229,6 +234,9 @@
                 // an incompatible skipper type.
                 if (f(first, last, context, skipper))
                 {
+ // do up-stream transformation, this integrates the results
+ // back into the original attribute value, if appropriate
+ traits::post_transform(attr, attr_);
                     return true;
                 }
             }
@@ -247,7 +255,12 @@
             {
                 typedef traits::make_attribute<attr_type, Attribute> make_attribute;
 
- typename make_attribute::type attr_ = make_attribute::call(attr);
+ // do down-stream transformation, provides attribute for
+ // rhs parser
+ typename traits::result_of::pre_transform<
+ typename make_attribute::type, attr_type
+ >::type attr_ =
+ traits::pre_transform<attr_type>(make_attribute::call(attr));
 
                 // If you are seeing a compilation error here, you are probably
                 // trying to use a rule or a grammar which has inherited
@@ -260,6 +273,9 @@
                 // an incompatible skipper type.
                 if (f(first, last, context, skipper))
                 {
+ // do up-stream transformation, this integrates the results
+ // back into the original attribute value, if appropriate
+ traits::post_transform(attr, attr_);
                     return true;
                 }
             }

Modified: trunk/boost/spirit/home/support/container.hpp
==============================================================================
--- trunk/boost/spirit/home/support/container.hpp (original)
+++ trunk/boost/spirit/home/support/container.hpp 2009-10-04 16:37:25 EDT (Sun, 04 Oct 2009)
@@ -123,10 +123,12 @@
     }
 
     ///////////////////////////////////////////////////////////////////////
+ //[customization_container_value_default
     template <typename Container, typename Enable/* = void*/>
     struct container_value
       : detail::remove_value_const<typename Container::value_type>
     {};
+ //]
 
     // this will be instantiated if the optional holds a container
     template <typename T>
@@ -153,11 +155,13 @@
>::type type;
     };
 
+ //[customization_container_value_unused
     template <>
     struct container_value<unused_type>
     {
         typedef unused_type type;
     };
+ //]
 
     template <>
     struct container_value<unused_type const>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk