Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66847 - in trunk/boost/spirit/home/lex/lexer: . lexertl
From: hartmut.kaiser_at_[hidden]
Date: 2010-11-29 13:48:28


Author: hkaiser
Date: 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
New Revision: 66847
URL: http://svn.boost.org/trac/boost/changeset/66847

Log:
Spirit: applying patch contributed by Mathias Gaunard, fixes compilation problems if lexer id type is not std::size_t
Text files modified:
   trunk/boost/spirit/home/lex/lexer/lexer.hpp | 6 +++---
   trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp | 6 ++++--
   trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 2 +-
   trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 4 ++--
   trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp | 8 ++++----
   trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp | 2 +-
   trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp | 4 ++--
   trunk/boost/spirit/home/lex/lexer/token_def.hpp | 2 +-
   8 files changed, 18 insertions(+), 16 deletions(-)

Modified: trunk/boost/spirit/home/lex/lexer/lexer.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexer.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexer.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -340,7 +340,7 @@
         // avoid warnings about using 'this' in constructor
         lexer& this_() { return *this; }
 
- typename Lexer::id_type next_token_id;
+ std::size_t next_token_id; // has to be an integral type
 
     public:
         typedef Lexer lexer_type;
@@ -353,7 +353,7 @@
         typedef std::basic_string<char_type> string_type;
 
         lexer(unsigned int flags = match_flags::match_default
- , id_type first_id = min_token_id)
+ , id_type first_id = id_type(min_token_id))
           : lexer_type(flags)
           , next_token_id(first_id)
           , self(this_(), lexer_type::initial_state())
@@ -371,7 +371,7 @@
             { return this->lexer_type::add_state(state); }
 
         // create a unique token id
- id_type get_next_id() { return next_token_id++; }
+ id_type get_next_id() { return id_type(next_token_id++); }
 
         lexer_def self; // allow for easy token definition
     };

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -134,6 +134,8 @@
         template <typename MultiPass>
         static result_type& get_next(MultiPass& mp, result_type& result)
         {
+ typedef typename result_type::id_type id_type;
+
             shared& data = mp.shared()->ftor;
             for(;;)
             {
@@ -204,13 +206,13 @@
                     // using data.set_value(), advancing 'data.first_' past the
                     // matched sequence
                     assign_on_exit<Iterator> on_exit(data.get_first(), end);
- return result = result_type(id, state, data.get_value());
+ return result = result_type(id_type(id), state, data.get_value());
                 }
                 else if (pass_flags::pass_normal == pass) {
                     // return matched token, advancing 'data.first_' past the
                     // matched sequence
                     assign_on_exit<Iterator> on_exit(data.get_first(), end);
- return result = result_type(id, state, data.get_first(), end);
+ return result = result_type(id_type(id), state, data.get_first(), end);
                 }
                 else if (pass_flags::pass_fail == pass) {
 #if defined(BOOST_SPIRIT_LEXERTL_DEBUG)

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -194,7 +194,7 @@
         };
 
         ///////////////////////////////////////////////////////////////////////
- // doesn't support lexer semantic actions
+ // doesn't support lexer semantic actions, but supports state
         template <typename Iterator, typename TokenValue>
         struct data<Iterator, mpl::false_, mpl::true_, TokenValue>
           : data<Iterator, mpl::false_, mpl::false_, TokenValue>

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -290,7 +290,7 @@
 
         // Register a semantic action with the given id
         template <typename F>
- void add_action(id_type unique_id, std::size_t state, F act)
+ void add_action(std::size_t unique_id, std::size_t state, F act)
         {
             // If you see an error here stating add_action is not a member of
             // fusion::unused_type then you are probably having semantic actions
@@ -310,7 +310,7 @@
             }
         }
 // template <typename F>
-// void add_action(id_type unique_id, char_type const* state, F act)
+// void add_action(std::size_t unique_id, char_type const* state, F act)
 // {
 // typedef typename Functor::wrap_action_type wrapper_type;
 // actions_.add_action(unique_id, add_state(state), wrapper_type::call(act));

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -35,8 +35,8 @@
             typedef boost::function<functor_type> functor_wrapper_type;
 
             // add a semantic action function object
- template <typename Idtype, typename F>
- void add_action(Idtype unique_id, std::size_t, F act)
+ template <typename F>
+ void add_action(std::size_t unique_id, std::size_t, F act)
             {
                 if (actions_.size() <= unique_id)
                     actions_.resize(unique_id + 1);
@@ -75,8 +75,8 @@
             typedef boost::function<functor_type> functor_wrapper_type;
 
             // add a semantic action function object
- template <typename Idtype, typename F>
- void add_action(Idtype unique_id, std::size_t state, F act)
+ template <typename F>
+ void add_action(std::size_t unique_id, std::size_t state, F act)
             {
                 if (actions_.size() <= state)
                     actions_.resize(state + 1);

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -212,7 +212,7 @@
         };
 
         ///////////////////////////////////////////////////////////////////////
- // doesn't support no actors
+ // doesn't support no actors, but does support states
         template <typename Iterator, typename TokenValue>
         struct static_data<Iterator, mpl::false_, mpl::true_, TokenValue>
           : static_data<Iterator, mpl::false_, mpl::false_, TokenValue>

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 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -126,10 +126,10 @@
         typedef unused_type token_value_type;
 
         // default constructed tokens correspond to EOI tokens
- token() : id_(boost::lexer::npos) {}
+ token() : id_(id_type(boost::lexer::npos)) {}
 
         // construct an invalid token
- explicit token(int) : id_(0) {}
+ explicit token(int) : id_(id_type(0)) {}
 
         token(id_type id, std::size_t) : id_(id) {}
 

Modified: trunk/boost/spirit/home/lex/lexer/token_def.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/token_def.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/token_def.hpp 2010-11-29 13:48:26 EST (Mon, 29 Nov 2010)
@@ -177,7 +177,7 @@
         explicit token_def(char_type def_, Idtype id_ = Idtype())
           : proto_base_type(terminal_type::make(reference_(*this)))
           , def_(def_)
- , token_id_(std::size_t(Idtype() == id_ ? def_ : id_))
+ , token_id_(Idtype() == id_ ? Idtype(def_) : id_)
           , unique_id_(std::size_t(~0)), token_state_(std::size_t(~0)) {}
 
         explicit token_def(string_type const& def_, Idtype id_ = Idtype())


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