Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53597 - in trunk: boost/spirit/home/karma/auxiliary boost/spirit/home/qi/auxiliary libs/spirit/test/karma libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-06-03 08:48:11


Author: hkaiser
Date: 2009-06-03 08:48:10 EDT (Wed, 03 Jun 2009)
New Revision: 53597
URL: http://svn.boost.org/trac/boost/changeset/53597

Log:
Spirit: applied patch allowing to use lazy constructs in directives for Karma
Text files modified:
   trunk/boost/spirit/home/karma/auxiliary/lazy.hpp | 66 +++++++++++++++++++++++++--------------
   trunk/boost/spirit/home/qi/auxiliary/lazy.hpp | 6 +-
   trunk/libs/spirit/test/karma/case_handling.cpp | 8 ++++
   trunk/libs/spirit/test/qi/no_case.cpp | 6 +-
   4 files changed, 56 insertions(+), 30 deletions(-)

Modified: trunk/boost/spirit/home/karma/auxiliary/lazy.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auxiliary/lazy.hpp (original)
+++ trunk/boost/spirit/home/karma/auxiliary/lazy.hpp 2009-06-03 08:48:10 EDT (Wed, 03 Jun 2009)
@@ -42,14 +42,19 @@
 namespace boost { namespace spirit { namespace karma
 {
     using spirit::lazy;
+ typedef modify<karma::domain> karma_modify;
 
- template <typename Function>
- struct lazy_generator : generator<lazy_generator<Function> >
+ template <typename Function, typename Modifiers>
+ struct lazy_generator : generator<lazy_generator<Function, Modifiers> >
     {
         template <typename Context, typename Unused>
         struct attribute
         {
             typedef typename
+ boost::result_of<karma_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
+
+ typedef typename
                 remove_reference<
                     typename boost::result_of<Function(unused_type, Context)>::type
>::type
@@ -61,7 +66,7 @@
             BOOST_SPIRIT_ASSERT_MATCH(karma::domain, expr_type)
 
             typedef typename
- result_of::compile<karma::domain, expr_type, tag::lazy_eval>::type
+ result_of::compile<karma::domain, expr_type, modifier>::type
             generator_type;
 
             typedef typename
@@ -69,9 +74,8 @@
             type;
         };
 
- lazy_generator(Function const& func)
- : func(func)
- {}
+ lazy_generator(Function const& func, Modifiers const& modifiers)
+ : func(func), modifiers(modifiers) {}
 
         template <
             typename OutputIterator, typename Context,
@@ -80,7 +84,8 @@
         bool generate(OutputIterator& sink, Context& context,
             Delimiter const& d, Attribute const& attr) const
         {
- return compile<karma::domain>(func(unused, context), tag::lazy_eval())
+ return compile<karma::domain>(func(unused, context)
+ , karma_modify()(tag::lazy_eval(), modifiers))
                 .generate(sink, context, d, attr);
         }
 
@@ -88,17 +93,20 @@
         info what(Context& context) const
         {
             return info("lazy"
- , compile<karma::domain>(func(unused, context), tag::lazy_eval())
+ , compile<karma::domain>(func(unused, context)
+ , karma_modify()(tag::lazy_eval(), modifiers))
                     .what(context)
             );
         }
 
         Function func;
+ Modifiers modifiers;
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename Function, typename Subject>
- struct lazy_directive : unary_generator<lazy_directive<Function, Subject> >
+ template <typename Function, typename Subject, typename Modifiers>
+ struct lazy_directive
+ : unary_generator<lazy_directive<Function, Subject, Modifiers> >
     {
         typedef Subject subject_type;
 
@@ -106,6 +114,10 @@
         struct attribute
         {
             typedef typename
+ boost::result_of<karma_modify(tag::lazy_eval, Modifiers)>::type
+ modifier;
+
+ typedef typename
                 remove_reference<
                     typename boost::result_of<Function(unused_type, Context)>::type
>::type
@@ -125,7 +137,7 @@
             BOOST_SPIRIT_ASSERT_MATCH(karma::domain, expr_type)
 
             typedef typename
- result_of::compile<karma::domain, expr_type, tag::lazy_eval>::type
+ result_of::compile<karma::domain, expr_type, modifier>::type
             generator_type;
 
             typedef typename
@@ -133,8 +145,9 @@
             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 OutputIterator, typename Context, typename Delimiter
           , typename Attribute>
@@ -143,7 +156,8 @@
         {
             return compile<karma::domain>(
                 proto::make_expr<proto::tag::subscript>(
- function(unused, ctx), subject), tag::lazy_eval())
+ function(unused, ctx), subject)
+ , karma_modify()(tag::lazy_eval(), modifiers))
                 .generate(sink, ctx, d, attr);
         }
 
@@ -153,13 +167,15 @@
             return info("lazy-directive"
               , compile<karma::domain>(
                     proto::make_expr<proto::tag::subscript>(
- function(unused, ctx), subject), tag::lazy_eval())
+ function(unused, ctx), subject)
+ , karma_modify()(tag::lazy_eval(), modifiers))
                     .what(ctx)
             );
         }
 
         Function function;
         Subject subject;
+ Modifiers modifiers;
     };
 
     ///////////////////////////////////////////////////////////////////////////
@@ -168,21 +184,23 @@
     template <typename Eval, typename Modifiers>
     struct make_primitive<phoenix::actor<Eval>, Modifiers>
     {
- typedef lazy_generator<phoenix::actor<Eval> > result_type;
- result_type operator()(phoenix::actor<Eval> const& f, unused_type) const
+ typedef lazy_generator<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_generator<Actor> result_type;
+ typedef lazy_generator<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);
         }
     };
 
@@ -192,12 +210,12 @@
     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);
         }
     };
 

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 08:48:10 EDT (Wed, 03 Jun 2009)
@@ -52,7 +52,7 @@
             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
@@ -105,7 +105,7 @@
     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>
@@ -114,7 +114,7 @@
             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

Modified: trunk/libs/spirit/test/karma/case_handling.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/case_handling.cpp (original)
+++ trunk/libs/spirit/test/karma/case_handling.cpp 2009-06-03 08:48:10 EDT (Wed, 03 Jun 2009)
@@ -255,5 +255,13 @@
         BOOST_TEST(test("ÄÄ", upper["Ää"]));
     }
 
+ {
+ using namespace boost::spirit::ascii;
+ using boost::phoenix::val;
+
+ BOOST_TEST(test("x", lower[val('X')]));
+ BOOST_TEST(test("x", lower[val('x')]));
+ }
+
     return boost::report_errors();
 }

Modified: trunk/libs/spirit/test/qi/no_case.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/no_case.cpp (original)
+++ trunk/libs/spirit/test/qi/no_case.cpp 2009-06-03 08:48:10 EDT (Wed, 03 Jun 2009)
@@ -160,9 +160,9 @@
         BOOST_TEST(test("x", no_case[char_(val('x'))][ref(ch) = _1]));
         BOOST_TEST(ch == 'x');
     }
-
+
     { // lazy no_case lits
-
+
         using namespace boost::spirit::ascii;
         using boost::phoenix::val;
 
@@ -170,6 +170,6 @@
         BOOST_TEST(test("BOCHI BOCHI", no_case[val("bochi bochi")]));
         BOOST_TEST(!test("Vavoo", no_case[val("bochi bochi")]));
     }
-
+
     return boost::report_errors();
 }


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