|
Boost-Commit : |
From: joel_at_[hidden]
Date: 2008-04-18 22:13:58
Author: djowel
Date: 2008-04-18 22:13:57 EDT (Fri, 18 Apr 2008)
New Revision: 44569
URL: http://svn.boost.org/trac/boost/changeset/44569
Log:
no-case for chsets
Text files modified:
trunk/boost/spirit/home/qi/char/char.hpp | 46 +++++++++++++++++++++++++++++++
trunk/boost/spirit/home/qi/char/meta_grammar.hpp | 59 +++++++++++++++++++++++----------------
trunk/boost/spirit/home/support/component.hpp | 10 +++---
3 files changed, 85 insertions(+), 30 deletions(-)
Modified: trunk/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/char.hpp (original)
+++ trunk/boost/spirit/home/qi/char/char.hpp 2008-04-18 22:13:57 EDT (Fri, 18 Apr 2008)
@@ -17,6 +17,7 @@
#include <boost/spirit/home/support/detail/to_narrow.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/remove_reference.hpp>
+#include <boost/foreach.hpp>
namespace boost { namespace spirit { namespace qi
{
@@ -253,11 +254,56 @@
return result;
}
};
+
+ template <typename Char, typename Elements>
+ struct char_set_component;
}}}
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
+ // char_set_component generator
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char, typename Elements, typename Modifier>
+ struct make_component<qi::domain, qi::char_set<Char>, Elements, Modifier
+ , typename disable_if<
+ is_member_of_modifier<Modifier, spirit::char_class::no_case_base_tag>
+ >::type
+ > : mpl::identity<qi::char_set_component<Char, Elements> >
+ {
+ static qi::char_set_component<Char, Elements>
+ call(Elements const& elements)
+ {
+ return qi::char_set_component<Char, Elements>(
+ fusion::at_c<0>(elements));
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // no_case char_set_component generator
+ ///////////////////////////////////////////////////////////////////////////
+ template <
+ typename Domain, typename Elements, typename Modifier, typename Char
+ >
+ struct make_modified_component<
+ Domain, qi::char_set<Char>, Elements, Modifier
+ , typename enable_if<
+ is_member_of_modifier<Modifier, spirit::char_class::no_case_base_tag>
+ >::type
+ >
+ {
+ typedef qi::char_set_component<Char, Elements> type;
+ typedef typename Modifier::char_set char_set;
+
+ static type
+ call(Elements const& elements)
+ {
+ return qi::char_set_component<Char, Elements>(
+ fusion::at_c<0>(elements), char_set());
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
// no_case_literal_char generator
///////////////////////////////////////////////////////////////////////////
template <
Modified: trunk/boost/spirit/home/qi/char/meta_grammar.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/meta_grammar.hpp (original)
+++ trunk/boost/spirit/home/qi/char/meta_grammar.hpp 2008-04-18 22:13:57 EDT (Fri, 18 Apr 2008)
@@ -18,30 +18,6 @@
namespace boost { namespace spirit { namespace qi
{
- template <typename Char>
- struct char_set;
-
- template <typename Char, typename Elements>
- struct char_set_component;
-}}}
-
-namespace boost { namespace spirit { namespace traits
-{
- template <typename Char, typename Elements, typename Modifier>
- struct make_component<qi::domain, qi::char_set<Char>, Elements, Modifier>
- : mpl::identity<qi::char_set_component<Char, Elements> >
- {
- static qi::char_set_component<Char, Elements>
- call(Elements const& elements)
- {
- return qi::char_set_component<Char, Elements>(
- fusion::at_c<0>(elements));
- }
- };
-}}}
-
-namespace boost { namespace spirit { namespace qi
-{
///////////////////////////////////////////////////////////////////////////
// forwards
///////////////////////////////////////////////////////////////////////////
@@ -66,7 +42,7 @@
struct eol_director;
struct eoi_director;
-
+
///////////////////////////////////////////////////////////////////////////
struct char_meta_grammar;
@@ -243,6 +219,39 @@
}
}
+ template <typename CharSetClass> // no-case version
+ char_set_component(Char const* definition, CharSetClass)
+ : ptr(new detail::basic_chset<Char>())
+ {
+ Char ch = *definition++;
+ while (ch)
+ {
+ Char next = *definition++;
+ if (next == '-')
+ {
+ next = *definition++;
+ if (next == 0)
+ {
+ ptr->set(CharSetClass::tolower(ch));
+ ptr->set(CharSetClass::tolower('-'));
+ ptr->set(CharSetClass::toupper(ch));
+ ptr->set(CharSetClass::toupper('-'));
+ break;
+ }
+ ptr->set(CharSetClass::tolower(ch)
+ , CharSetClass::tolower(next));
+ ptr->set(CharSetClass::toupper(ch)
+ , CharSetClass::toupper(next));
+ }
+ else
+ {
+ ptr->set(CharSetClass::tolower(ch));
+ ptr->set(CharSetClass::toupper(ch));
+ }
+ ch = next;
+ }
+ }
+
boost::shared_ptr<detail::basic_chset<Char> > ptr;
};
Modified: trunk/boost/spirit/home/support/component.hpp
==============================================================================
--- trunk/boost/spirit/home/support/component.hpp (original)
+++ trunk/boost/spirit/home/support/component.hpp 2008-04-18 22:13:57 EDT (Fri, 18 Apr 2008)
@@ -191,7 +191,7 @@
namespace result_of
{
template <
- typename Domain, typename Expr, typename State = unused_type,
+ typename Domain, typename Expr, typename State = unused_type,
typename Visitor = unused_type
>
struct as_component
@@ -208,7 +208,7 @@
// special case for arrays
template <
- typename Domain, typename T, int N,
+ typename Domain, typename T, int N,
typename State, typename Visitor>
struct as_component<Domain, T[N], State, Visitor>
{
@@ -243,8 +243,8 @@
inline typename result_of::as_component<Domain, Expr>::type
as_component(Domain, Expr const& xpr, State const& state, Visitor& visitor)
{
- typedef typename
- result_of::as_component<Domain, Expr, State, Visitor>::grammar
+ typedef typename
+ result_of::as_component<Domain, Expr, State, Visitor>::grammar
grammar;
return grammar()(proto::as_expr(xpr), state, visitor);
};
@@ -271,7 +271,7 @@
{
template <
typename Domain, typename Director
- , typename Elements, typename Modifier>
+ , typename Elements, typename Modifier, typename Enable = void>
struct make_component
: mpl::identity<component<Domain, Director, Elements> >
{
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