|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66633 - in trunk/boost/spirit/home/lex/lexer: . lexertl
From: hartmut.kaiser_at_[hidden]
Date: 2010-11-18 09:46:32
Author: hkaiser
Date: 2010-11-18 09:46:18 EST (Thu, 18 Nov 2010)
New Revision: 66633
URL: http://svn.boost.org/trac/boost/changeset/66633
Log:
Spirit: allowing "*" as a state name to associate a token definition with all states
Text files modified:
trunk/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 11 +++++++++++
trunk/boost/spirit/home/lex/lexer/token_def.hpp | 6 +++++-
2 files changed, 16 insertions(+), 1 deletions(-)
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-18 09:46:18 EST (Thu, 18 Nov 2010)
@@ -148,6 +148,8 @@
struct dummy { void true_() {}; };
typedef void (dummy::*safe_bool)();
+ static std::size_t const all_states_id = static_cast<std::size_t>(-2);
+
public:
operator safe_bool() const
{ return initialized_dfa_ ? &dummy::true_ : 0; }
@@ -226,6 +228,8 @@
{
add_state(state);
initialized_dfa_ = false;
+ if (state == all_states())
+ return rules_.add(state, tokendef, token_id, rules_.dot());
return rules_.add(state, tokendef, token_id, state);
}
@@ -249,6 +253,9 @@
}
std::size_t add_state(char_type const* state)
{
+ if (state == all_states())
+ return all_states_id;
+
std::size_t stateid = rules_.state(state);
if (boost::lexer::npos == stateid) {
stateid = rules_.add_state(state);
@@ -260,6 +267,10 @@
{
return string_type(rules_.initial());
}
+ string_type all_states() const
+ {
+ return string_type(rules_.all_states());
+ }
// Register a semantic action with the given id
template <typename F>
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-18 09:46:18 EST (Thu, 18 Nov 2010)
@@ -58,6 +58,8 @@
typedef typename proto::terminal<reference_>::type terminal_type;
typedef proto::extends<terminal_type, token_def> proto_base_type;
+ static std::size_t const all_states_id = static_cast<std::size_t>(-2);
+
public:
// Qi interface: metafunction calculating parser return type
template <typename Context, typename Iterator>
@@ -97,7 +99,9 @@
BOOST_ASSERT(std::size_t(~0) != token_state_);
token_type const& t = *first;
- if (token_id_ == t.id() && token_state_ == t.state()) {
+ if (token_id_ == t.id() &&
+ (all_states_id == token_state_ || token_state_ == t.state()))
+ {
spirit::traits::assign_to(t, attr);
++first;
return true;
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