Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72040 - trunk/boost/spirit/home/qi/auxiliary
From: joel_at_[hidden]
Date: 2011-05-18 22:01:58


Author: djowel
Date: 2011-05-18 22:01:57 EDT (Wed, 18 May 2011)
New Revision: 72040
URL: http://svn.boost.org/trac/boost/changeset/72040

Log:
Fixed bug where lazy_parser and lazy_directive are not respecting the auto rule.
Text files modified:
   trunk/boost/spirit/home/qi/auxiliary/lazy.hpp | 84 ++++++++++++++++++++++++++++++++++++---
   1 files changed, 77 insertions(+), 7 deletions(-)

Modified: trunk/boost/spirit/home/qi/auxiliary/lazy.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auxiliary/lazy.hpp (original)
+++ trunk/boost/spirit/home/qi/auxiliary/lazy.hpp 2011-05-18 22:01:57 EDT (Wed, 18 May 2011)
@@ -76,15 +76,50 @@
         lazy_parser(Function const& function, Modifiers const& modifiers)
           : function(function), modifiers(modifiers) {}
 
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr, mpl::false_) const
+ {
+ return p.parse(first, last, context, skipper, attr);
+ }
+
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr, mpl::true_) const
+ {
+ // If DeducedAuto is false (semantic actions is present), the
+ // component's attribute is unused.
+ return p.parse(first, last, context, skipper, unused);
+ }
+
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl_main(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr) const
+ {
+ // If DeducedAuto is true (no semantic action), we pass the parser's
+ // attribute on to the component.
+ typedef typename traits::has_semantic_action<Parser>::type auto_rule;
+ return parse_impl(p, first, last, context, skipper, attr, auto_rule());
+ }
+
         template <typename Iterator, typename Context
           , typename Skipper, typename Attribute>
         bool parse(Iterator& first, Iterator const& last
           , Context& context, Skipper const& skipper
           , Attribute& attr) const
         {
- return compile<qi::domain>(function(unused, context)
+ return parse_impl_main(compile<qi::domain>(function(unused, context)
                 , qi_modify()(tag::lazy_eval(), modifiers))
- .parse(first, last, context, skipper, attr);
+ , first, last, context, skipper, attr);
         }
 
         template <typename Context>
@@ -103,7 +138,7 @@
 
 
     template <typename Function, typename Subject, typename Modifiers>
- struct lazy_directive
+ struct lazy_directive
         : unary_parser<lazy_directive<Function, Subject, Modifiers> >
     {
         typedef Subject subject_type;
@@ -149,18 +184,53 @@
           , Modifiers const& modifiers)
           : function(function), subject(subject), modifiers(modifiers) {}
 
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr, mpl::false_) const
+ {
+ return p.parse(first, last, context, skipper, attr);
+ }
+
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr, mpl::true_) const
+ {
+ // If DeducedAuto is false (semantic actions is present), the
+ // component's attribute is unused.
+ return p.parse(first, last, context, skipper, unused);
+ }
+
+ template <typename Parser, typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse_impl_main(Parser const& p
+ , Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper
+ , Attribute& attr) const
+ {
+ // If DeducedAuto is true (no semantic action), we pass the parser's
+ // attribute on to the component.
+ typedef typename traits::has_semantic_action<Parser>::type auto_rule;
+ return parse_impl(p, first, last, context, skipper, attr, auto_rule());
+ }
+
         template <typename Iterator, typename Context
           , typename Skipper, typename Attribute>
         bool parse(Iterator& first, Iterator const& last
           , Context& context, Skipper const& skipper
           , Attribute& attr) const
         {
- return compile<qi::domain>(
+ return parse_impl_main(compile<qi::domain>(
                 proto::make_expr<proto::tag::subscript>(
                     function(unused, context)
                   , subject
                 ), qi_modify()(tag::lazy_eval(), modifiers))
- .parse(first, last, context, skipper, attr);
+ , first, last, context, skipper, attr);
         }
 
         template <typename Context>
@@ -230,7 +300,7 @@
       : handles_container<
           typename qi::lazy_parser<Actor, Modifiers>::template
               attribute<Context, Iterator>::parser_type
- , Attribute, Context, Iterator>
+ , Attribute, Context, Iterator>
     {};
 
     template <typename Subject, typename Actor, typename Modifiers
@@ -241,7 +311,7 @@
       : handles_container<
           typename qi::lazy_directive<Actor, Subject, Modifiers>::template
               attribute<Context, Iterator>::parser_type
- , Attribute, Context, Iterator>
+ , Attribute, Context, Iterator>
     {};
 }}}
 


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