|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67350 - trunk/boost/spirit/home/lex/qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-12-19 13:32:02
Author: hkaiser
Date: 2010-12-19 13:32:02 EST (Sun, 19 Dec 2010)
New Revision: 67350
URL: http://svn.boost.org/trac/boost/changeset/67350
Log:
Spirit: added matching of any tokens by specifying qi::token/qi::tokenid without parameter
Text files modified:
trunk/boost/spirit/home/lex/qi/plain_token.hpp | 19 +++++++++++++++++--
trunk/boost/spirit/home/lex/qi/plain_tokenid.hpp | 18 +++++++++++++++++-
2 files changed, 34 insertions(+), 3 deletions(-)
Modified: trunk/boost/spirit/home/lex/qi/plain_token.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/qi/plain_token.hpp (original)
+++ trunk/boost/spirit/home/lex/qi/plain_token.hpp 2010-12-19 13:32:02 EST (Sun, 19 Dec 2010)
@@ -31,6 +31,11 @@
// Enablers
///////////////////////////////////////////////////////////////////////////
+ // enables token
+ template <>
+ struct use_terminal<qi::domain, tag::token>
+ : mpl::true_ {};
+
// enables token(id)
template <typename A0>
struct use_terminal<qi::domain
@@ -82,7 +87,7 @@
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if (id_type(id) == t.id()) {
+ if (std::size_t(~0) == t.id() || id_type(id) == t.id()) {
spirit::traits::assign_to(t, attr);
++first;
return true;
@@ -103,6 +108,17 @@
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::token, Modifiers>
+ {
+ typedef plain_token<std::size_t> result_type;
+
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type(std::size_t(~0));
+ }
+ };
+
template <typename Modifiers, typename TokenId>
struct make_primitive<terminal_ex<tag::token, fusion::vector1<TokenId> >
, Modifiers>
@@ -115,7 +131,6 @@
return result_type(fusion::at_c<0>(term.args));
}
};
-
}}}
#endif
Modified: trunk/boost/spirit/home/lex/qi/plain_tokenid.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/qi/plain_tokenid.hpp (original)
+++ trunk/boost/spirit/home/lex/qi/plain_tokenid.hpp 2010-12-19 13:32:02 EST (Sun, 19 Dec 2010)
@@ -31,6 +31,11 @@
// Enablers
///////////////////////////////////////////////////////////////////////////
+ // enables tokenid
+ template <>
+ struct use_terminal<qi::domain, tag::tokenid>
+ : mpl::true_ {};
+
// enables tokenid(id)
template <typename A0>
struct use_terminal<qi::domain
@@ -83,7 +88,7 @@
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if (id_type(id) == t.id()) {
+ if (std::size_t(~0) == t.id() || id_type(id) == t.id()) {
spirit::traits::assign_to(id, attr);
++first;
return true;
@@ -104,6 +109,17 @@
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::tokenid, Modifiers>
+ {
+ typedef plain_token<std::size_t> result_type;
+
+ result_type operator()(unused_type, unused_type) const
+ {
+ return result_type(std::size_t(~0));
+ }
+ };
+
template <typename Modifiers, typename TokenId>
struct make_primitive<terminal_ex<tag::tokenid, fusion::vector1<TokenId> >
, Modifiers>
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