|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54225 - trunk/boost/spirit/home/lex/lexer/lexertl
From: hartmut.kaiser_at_[hidden]
Date: 2009-06-22 16:01:36
Author: hkaiser
Date: 2009-06-22 16:01:35 EDT (Mon, 22 Jun 2009)
New Revision: 54225
URL: http://svn.boost.org/trac/boost/changeset/54225
Log:
Spirit: improved encapsulation for lexer semantic actions context type
Text files modified:
trunk/boost/spirit/home/lex/lexer/lexertl/functor.hpp | 24 ++++++++++++------------
trunk/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 2 ++
trunk/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp | 4 ++--
trunk/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp | 6 +++++-
4 files changed, 21 insertions(+), 15 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 2009-06-22 16:01:35 EDT (Mon, 22 Jun 2009)
@@ -127,24 +127,24 @@
template <typename MultiPass>
static result_type& get_next(MultiPass& mp, result_type& result)
{
- shared& data = mp.shared->ftor;
+ shared& data = mp.shared()->ftor;
do {
- if (data.first_ == data.last_)
+ if (data.get_first() == data.get_last())
#if defined(BOOST_SPIRIT_STATIC_EOF)
return result = eof;
#else
return result = mp.ftor.eof;
#endif
- Iterator end = data.first_;
+ Iterator end = data.get_first();
std::size_t unique_id = boost::lexer::npos;
std::size_t id = data.next(end, unique_id);
if (boost::lexer::npos == id) { // no match
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
std::string next;
- Iterator it = data.first_;
- for (std::size_t i = 0; i < 10 && it != data.last_; ++it, ++i)
+ Iterator it = data.get_first();
+ for (std::size_t i = 0; i < 10 && it != data.get_last(); ++it, ++i)
next += *it;
std::cerr << "Not matched, in state: " << data.get_state()
@@ -164,12 +164,12 @@
{
std::string next;
Iterator it = end;
- for (std::size_t i = 0; i < 10 && it != data.last_; ++it, ++i)
+ for (std::size_t i = 0; i < 10 && it != data.get_last(); ++it, ++i)
next += *it;
std::cerr << "Matched: " << id << ", in state: "
<< data.get_state() << ", string: >"
- << std::basic_string<char_type>(data.first_, end) << "<"
+ << std::basic_string<char_type>(data.get_first(), end) << "<"
<< ", lookahead: >" << next << "<" << std::endl;
}
#endif
@@ -187,8 +187,8 @@
if (pass_flags::pass_normal == pass) {
// return matched token, advancing 'data.first_' past the
// matched sequence
- assign_on_exit<Iterator> on_exit(data.first_, end);
- return result = result_type(id, state, data.first_, end);
+ assign_on_exit<Iterator> on_exit(data.get_first(), end);
+ return result = result_type(id, state, data.get_first(), end);
}
else if (pass_flags::pass_fail == pass) {
// if the data.first_ got adjusted above, revert this adjustment
@@ -210,8 +210,8 @@
template <typename MultiPass>
static std::size_t set_state(MultiPass& mp, std::size_t state)
{
- std::size_t oldstate = mp.shared->ftor.get_state();
- mp.shared->ftor.set_state(state);
+ std::size_t oldstate = mp.shared()->ftor.get_state();
+ mp.shared()->ftor.set_state(state);
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
std::cerr << "Switching state from: " << oldstate
@@ -225,7 +225,7 @@
static std::size_t
map_state(MultiPass const& mp, char_type const* statename)
{
- return mp.shared->ftor.get_state_id(statename);
+ return mp.shared()->ftor.get_state_id(statename);
}
// we don't need this, but it must be there
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 2009-06-22 16:01:35 EDT (Mon, 22 Jun 2009)
@@ -142,7 +142,9 @@
std::size_t get_state() const { return 0; }
void set_state(std::size_t state) {}
+ Iterator& get_first() { return first_; }
Iterator const& get_first() const { return first_; }
+ Iterator const& get_last() const { return last_; }
protected:
Iterator& first_;
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 2009-06-22 16:01:35 EDT (Mon, 22 Jun 2009)
@@ -56,7 +56,7 @@
// Note: all arguments might be changed by the invoked semantic
// action
BOOST_SCOPED_ENUM(pass_flags) match = pass_flags::pass_normal;
- actions_[unique_id](data.first_, end, match, id, data);
+ actions_[unique_id](data.get_first(), end, match, id, data);
return match;
}
@@ -105,7 +105,7 @@
// Note: all arguments might be changed by the invoked semantic
// action
BOOST_SCOPED_ENUM(pass_flags) match = pass_flags::pass_normal;
- actions[unique_id](data.first_, end, match, id, data);
+ actions[unique_id](data.get_first(), end, match, id, data);
return match;
}
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 2009-06-22 16:01:35 EDT (Mon, 22 Jun 2009)
@@ -160,10 +160,14 @@
std::size_t get_state() const { return 0; }
void set_state(std::size_t state) {}
+ Iterator& get_first() { return first_; }
+ Iterator const& get_first() const { return first_; }
+ Iterator const& get_last() const { return last_; }
+
+ protected:
Iterator& first_;
Iterator last_;
- protected:
next_token_functor next_token_;
get_state_name_type get_state_name_;
};
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