Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57298 - trunk/boost/spirit/home/lex/lexer/lexertl
From: hartmut.kaiser_at_[hidden]
Date: 2009-11-02 20:53:46


Author: hkaiser
Date: 2009-11-02 20:53:46 EST (Mon, 02 Nov 2009)
New Revision: 57298
URL: http://svn.boost.org/trac/boost/changeset/57298

Log:
Spirit: fixing usage of plain functions as lexer semantic actions
Text files modified:
   trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp | 6 +-
   trunk/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp | 86 ++++++++++++---------------------------
   2 files changed, 30 insertions(+), 62 deletions(-)

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp 2009-11-02 20:53:46 EST (Mon, 02 Nov 2009)
@@ -249,7 +249,8 @@
         // types supported by the generated variant type (this is being
         // used to identify whether the stored data item in a particular
         // token instance needs to be converted from the pair of
- // iterators (see the first of the construct() functions below).
+ // iterators (see the first of the assign_to_attribute_from_value
+ // specializations below).
         ///////////////////////////////////////////////////////////////////////
         template <typename IteratorPair, typename AttributeTypes>
         struct token_value_typesequence
@@ -402,8 +403,7 @@
             // Interestingly enough we use the assign_to() framework defined in
             // Spirit.Qi allowing to convert the pair of iterators to almost any
             // required type (assign_to(), if available, uses the standard Spirit
- // parsers to do the conversion, and falls back to boost::lexical_cast
- // otherwise).
+ // parsers to do the conversion).
                 spirit::traits::assign_to(ip.begin(), ip.end(), attr);
 
             // If you get an error during the compilation of the following

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp 2009-11-02 20:53:46 EST (Mon, 02 Nov 2009)
@@ -74,17 +74,8 @@
                 f(start, end, pass, id);
             }
 
- template <typename F>
- static void arg4_action_bool(F* f, Iterator& start, Iterator& end
- , BOOST_SCOPED_ENUM(pass_flags)& pass, IdType& id, Context const&)
- {
- bool pass_bool = true;
- f (start, end, pass_bool, id);
- pass = pass_bool ? pass_flags::pass_normal : pass_flags::pass_fail;
- }
-
             template <typename A0, typename A1, typename A2, typename A3>
- static FunctionType call(void(*f)(A0, A1, A2, A3))
+ static FunctionType call(void (*f)(A0, A1, A2, A3))
             {
                 void (*pf)(void(*)(A0, A1, A2, A3)
                   , Iterator&, Iterator&, BOOST_SCOPED_ENUM(pass_flags)&
@@ -94,21 +85,8 @@
                 using phoenix::arg_names::_2;
                 using phoenix::arg_names::_3;
                 using phoenix::arg_names::_4;
- return phoenix::bind(pf, f, _1, _2, _3, _4);
- }
-
- template <typename A0, typename A1, typename A3>
- static FunctionType call(void(*f)(A0, A1, bool&, A3))
- {
- void (*pf)(void(*)(A0, A1, bool&, A3), Iterator&, Iterator&
- , BOOST_SCOPED_ENUM(pass_flags)&, IdType&, Context const&)
- = &wrap_action::arg4_action_bool;
-
- using phoenix::arg_names::_1;
- using phoenix::arg_names::_2;
- using phoenix::arg_names::_3;
- using phoenix::arg_names::_4;
- return phoenix::bind(pf, f, _1, _2, _3, _4);
+ using phoenix::arg_names::_5;
+ return phoenix::bind(pf, f, _1, _2, _3, _4, _5);
             }
 
             // semantic actions with 3 arguments
@@ -120,17 +98,8 @@
                 f(start, end, pass);
             }
 
- template <typename F>
- static void arg3_action_bool(F* f, Iterator& start, Iterator& end
- , BOOST_SCOPED_ENUM(pass_flags)& pass, IdType, Context const&)
- {
- bool pass_bool = true;
- f (start, end, pass_bool);
- pass = pass_bool ? pass_flags::pass_normal : pass_flags::pass_fail;
- }
-
             template <typename A0, typename A1, typename A2>
- static FunctionType call(void(*f)(A0, A1, A2))
+ static FunctionType call(void (*f)(A0, A1, A2))
             {
                 void (*pf)(void(*)(A0, A1, A2), Iterator&, Iterator&
                   , BOOST_SCOPED_ENUM(pass_flags)&, IdType
@@ -139,39 +108,32 @@
                 using phoenix::arg_names::_1;
                 using phoenix::arg_names::_2;
                 using phoenix::arg_names::_3;
- return phoenix::bind(pf, f, _1, _2, _3);
- }
-
- template <typename A0, typename A1>
- static FunctionType call(void(*f)(A0, A1, bool&))
- {
- void (*pf)(void(*)(A0, A1, bool&), Iterator&, Iterator&
- , BOOST_SCOPED_ENUM(pass_flags)&, IdType, Context const&)
- = &wrap_action::arg3_action_bool;
-
- using phoenix::arg_names::_1;
- using phoenix::arg_names::_2;
- using phoenix::arg_names::_3;
- return phoenix::bind(pf, f, _1, _2, _3);
+ using phoenix::arg_names::_4;
+ using phoenix::arg_names::_5;
+ return phoenix::bind(pf, f, _1, _2, _3, _4, _5);
             }
 
             // semantic actions with 2 arguments
             template <typename F>
             static void arg2_action(F* f, Iterator& start, Iterator& end
- , bool, IdType, Context const&)
+ , BOOST_SCOPED_ENUM(pass_flags)&, IdType, Context const&)
             {
- f(start, end);
+ f (start, end);
             }
 
             template <typename A0, typename A1>
- static FunctionType call(void(*f)(A0, A1))
+ static FunctionType call(void (*f)(A0, A1))
             {
- void (*pf)(void(*)(A0, A1), Iterator&, Iterator&, bool
+ void (*pf)(void(*)(A0, A1), Iterator&, Iterator&
+ , BOOST_SCOPED_ENUM(pass_flags)&
                   , IdType, Context const&) = &wrap_action::arg2_action;
 
                 using phoenix::arg_names::_1;
                 using phoenix::arg_names::_2;
- return phoenix::bind(pf, f, _1, _2);
+ using phoenix::arg_names::_3;
+ using phoenix::arg_names::_4;
+ using phoenix::arg_names::_5;
+ return phoenix::bind(pf, f, _1, _2, _3, _4, _5);
             }
 
             // we assume that either both iterators are to be passed to the
@@ -181,17 +143,23 @@
             // semantic actions with 0 argument
             template <typename F>
             static void arg0_action(F* f, Iterator&, Iterator&
- , bool, IdType, Context const&)
+ , BOOST_SCOPED_ENUM(pass_flags)&, IdType, Context const&)
             {
                 f();
             }
 
- static FunctionType call(void(*f)())
+ static FunctionType call(void (*f)())
             {
- void (*pf)(void(*)(), Iterator&, Iterator&, bool
+ void (*pf)(void(*)(), Iterator&, Iterator&
+ , BOOST_SCOPED_ENUM(pass_flags)&
                   , IdType, Context const&) = &arg0_action;
 
- return phoenix::bind(pf, f);
+ using phoenix::arg_names::_1;
+ using phoenix::arg_names::_2;
+ using phoenix::arg_names::_3;
+ using phoenix::arg_names::_4;
+ using phoenix::arg_names::_5;
+ return phoenix::bind(pf, f, _1, _2, _3, _4, _5);
             }
         };
 
@@ -200,7 +168,7 @@
         template <typename Iterator, typename Context, typename Idtype>
         struct wrap_action<unused_type, Iterator, Context, Idtype>
         {
- // plain functors are not touched at all
+ // plain function objects are not touched at all
             template <typename F>
             static F const& call(F const& f)
             {


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