Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53576 - trunk/boost/spirit/home/support/detail/lexer
From: jamin.hanson_at_[hidden]
Date: 2009-06-02 15:01:39


Author: ben_hanson
Date: 2009-06-02 15:01:39 EDT (Tue, 02 Jun 2009)
New Revision: 53576
URL: http://svn.boost.org/trac/boost/changeset/53576

Log:
Added add_macros() and merge_macros().
Text files modified:
   trunk/boost/spirit/home/support/detail/lexer/rules.hpp | 55 ++++++++++++++++++++++++++-------------
   1 files changed, 37 insertions(+), 18 deletions(-)

Modified: trunk/boost/spirit/home/support/detail/lexer/rules.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/lexer/rules.hpp (original)
+++ trunk/boost/spirit/home/support/detail/lexer/rules.hpp 2009-06-02 15:01:39 EDT (Tue, 02 Jun 2009)
@@ -231,6 +231,43 @@
         }
     }
 
+ void add_macros (const basic_rules<CharT> &rules_)
+ {
+ const string_pair_deque &macros_ = rules_.macrodeque ();
+ typename string_pair_deque::const_iterator macro_iter_ =
+ macros_.begin ();
+ typename string_pair_deque::const_iterator macro_end_ =
+ macros_.end ();
+
+ for (; macro_iter_ != macro_end_; ++macro_iter_)
+ {
+ add_macro (macro_iter_->first.c_str (),
+ macro_iter_->second.c_str ());
+ }
+ }
+
+ void merge_macros (const basic_rules<CharT> &rules_)
+ {
+ const string_pair_deque &macros_ = rules_.macrodeque ();
+ typename string_pair_deque::const_iterator macro_iter_ =
+ macros_.begin ();
+ typename string_pair_deque::const_iterator macro_end_ =
+ macros_.end ();
+ typename string_set::const_iterator macro_dest_iter_;
+ typename string_set::const_iterator macro_dest_end_ = _macroset.end ();
+
+ for (; macro_iter_ != macro_end_; ++macro_iter_)
+ {
+ macro_dest_iter_ = _macroset.find (macro_iter_->first);
+
+ if (macro_dest_iter_ == macro_dest_end_)
+ {
+ add_macro (macro_iter_->first.c_str (),
+ macro_iter_->second.c_str ());
+ }
+ }
+ }
+
     std::size_t add (const CharT *regex_, const std::size_t id_)
     {
         return add (string (regex_), id_);
@@ -295,13 +332,6 @@
 
     void add (const CharT *from_, const basic_rules<CharT> &rules_, const CharT *to_)
     {
- const string_pair_deque &macros_ = rules_.macrodeque ();
- typename string_pair_deque::const_iterator macro_iter_ =
- macros_.begin ();
- typename string_pair_deque::const_iterator macro_end_ =
- macros_.end ();
- typename string_set::const_iterator macro_dest_iter_;
- typename string_set::const_iterator macro_dest_end_ = _macroset.end ();
         const bool star_ = *from_ == '*' && *(from_ + 1) == 0;
         const bool dot_ = *to_ == '.' && *(to_ + 1) == 0;
         std::size_t state_ = 0;
@@ -313,17 +343,6 @@
         typename id_vector::const_iterator id_iter_;
         typename id_vector::const_iterator uid_iter_;
 
- for (; macro_iter_ != macro_end_; ++macro_iter_)
- {
- macro_dest_iter_ = _macroset.find (macro_iter_->first);
-
- if (macro_dest_iter_ == macro_dest_end_)
- {
- add_macro (macro_iter_->first.c_str (),
- macro_iter_->second.c_str ());
- }
- }
-
         if (star_)
         {
             typename string_deque_deque::const_iterator all_regexes_iter_ =


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