Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53593 - trunk/boost/spirit/home/qi/auxiliary
From: joel_at_[hidden]
Date: 2009-06-03 06:35:07


Author: djowel
Date: 2009-06-03 06:35:07 EDT (Wed, 03 Jun 2009)
New Revision: 53593
URL: http://svn.boost.org/trac/boost/changeset/53593

Log:
fix to allow directives over lazy parsers
Text files modified:
   trunk/boost/spirit/home/qi/auxiliary/lazy.hpp | 69 +++++++++++++++++++++++++--------------
   1 files changed, 44 insertions(+), 25 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 2009-06-03 06:35:07 EDT (Wed, 03 Jun 2009)
@@ -41,14 +41,19 @@
 namespace boost { namespace spirit { namespace qi
 {
     using spirit::lazy;
+ typedef modify<qi::domain> qi_modify;
 
- template <typename Function>
- struct lazy_parser : parser<lazy_parser<Function> >
+ template <typename Function, typename Modifiers>
+ struct lazy_parser : parser<lazy_parser<Function, Modifiers> >
     {
         template <typename Context, typename Iterator>
         struct attribute
         {
             typedef typename
+ boost::result_of<qi_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
+
+ typedef typename
                 remove_reference<
                     typename boost::result_of<Function(unused_type, Context)>::type
>::type
@@ -60,7 +65,7 @@
             BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type)
 
             typedef typename
- result_of::compile<qi::domain, expr_type, tag::lazy_eval>::type
+ result_of::compile<qi::domain, expr_type, modifier>::type
             parser_type;
 
             typedef typename
@@ -68,8 +73,8 @@
             type;
         };
 
- lazy_parser(Function const& function)
- : function(function) {}
+ lazy_parser(Function const& function, Modifiers const& modifiers)
+ : function(function), modifiers(modifiers) {}
 
         template <typename Iterator, typename Context
           , typename Skipper, typename Attribute>
@@ -77,32 +82,40 @@
           , Context& context, Skipper const& skipper
           , Attribute& attr) const
         {
- return compile<qi::domain>(function(unused, context), tag::lazy_eval())
- .parse(first, last, context, skipper, attr);
+ return compile<qi::domain>(function(unused, context)
+ , qi_modify()(tag::lazy_eval(), modifiers))
+ .parse(first, last, context, skipper, attr);
         }
 
         template <typename Context>
         info what(Context& context) const
         {
             return info("lazy"
- , compile<qi::domain>(function(unused, context), tag::lazy_eval())
+ , compile<qi::domain>(function(unused, context)
+ , qi_modify()(tag::lazy_eval(), modifiers))
                     .what(context)
             );
         }
 
         Function function;
+ Modifiers modifiers;
     };
 
 
- template <typename Function, typename Subject>
- struct lazy_directive : unary_parser<lazy_directive<Function, Subject> >
- {
+ template <typename Function, typename Subject, typename Modifiers>
+ struct lazy_directive
+ : unary_parser<lazy_directive<Function, Subject, Modifiers> >
+ {
         typedef Subject subject_type;
 
         template <typename Context, typename Iterator>
         struct attribute
         {
             typedef typename
+ boost::result_of<qi_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
+
+ typedef typename
                 remove_reference<
                     typename boost::result_of<Function(unused_type, Context)>::type
>::type
@@ -122,7 +135,7 @@
             BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type)
 
             typedef typename
- result_of::compile<qi::domain, expr_type, tag::lazy_eval>::type
+ result_of::compile<qi::domain, expr_type, modifier>::type
             parser_type;
 
             typedef typename
@@ -130,8 +143,11 @@
             type;
         };
 
- lazy_directive(Function const& function, Subject const& subject)
- : function(function), subject(subject) {}
+ lazy_directive(
+ Function const& function
+ , Subject const& subject
+ , Modifiers const& modifiers)
+ : function(function), subject(subject), modifiers(modifiers) {}
 
         template <typename Iterator, typename Context
           , typename Skipper, typename Attribute>
@@ -143,7 +159,7 @@
                 proto::make_expr<proto::tag::subscript>(
                     function(unused, context)
                   , subject
- ), tag::lazy_eval())
+ ), qi_modify()(tag::lazy_eval(), modifiers))
                 .parse(first, last, context, skipper, attr);
         }
 
@@ -155,13 +171,14 @@
                     proto::make_expr<proto::tag::subscript>(
                         function(unused, context)
                       , subject
- ), tag::lazy_eval())
+ ), qi_modify()(tag::lazy_eval(), modifiers))
                     .what(context)
             );
         }
 
         Function function;
         Subject subject;
+ Modifiers modifiers;
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -170,33 +187,35 @@
     template <typename Eval, typename Modifiers>
     struct make_primitive<phoenix::actor<Eval>, Modifiers>
     {
- typedef lazy_parser<phoenix::actor<Eval> > result_type;
- result_type operator()(phoenix::actor<Eval> const& f, unused_type) const
+ typedef lazy_parser<phoenix::actor<Eval>, Modifiers> result_type;
+ result_type operator()(phoenix::actor<Eval> const& f
+ , Modifiers const& modifiers) const
         {
- return result_type(f);
+ return result_type(f, modifiers);
         }
     };
 
     template <typename Terminal, typename Actor, int Arity, typename Modifiers>
     struct make_primitive<lazy_terminal<Terminal, Actor, Arity>, Modifiers>
     {
- typedef lazy_parser<Actor> result_type;
+ typedef lazy_parser<Actor, Modifiers> result_type;
         result_type operator()(
- lazy_terminal<Terminal, Actor, Arity> const& lt, unused_type) const
+ lazy_terminal<Terminal, Actor, Arity> const& lt
+ , Modifiers const& modifiers) const
         {
- return result_type(lt.actor);
+ return result_type(lt.actor, modifiers);
         }
     };
 
     template <typename Terminal, typename Actor, int Arity, typename Subject, typename Modifiers>
     struct make_directive<lazy_terminal<Terminal, Actor, Arity>, Subject, Modifiers>
     {
- typedef lazy_directive<Actor, Subject> result_type;
+ typedef lazy_directive<Actor, Subject, Modifiers> result_type;
         result_type operator()(
             lazy_terminal<Terminal, Actor, Arity> const& lt
- , Subject const& subject, unused_type) const
+ , Subject const& subject, Modifiers const& modifiers) const
         {
- return result_type(lt.actor, subject);
+ return result_type(lt.actor, subject, modifiers);
         }
     };
 }}}


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