Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52901 - trunk/boost/spirit/home/lex/lexer
From: hartmut.kaiser_at_[hidden]
Date: 2009-05-11 08:34:38


Author: hkaiser
Date: 2009-05-11 08:34:36 EDT (Mon, 11 May 2009)
New Revision: 52901
URL: http://svn.boost.org/trac/boost/changeset/52901

Log:
Spirit: Added missing accessor functions to lex::char_token_def and lex::string_token_def
Text files modified:
   trunk/boost/spirit/home/lex/lexer/char_token_def.hpp | 2 ++
   trunk/boost/spirit/home/lex/lexer/string_token_def.hpp | 9 +++++++--
   2 files changed, 9 insertions(+), 2 deletions(-)

Modified: trunk/boost/spirit/home/lex/lexer/char_token_def.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/char_token_def.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/char_token_def.hpp 2009-05-11 08:34:36 EDT (Mon, 11 May 2009)
@@ -70,6 +70,8 @@
                 static_cast<std::size_t>(ch));
         }
 
+ std::size_t id() const { return static_cast<std::size_t>(ch); }
+
         char_type ch;
     };
 

Modified: trunk/boost/spirit/home/lex/lexer/string_token_def.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/string_token_def.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/string_token_def.hpp 2009-05-11 08:34:36 EDT (Mon, 11 May 2009)
@@ -58,16 +58,21 @@
         typedef std::basic_string<char_type> string_type;
 
         string_token_def(typename add_reference<String>::type str)
- : str_(str) {}
+ : str_(str), id_(~0U) {}
 
         template <typename LexerDef, typename State>
         void collect(LexerDef& lexdef, State const& state) const
         {
             typedef typename LexerDef::id_type id_type;
- lexdef.add_token (state.c_str(), str_, next_id<id_type>::get());
+ if (~0U == id_)
+ id_ = next_id<id_type>::get();
+ lexdef.add_token (state.c_str(), str_, id_);
         }
 
+ std::size_t id() const { return id_; }
+
         string_type str_;
+ std::size_t id_;
     };
 
     ///////////////////////////////////////////////////////////////////////////


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