diff -ur spirit.orig/home/qi/auxiliary/attr_cast.hpp spirit/home/qi/auxiliary/attr_cast.hpp --- spirit.orig/home/qi/auxiliary/attr_cast.hpp 2011-10-12 21:22:46.000000000 +1100 +++ spirit/home/qi/auxiliary/attr_cast.hpp 2011-10-26 03:02:41.389139222 +1100 @@ -92,17 +92,21 @@ typename transform::type attr_ = transform::pre(attr); - if (!compile(subject). - parse(first, last, context, skipper, attr_)) + Iterator i = first; + + if (compile(subject). + parse(i, last, context, skipper, attr_)) { - transform::fail(attr); - return false; + // do up-stream transformation, this mainly integrates the results + // back into the original attribute value, if appropriate + if (traits::post_transform(attr, attr_)) { + first = i; + return true; + } } - // do up-stream transformation, this mainly integrates the results - // back into the original attribute value, if appropriate - traits::post_transform(attr, attr_); - return true; + transform::fail(attr); + return false; } template diff -ur spirit.orig/home/qi/detail/attributes.hpp spirit/home/qi/detail/attributes.hpp --- spirit.orig/home/qi/detail/attributes.hpp 2011-10-12 21:22:46.000000000 +1100 +++ spirit/home/qi/detail/attributes.hpp 2011-10-24 20:49:24.097277462 +1100 @@ -22,9 +22,10 @@ static Transformed pre(Exposed&) { return Transformed(); } - static void post(Exposed& val, Transformed const& attr) + static bool post(Exposed& val, Transformed const& attr) { traits::assign_to(attr, val); + return true; } // fail() will be called by Qi rule's if the rhs failed parsing @@ -37,7 +38,7 @@ { typedef Attribute& type; static Attribute& pre(Attribute& val) { return val; } - static void post(Attribute&, Attribute const&) {} + static bool post(Attribute&, Attribute const&) { return true; } static void fail(Attribute&) {} }; @@ -47,7 +48,7 @@ typedef Transformed type; static Transformed pre(Exposed& val) { return Transformed(val); } - static void post(Exposed&, Transformed const&) { /* no-op */ } + static bool post(Exposed&, Transformed const&) { return true; } // fail() will be called by Qi rule's if the rhs failed parsing static void fail(Exposed&) {} @@ -59,7 +60,7 @@ { typedef Attribute& type; static Attribute& pre(Attribute& val) { return val; } - static void post(Attribute&, Attribute const&) {} + static bool post(Attribute&, Attribute const&) { return true; } static void fail(Attribute&) {} }; @@ -87,7 +88,7 @@ val = Transformed(); return boost::get(val); } - static void post(boost::optional&, Transformed const&) {} + static bool post(boost::optional&, Transformed const&) { return true; } static void fail(boost::optional& val) { val = none_t(); // leave optional uninitialized if rhs failed @@ -100,7 +101,7 @@ { typedef Attribute& type; static Attribute& pre(Attribute& val) { return val; } - static void post(Attribute&, Attribute const&) {} + static bool post(Attribute&, Attribute const&) { return true; } static void fail(Attribute&) {} }; @@ -110,7 +111,7 @@ { typedef unused_type type; static unused_type pre(unused_type) { return unused; } - static void post(unused_type, unused_type) {} + static bool post(unused_type, unused_type) { return true; } static void fail(unused_type) {} }; @@ -160,7 +161,7 @@ /////////////////////////////////////////////////////////////////////////// template - void post_transform(Exposed& dest, Transformed const& attr) + bool post_transform(Exposed& dest, Transformed const& attr) { return transform_attribute::post(dest, attr); } diff -ur spirit.orig/home/qi/nonterminal/rule.hpp spirit/home/qi/nonterminal/rule.hpp --- spirit.orig/home/qi/nonterminal/rule.hpp 2011-10-12 21:22:46.000000000 +1100 +++ spirit/home/qi/nonterminal/rule.hpp 2011-10-26 03:04:41.403945091 +1100 @@ -285,16 +285,20 @@ // attributes, without passing values for them. context_type context(attr_); + Iterator i = first; + // If you are seeing a compilation error here stating that the // fourth parameter can't be converted to a required target type // then you are probably trying to use a rule or a grammar with // an incompatible skipper type. - if (f(first, last, context, skipper)) + if (f(i, 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; + if (traits::post_transform(attr, attr_)) { + first = i; + return true; + } } // inform attribute transformation of failed rhs @@ -331,16 +335,20 @@ // attributes, passing values of incompatible types for them. context_type context(attr_, params, caller_context); + Iterator i = first; + // If you are seeing a compilation error here stating that the // fourth parameter can't be converted to a required target type // then you are probably trying to use a rule or a grammar with // an incompatible skipper type. - if (f(first, last, context, skipper)) + if (f(i, 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; + if (traits::post_transform(attr, attr_)) { + first = i; + return true; + } } // inform attribute transformation of failed rhs diff -ur spirit.orig/home/support/adapt_adt_attributes.hpp spirit/home/support/adapt_adt_attributes.hpp --- spirit.orig/home/support/adapt_adt_attributes.hpp 2011-10-12 21:22:39.000000000 +1100 +++ spirit/home/support/adapt_adt_attributes.hpp 2011-10-24 20:33:51.100900977 +1100 @@ -257,12 +257,13 @@ { return val; } - static void + static bool post( fusion::extension::adt_attribute_proxy& val , Attribute const& attr) { val = attr; + return true; } static void fail(fusion::extension::adt_attribute_proxy&) @@ -289,11 +290,12 @@ { return val; } - static void + static bool post( fusion::extension::adt_attribute_proxy& , Attribute const&) { + return true; } static void fail(fusion::extension::adt_attribute_proxy&) diff -ur spirit.orig/repository/home/qi/nonterminal/subrule.hpp spirit/repository/home/qi/nonterminal/subrule.hpp --- spirit.orig/repository/home/qi/nonterminal/subrule.hpp 2011-10-12 21:22:52.000000000 +1100 +++ spirit/repository/home/qi/nonterminal/subrule.hpp 2011-10-26 03:06:35.435757539 +1100 @@ -213,12 +213,16 @@ // without passing values for them. context_type context(*this, attr_); - if (def.binder(first, last, context, skipper)) + Iterator i = first; + + if (def.binder(i, 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; + if (traits::post_transform(attr, attr_)) { + first = i; + return true; + } } // inform attribute transformation of failed rhs @@ -267,12 +271,16 @@ // passing values of incompatible types for them. context_type context(*this, attr_, params, caller_context); - if (def.binder(first, last, context, skipper)) + Iterator i = first; + + if (def.binder(i, 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; + if (traits::post_transform(attr, attr_)) { + first = i; + return true; + } } // inform attribute transformation of failed rhs