Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66759 - trunk/boost/spirit/home/lex/lexer/lexertl
From: hartmut.kaiser_at_[hidden]
Date: 2010-11-25 13:07:59


Author: hkaiser
Date: 2010-11-25 13:07:57 EST (Thu, 25 Nov 2010)
New Revision: 66759
URL: http://svn.boost.org/trac/boost/changeset/66759

Log:
Spirit: restoring bol state (begin of line) in case lex::pass_fail is used
Text files modified:
   trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp | 7 +++++--
   trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 14 +++++++++++---
   trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp | 15 +++++++++++----
   3 files changed, 27 insertions(+), 9 deletions(-)

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-25 13:07:57 EST (Thu, 25 Nov 2010)
@@ -147,7 +147,8 @@
                 data.reset_value();
                 Iterator end = data.get_first();
                 std::size_t unique_id = boost::lexer::npos;
- std::size_t id = data.next(end, unique_id);
+ bool prev_bol = false;
+ std::size_t id = data.next(end, unique_id, prev_bol);
 
                 if (boost::lexer::npos == id) { // no match
 #if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
@@ -212,7 +213,9 @@
                         data.revert_adjust_start();
 
                     // one of the semantic actions signaled no-match
- return result = result_type(0);
+ data.reset_bol(prev_bol);
+ continue; // retry matching
+// return result = result_type(0);
                 }
 
             // if this token needs to be ignored, just repeat the matching,

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-25 13:07:57 EST (Thu, 25 Nov 2010)
@@ -141,8 +141,10 @@
 
             // The function next() tries to match the next token from the
             // underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
             {
+ prev_bol = bol_;
+
                 typedef basic_iterator_tokeniser<Iterator> tokenizer;
                 return tokenizer::next(state_machine_, bol_, end, last_
                   , unique_id);
@@ -169,6 +171,8 @@
             bool has_value() const { return false; }
             void reset_value() {}
 
+ void reset_bol(bool bol) { bol_ = bol; }
+
         protected:
             Iterator& first_;
             Iterator last_;
@@ -236,8 +240,10 @@
 
             // The function next() tries to match the next token from the
             // underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
             {
+ prev_bol = this->bol_;
+
                 typedef basic_iterator_tokeniser<Iterator> tokenizer;
                 return tokenizer::next(this->state_machine_, state_,
                     this->bol_, end, this->get_eoi(), unique_id);
@@ -327,12 +333,14 @@
             {
                 Iterator end = end_;
                 std::size_t unique_id = boost::lexer::npos;
+ bool bol = this->bol_;
+
                 if (std::size_t(~0) == state)
                     state = this->state_;
 
                 typedef basic_iterator_tokeniser<Iterator> tokenizer;
                 return id == tokenizer::next(this->state_machine_, state,
- this->bol_, end, this->get_eoi(), unique_id);
+ bol, end, this->get_eoi(), unique_id);
             }
 
             // The adjust_start() and revert_adjust_start() are helper

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-25 13:07:57 EST (Thu, 25 Nov 2010)
@@ -160,9 +160,11 @@
 
             // The function next() tries to match the next token from the
             // underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
             {
- std::size_t state;
+ prev_bol = bol_;
+
+ std::size_t state = 0;
                 return next_token_(state, bol_, end, last_, unique_id);
             }
 
@@ -187,6 +189,8 @@
             bool has_value() const { return false; }
             void reset_value() {}
 
+ void reset_bol(bool bol) { bol_ = bol; }
+
         protected:
             Iterator& first_;
             Iterator last_;
@@ -257,8 +261,9 @@
 
             // The function next() tries to match the next token from the
             // underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
             {
+ prev_bol = this->bol_;
                 return this->next_token_(state_, this->bol_, end, this->last_
                   , unique_id);
             }
@@ -349,11 +354,13 @@
             {
                 Iterator end = end_;
                 std::size_t unique_id = boost::lexer::npos;
+ bool bol = this->bol_;
+
                 if (std::size_t(~0) == state)
                     state = this->state_;
 
                 return id == this->next_token_(
- state, this->bol_, end, this->last_, unique_id);
+ state, bol, end, this->last_, unique_id);
             }
 
             // The adjust_start() and revert_adjust_start() are helper


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