Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69136 - in trunk/boost/spirit/home: qi qi/detail qi/nonterminal support
From: joel_at_[hidden]
Date: 2011-02-21 20:28:15


Author: djowel
Date: 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
New Revision: 69136
URL: http://svn.boost.org/trac/boost/changeset/69136

Log:
added option to have no predefined terminals _1..._N _j, _val, etc.
Text files modified:
   trunk/boost/spirit/home/qi/detail/assign_to.hpp | 4 +-
   trunk/boost/spirit/home/qi/domain.hpp | 19 +++++++++
   trunk/boost/spirit/home/qi/nonterminal/rule.hpp | 24 ++++++++++--
   trunk/boost/spirit/home/support/argument.hpp | 47 +++++++++++++++++++++---
   trunk/boost/spirit/home/support/context.hpp | 77 ++++++++++++++++++++++++++++++++-------
   5 files changed, 144 insertions(+), 27 deletions(-)

Modified: trunk/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/assign_to.hpp 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
@@ -18,7 +18,7 @@
 #include <boost/spirit/home/qi/detail/attributes.hpp>
 #include <boost/spirit/home/support/container.hpp>
 #include <boost/spirit/home/phoenix/core/actor.hpp>
-#include <boost/fusion/include/assign.hpp>
+#include <boost/fusion/include/copy.hpp>
 #include <boost/ref.hpp>
 #include <boost/range/iterator_range.hpp>
 
@@ -179,7 +179,7 @@
         static void
         call(T const& val, Attribute& attr)
         {
- fusion::assign(val, attr);
+ fusion::copy(val, attr);
         }
     };
 

Modified: trunk/boost/spirit/home/qi/domain.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/domain.hpp (original)
+++ trunk/boost/spirit/home/qi/domain.hpp 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
@@ -31,13 +31,29 @@
     using spirit::compile;
     using spirit::info;
 
+ using spirit::_pass_type;
+ using spirit::_val_type;
+ using spirit::_a_type;
+ using spirit::_b_type;
+ using spirit::_c_type;
+ using spirit::_d_type;
+ using spirit::_e_type;
+ using spirit::_f_type;
+ using spirit::_g_type;
+ using spirit::_h_type;
+ using spirit::_i_type;
+ using spirit::_j_type;
+
     // You can bring these in with the using directive
     // without worrying about bringing in too much.
+
     namespace labels
     {
         BOOST_PP_REPEAT(SPIRIT_ARGUMENTS_LIMIT, SPIRIT_USING_ARGUMENT, _)
         BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
 
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
         using spirit::_pass;
         using spirit::_val;
         using spirit::_a;
@@ -50,7 +66,10 @@
         using spirit::_h;
         using spirit::_i;
         using spirit::_j;
+
+#endif
     }
+
 }}}
 
 #endif

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 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
@@ -47,6 +47,21 @@
 {
     BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
 
+ using spirit::_pass_type;
+ using spirit::_val_type;
+ using spirit::_a_type;
+ using spirit::_b_type;
+ using spirit::_c_type;
+ using spirit::_d_type;
+ using spirit::_e_type;
+ using spirit::_f_type;
+ using spirit::_g_type;
+ using spirit::_h_type;
+ using spirit::_i_type;
+ using spirit::_j_type;
+
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
     using spirit::_pass;
     using spirit::_val;
     using spirit::_a;
@@ -59,6 +74,7 @@
     using spirit::_h;
     using spirit::_i;
     using spirit::_j;
+#endif
 
     using spirit::info;
     using spirit::locals;
@@ -224,7 +240,7 @@
         }
 #else
         // both friend functions have to be defined out of class as VC7.1
- // will complain otherwise
+ // will complain otherwise
         template <typename OutputIterator_, typename T1_, typename T2_
           , typename T3_, typename T4_, typename Expr>
         friend rule<OutputIterator_, T1_, T2_, T3_, T4_>& operator%=(
@@ -259,7 +275,7 @@
                 // do down-stream transformation, provides attribute for
                 // rhs parser
                 typedef traits::transform_attribute<
- typename make_attribute::type, attr_type, domain>
+ typename make_attribute::type, attr_type, domain>
                 transform;
 
                 typename make_attribute::type made_attr = make_attribute::call(attr);
@@ -305,7 +321,7 @@
                 // do down-stream transformation, provides attribute for
                 // rhs parser
                 typedef traits::transform_attribute<
- typename make_attribute::type, attr_type, domain>
+ typename make_attribute::type, attr_type, domain>
                 transform;
 
                 typename make_attribute::type made_attr = make_attribute::call(attr);
@@ -371,7 +387,7 @@
         // then the expression (expr) is not a valid spirit qi expression.
         BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
 
- typedef typename
+ typedef typename
             rule<OutputIterator_, T1_, T2_, T3_, T4_>::encoding_modifier_type
         encoding_modifier_type;
 

Modified: trunk/boost/spirit/home/support/argument.hpp
==============================================================================
--- trunk/boost/spirit/home/support/argument.hpp (original)
+++ trunk/boost/spirit/home/support/argument.hpp 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
@@ -25,11 +25,32 @@
 # define SPIRIT_ARGUMENTS_LIMIT PHOENIX_LIMIT
 #endif
 
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
 #define SPIRIT_DECLARE_ARG(z, n, data) \
+ typedef phoenix::actor<argument<n> > const \
+ BOOST_PP_CAT(BOOST_PP_CAT(_, BOOST_PP_INC(n)), _type); \
     phoenix::actor<argument<n> > const \
         BOOST_PP_CAT(_, BOOST_PP_INC(n)) = argument<n>();
+ /***/
+
+#define SPIRIT_USING_ARGUMENT(z, n, data) \
+ using spirit::BOOST_PP_CAT(BOOST_PP_CAT(_, n), _type); \
+ using spirit::BOOST_PP_CAT(_, n);
+ /***/
+
+#else
+
+#define SPIRIT_DECLARE_ARG(z, n, data) \
+ typedef phoenix::actor<argument<n> > const \
+ BOOST_PP_CAT(BOOST_PP_CAT(_, BOOST_PP_INC(n)), _type);
+ /***/
+
+#define SPIRIT_USING_ARGUMENT(z, n, data) \
+ using spirit::BOOST_PP_CAT(BOOST_PP_CAT(_, n), _type); \
+ /***/
 
-#define SPIRIT_USING_ARGUMENT(z, n, data) using spirit::BOOST_PP_CAT(_, n);
+#endif
 
 namespace boost { namespace spirit
 {
@@ -117,27 +138,41 @@
     };
 
     // _0 refers to the whole attribute as generated by the lhs parser
- phoenix::actor<attribute_context> const _0 = attribute_context();
+ typedef phoenix::actor<attribute_context> const _0_type;
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ _0_type _0 = attribute_context();
+#endif
 
     // _1, _2, ... refer to the attributes of the single components the lhs
     // parser is composed of
- phoenix::actor<argument<0> > const _1 = argument<0>();
- phoenix::actor<argument<1> > const _2 = argument<1>();
- phoenix::actor<argument<2> > const _3 = argument<2>();
+ typedef phoenix::actor<argument<0> > const _1_type;
+ typedef phoenix::actor<argument<1> > const _2_type;
+ typedef phoenix::actor<argument<2> > const _3_type;
+
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ _1_type _1 = argument<0>();
+ _2_type _2 = argument<1>();
+ _3_type _3 = argument<2>();
+#endif
 
     // '_pass' may be used to make a match fail in retrospective
- phoenix::actor<phoenix::argument<2> > const _pass = phoenix::argument<2>();
+ typedef phoenix::actor<phoenix::argument<2> > const _pass_type;
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+ _pass_type _pass = phoenix::argument<2>();
+#endif
 
     // Bring in the rest of the arguments and attributes (_4 .. _N+1), using PP
     BOOST_PP_REPEAT_FROM_TO(
         3, SPIRIT_ARGUMENTS_LIMIT, SPIRIT_DECLARE_ARG, _)
 
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
     // You can bring these in with the using directive
     // without worrying about bringing in too much.
     namespace labels
     {
         BOOST_PP_REPEAT(SPIRIT_ARGUMENTS_LIMIT, SPIRIT_USING_ARGUMENT, _)
     }
+#endif
 
 }}
 

Modified: trunk/boost/spirit/home/support/context.hpp
==============================================================================
--- trunk/boost/spirit/home/support/context.hpp (original)
+++ trunk/boost/spirit/home/support/context.hpp 2011-02-21 20:28:11 EST (Mon, 21 Feb 2011)
@@ -27,11 +27,30 @@
 # define SPIRIT_ATTRIBUTES_LIMIT PHOENIX_LIMIT
 #endif
 
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
 #define SPIRIT_DECLARE_ATTRIBUTE(z, n, data) \
+ typedef phoenix::actor<attribute<n> > const \
+ BOOST_PP_CAT(BOOST_PP_CAT(_r, n), _type); \
     phoenix::actor<attribute<n> > const \
         BOOST_PP_CAT(_r, n) = attribute<n>();
 
-#define SPIRIT_USING_ATTRIBUTE(z, n, data) using spirit::BOOST_PP_CAT(_r, n);
+#define SPIRIT_USING_ATTRIBUTE(z, n, data) \
+ using spirit::BOOST_PP_CAT(BOOST_PP_CAT(_r, n), _type); \
+ using spirit::BOOST_PP_CAT(_r, n); \
+ /***/
+
+#else
+
+#define SPIRIT_DECLARE_ATTRIBUTE(z, n, data) \
+ typedef phoenix::actor<attribute<n> > const \
+ BOOST_PP_CAT(BOOST_PP_CAT(_r, n), _type); \
+
+#define SPIRIT_USING_ATTRIBUTE(z, n, data) \
+ using spirit::BOOST_PP_CAT(BOOST_PP_CAT(_r, n), _type); \
+ /***/
+
+#endif
 
 namespace boost { namespace spirit
 {
@@ -163,35 +182,60 @@
         }
     };
 
+ typedef phoenix::actor<attribute<0> > const _val_type;
+ typedef phoenix::actor<attribute<0> > const _r0_type;
+ typedef phoenix::actor<attribute<1> > const _r1_type;
+ typedef phoenix::actor<attribute<2> > const _r2_type;
+
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
     // _val refers to the 'return' value of a rule (same as _r0)
     // _r1, _r2, ... refer to the rule arguments
- phoenix::actor<attribute<0> > const _val = attribute<0>();
- phoenix::actor<attribute<0> > const _r0 = attribute<0>();
- phoenix::actor<attribute<1> > const _r1 = attribute<1>();
- phoenix::actor<attribute<2> > const _r2 = attribute<2>();
+ _val_type _val = attribute<0>();
+ _r0_type _r0 = attribute<0>();
+ _r1_type _r1 = attribute<1>();
+ _r2_type _r2 = attribute<2>();
+
+#endif
 
     // Bring in the rest of the attributes (_r4 .. _rN+1), using PP
     BOOST_PP_REPEAT_FROM_TO(
         3, SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_DECLARE_ATTRIBUTE, _)
 
+ typedef phoenix::actor<local_variable<0> > const _a_type;
+ typedef phoenix::actor<local_variable<1> > const _b_type;
+ typedef phoenix::actor<local_variable<2> > const _c_type;
+ typedef phoenix::actor<local_variable<3> > const _d_type;
+ typedef phoenix::actor<local_variable<4> > const _e_type;
+ typedef phoenix::actor<local_variable<5> > const _f_type;
+ typedef phoenix::actor<local_variable<6> > const _g_type;
+ typedef phoenix::actor<local_variable<7> > const _h_type;
+ typedef phoenix::actor<local_variable<8> > const _i_type;
+ typedef phoenix::actor<local_variable<9> > const _j_type;
+
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
+
     // _a, _b, ... refer to the local variables of a rule
- phoenix::actor<local_variable<0> > const _a = local_variable<0>();
- phoenix::actor<local_variable<1> > const _b = local_variable<1>();
- phoenix::actor<local_variable<2> > const _c = local_variable<2>();
- phoenix::actor<local_variable<3> > const _d = local_variable<3>();
- phoenix::actor<local_variable<4> > const _e = local_variable<4>();
- phoenix::actor<local_variable<5> > const _f = local_variable<5>();
- phoenix::actor<local_variable<6> > const _g = local_variable<6>();
- phoenix::actor<local_variable<7> > const _h = local_variable<7>();
- phoenix::actor<local_variable<8> > const _i = local_variable<8>();
- phoenix::actor<local_variable<9> > const _j = local_variable<9>();
+ _a_type _a = local_variable<0>();
+ _b_type _b = local_variable<1>();
+ _c_type _c = local_variable<2>();
+ _d_type _d = local_variable<3>();
+ _e_type _e = local_variable<4>();
+ _f_type _f = local_variable<5>();
+ _g_type _g = local_variable<6>();
+ _h_type _h = local_variable<7>();
+ _i_type _i = local_variable<8>();
+ _j_type _j = local_variable<9>();
 
+#endif
     // You can bring these in with the using directive
     // without worrying about bringing in too much.
     namespace labels
     {
         BOOST_PP_REPEAT(SPIRIT_ARGUMENTS_LIMIT, SPIRIT_USING_ARGUMENT, _)
         BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
+
+#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
         using spirit::_val;
         using spirit::_a;
         using spirit::_b;
@@ -203,7 +247,10 @@
         using spirit::_h;
         using spirit::_i;
         using spirit::_j;
+#endif
     }
+
+
 }}
 
 #endif


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