|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67754 - in trunk: boost/spirit/home/karma/char boost/spirit/home/karma/detail boost/spirit/home/karma/numeric boost/spirit/home/karma/string boost/spirit/home/lex/lexer boost/spirit/home/qi/char boost/spirit/home/qi/detail boost/spirit/home/qi/numeric boost/spirit/home/qi/string boost/spirit/home/support boost/thread/win32 libs/spirit/doc libs/spirit/doc/lex libs/spirit/test libs/spirit/test/karma libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-01-07 12:50:15
Author: hkaiser
Date: 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
New Revision: 67754
URL: http://svn.boost.org/trac/boost/changeset/67754
Log:
Spirit: replaced proto::lit with spirit::lit
Added:
trunk/boost/spirit/home/karma/detail/enable_lit.hpp (contents, props changed)
trunk/boost/spirit/home/qi/detail/enable_lit.hpp (contents, props changed)
trunk/boost/spirit/home/support/numeric_traits.hpp (contents, props changed)
trunk/libs/spirit/test/karma/char3.cpp (contents, props changed)
trunk/libs/spirit/test/qi/char1.cpp
- copied, changed from r67745, /trunk/libs/spirit/test/qi/char.cpp
trunk/libs/spirit/test/qi/char2.cpp (contents, props changed)
trunk/libs/spirit/test/qi/lit1.cpp
- copied, changed from r67745, /trunk/libs/spirit/test/qi/lit.cpp
trunk/libs/spirit/test/qi/lit2.cpp (contents, props changed)
Removed:
trunk/libs/spirit/test/qi/char.cpp
trunk/libs/spirit/test/qi/lit.cpp
Text files modified:
trunk/boost/spirit/home/karma/char/char.hpp | 101 ++++++++++++++++++++++++++-------------
trunk/boost/spirit/home/karma/numeric/bool.hpp | 39 +++++++++++++++
trunk/boost/spirit/home/karma/numeric/int.hpp | 41 +++++++++++++++
trunk/boost/spirit/home/karma/numeric/real.hpp | 38 +++++++++++++++
trunk/boost/spirit/home/karma/numeric/uint.hpp | 39 +++++++++++++++
trunk/boost/spirit/home/karma/string/lit.hpp | 82 ++++++++++++++++++++++---------
trunk/boost/spirit/home/lex/lexer/char_token_def.hpp | 4 -
trunk/boost/spirit/home/qi/char/char.hpp | 62 +++++++++++++++++++++---
trunk/boost/spirit/home/qi/numeric/bool.hpp | 16 +++--
trunk/boost/spirit/home/qi/numeric/int.hpp | 6 +-
trunk/boost/spirit/home/qi/numeric/real.hpp | 12 ++-
trunk/boost/spirit/home/qi/numeric/uint.hpp | 26 +++++----
trunk/boost/spirit/home/qi/string/lit.hpp | 53 ++++++++++++++++++++
trunk/boost/spirit/home/support/common_terminals.hpp | 29 +++++++++--
trunk/boost/spirit/home/support/string_traits.hpp | 22 ++++++++
trunk/boost/thread/win32/thread_heap_alloc.hpp | 4
trunk/libs/spirit/doc/lex/token_primitives.qbk | 3 -
trunk/libs/spirit/doc/what_s_new.qbk | 7 ++
trunk/libs/spirit/test/Jamfile | 7 +
trunk/libs/spirit/test/karma/char1.cpp | 2
trunk/libs/spirit/test/karma/char2.cpp | 2
trunk/libs/spirit/test/karma/encoding.cpp | 18 ++----
trunk/libs/spirit/test/karma/int1.cpp | 2
trunk/libs/spirit/test/karma/int2.cpp | 2
trunk/libs/spirit/test/karma/int3.cpp | 2
trunk/libs/spirit/test/karma/real3.cpp | 1
trunk/libs/spirit/test/qi/char1.cpp | 16 ------
trunk/libs/spirit/test/qi/lit1.cpp | 48 +++++++-----------
trunk/libs/spirit/test/qi/rule1.cpp | 2
trunk/libs/spirit/test/qi/rule2.cpp | 2
trunk/libs/spirit/test/qi/rule3.cpp | 2
trunk/libs/spirit/test/qi/rule4.cpp | 2
32 files changed, 511 insertions(+), 181 deletions(-)
Modified: trunk/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/char/char.hpp (original)
+++ trunk/boost/spirit/home/karma/char/char.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -24,12 +24,14 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/generate_to.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/cons.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
#include <string>
///////////////////////////////////////////////////////////////////////////////
@@ -51,6 +53,12 @@
>
> : mpl::true_ {};
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> > // enables lit('x')
+ , typename enable_if<traits::is_char<A0> >::type>
+ : mpl::true_ {};
+
template <typename CharEncoding, typename A0, typename A1>
struct use_terminal<karma::domain
, terminal_ex<
@@ -81,13 +89,13 @@
template <>
struct use_terminal<karma::domain, wchar_t[2]> // enables L"x"
: mpl::true_ {};
-
}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace karma
{
using spirit::lit; // lit('x') is equivalent to 'x'
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
//
@@ -243,13 +251,19 @@
///////////////////////////////////////////////////////////////////////////
// character set generator
- template <typename CharEncoding, typename Tag>
+ template <typename CharEncoding, typename Tag, bool no_attribute>
struct char_set
- : char_generator<char_set<CharEncoding, Tag>, CharEncoding, Tag>
+ : char_generator<char_set<CharEncoding, Tag, no_attribute>
+ , CharEncoding, Tag>
{
typedef typename CharEncoding::char_type char_type;
typedef CharEncoding char_encoding;
+ template <typename Context, typename Unused>
+ struct attribute
+ : mpl::if_c<no_attribute, unused_type, char_type>
+ {};
+
template <typename String>
char_set(String const& str)
{
@@ -391,45 +405,65 @@
}
};
- // char_(...)
- template <typename CharEncoding, typename Modifiers, typename A0>
- struct make_primitive<
- terminal_ex<
- tag::char_code<tag::char_, CharEncoding>
- , fusion::vector1<A0>
- >
- , Modifiers>
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
{
- static bool const lower =
- has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
- static bool const upper =
- has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+ template <typename CharEncoding, typename Modifiers, typename A0
+ , bool no_attribute>
+ struct make_char_direct
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- typedef typename spirit::detail::get_encoding_with_case<
- Modifiers, CharEncoding, lower || upper>::type encoding;
- typedef typename detail::get_casetag<
- Modifiers, lower || upper>::type tag;
-
- typedef typename mpl::if_<
- traits::is_string<A0>
- , char_set<encoding, tag>
- , literal_char<encoding, tag, false>
- >::type result_type;
+ typedef typename spirit::detail::get_encoding_with_case<
+ Modifiers, CharEncoding, lower || upper>::type encoding;
+ typedef typename detail::get_casetag<
+ Modifiers, lower || upper>::type tag;
+
+ typedef typename mpl::if_<
+ traits::is_string<A0>
+ , char_set<encoding, tag, no_attribute>
+ , literal_char<encoding, tag, no_attribute>
+ >::type result_type;
- template <typename Terminal>
- result_type operator()(Terminal const& term, unused_type) const
- {
- return result_type(fusion::at_c<0>(term.args));
- }
- };
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
+ }
+
+ // char_(...), lit(...)
+ template <typename CharEncoding, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::char_, CharEncoding>
+ , fusion::vector1<A0> >
+ , Modifiers>
+ : detail::make_char_direct<CharEncoding, Modifiers, A0, false>
+ {};
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_char<A0> >::type>
+ : detail::make_char_direct<
+ typename traits::char_encoding_from_char<
+ typename traits::char_type_of<A0>::type>::type
+ , Modifiers, A0, true>
+ {};
+
+ ///////////////////////////////////////////////////////////////////////////
// char_("x")
template <typename CharEncoding, typename Modifiers, typename Char>
struct make_primitive<
terminal_ex<
tag::char_code<tag::char_, CharEncoding>
- , fusion::vector1<Char(&)[2]> // For single char strings
- >
+ , fusion::vector1<Char(&)[2]> > // For single char strings
, Modifiers>
{
static bool const lower =
@@ -451,6 +485,7 @@
}
};
+ ///////////////////////////////////////////////////////////////////////////
// char_('a', 'z')
template <typename CharEncoding, typename Modifiers, typename A0, typename A1>
struct make_primitive<
Added: trunk/boost/spirit/home/karma/detail/enable_lit.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/karma/detail/enable_lit.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,29 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#if !defined(BOOST_SPIRIT_KARMA_DETAIL_ENABLE_LIT_JAN_06_2011_1009PM)
+#define BOOST_SPIRIT_KARMA_DETAIL_ENABLE_LIT_JAN_06_2011_1009PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
+#include <boost/spirit/home/karma/meta_compiler.hpp>
+#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+
+namespace boost { namespace spirit
+{
+ // enables lazy lit(...) for karma
+ template <>
+ struct use_lazy_terminal<karma::domain, tag::lit, 1>
+ : mpl::true_ {};
+}}
+
+#endif
+
Modified: trunk/boost/spirit/home/karma/numeric/bool.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/bool.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/bool.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -11,9 +11,12 @@
#endif
#include <limits>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/numeric_traits.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/karma/meta_compiler.hpp>
@@ -21,6 +24,7 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/extract_from.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/karma/numeric/bool_policies.hpp>
#include <boost/spirit/home/karma/numeric/detail/bool_utils.hpp>
@@ -98,6 +102,12 @@
, tag::stateful_tag<Policies, tag::bool_, T>, 1>
: mpl::true_ {};
+ // enables lit(bool)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_bool<A0> >::type>
+ : mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
@@ -111,6 +121,7 @@
using spirit::false__type;
using spirit::lit; // lit(true) is equivalent to true
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
// This specialization is used for bool generators not having a direct
@@ -337,7 +348,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers, typename A0>
struct make_primitive<
- terminal_ex<tag::bool_, fusion::vector1<A0> >, Modifiers>
+ terminal_ex<tag::bool_, fusion::vector1<A0> >, Modifiers>
: detail::make_bool_direct<Modifiers> {};
template <typename T, typename Policies, typename A0, typename Modifiers>
@@ -378,6 +389,32 @@
struct make_primitive<bool, Modifiers>
: detail::basic_bool_literal<Modifiers> {};
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_bool<A0> >::type>
+ : detail::basic_bool_literal<Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_bool_generator<
+ bool
+ , typename spirit::detail::get_encoding_with_case<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , bool_policies<>, true
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
}}}
#endif
Modified: trunk/boost/spirit/home/karma/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/int.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -11,9 +11,13 @@
#endif
#include <limits>
+#include <boost/config.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/numeric_traits.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/support/container.hpp>
@@ -23,6 +27,7 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/extract_from.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
#include <boost/fusion/include/at.hpp>
@@ -72,7 +77,7 @@
///////////////////////////////////////////////////////////////////////////
template <>
- struct use_terminal<karma::domain, short> // enables lit(short(0))
+ struct use_terminal<karma::domain, short> // enables lit(short(0))
: mpl::true_ {};
template <>
@@ -152,6 +157,12 @@
, 1 // arity
> : mpl::true_ {};
+ // enables lit(int)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_int<A0> >::type>
+ : mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
@@ -169,6 +180,7 @@
#endif
using spirit::lit; // lit(1) is equivalent to 1
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
// This specialization is used for int generators not having a direct
@@ -471,6 +483,33 @@
: detail::basic_int_literal<boost::long_long_type, Modifiers> {};
#endif
+ // lit(int)
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_int<A0> >::type>
+ : detail::basic_int_literal<A0, Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_int_generator<
+ A0
+ , typename spirit::detail::get_encoding_with_case<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, false, true
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
}}}
#endif
Modified: trunk/boost/spirit/home/karma/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/real.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -11,8 +11,12 @@
#endif
#include <boost/config/no_tr1/cmath.hpp>
+#include <boost/config.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/numeric_traits.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/support/container.hpp>
@@ -23,6 +27,7 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/extract_from.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/karma/numeric/real_policies.hpp>
#include <boost/spirit/home/karma/numeric/detail/real_utils.hpp>
@@ -132,6 +137,12 @@
, 1 // arity
> : mpl::true_ {};
+ // enables lit(double)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_real<A0> >::type>
+ : mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
@@ -406,6 +417,33 @@
struct make_primitive<long double, Modifiers>
: detail::basic_real_literal<long double, Modifiers> {};
+ // lit(double)
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_real<A0> >::type>
+ : detail::basic_real_literal<A0, Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_real_generator<
+ A0, real_policies<A0>
+ , typename spirit::detail::get_encoding_with_case<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , true
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
}}}
#endif // defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)
Modified: trunk/boost/spirit/home/karma/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/uint.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -13,10 +13,11 @@
#include <limits>
#include <boost/config.hpp>
#include <boost/mpl/bool.hpp>
-#include <boost/mpl/not.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
+#include <boost/spirit/home/support/numeric_traits.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/support/container.hpp>
@@ -26,6 +27,7 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/extract_from.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp>
#include <boost/fusion/include/at.hpp>
@@ -194,6 +196,12 @@
, 1 // arity
> : mpl::true_ {};
+ // enables lit(uint)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_uint<A0> >::type>
+ : mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
@@ -217,6 +225,7 @@
using spirit::hex_type;
using spirit::lit; // lit(1U) is equivalent to 1U
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
// This specialization is used for unsigned int generators not having a
@@ -480,6 +489,7 @@
, Modifiers>
: detail::make_uint_direct<T, Modifiers, Radix> {};
+ ///////////////////////////////////////////////////////////////////////////
namespace detail
{
template <typename T, typename Modifiers>
@@ -526,6 +536,33 @@
: detail::basic_uint_literal<boost::ulong_long_type, Modifiers> {};
#endif
+ // lit(uint)
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_uint<A0> >::type>
+ : detail::basic_uint_literal<A0, Modifiers>
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_uint_generator<
+ A0
+ , typename spirit::detail::get_encoding_with_case<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, true
+ > result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
}}}
#endif
Modified: trunk/boost/spirit/home/karma/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/string/lit.hpp (original)
+++ trunk/boost/spirit/home/karma/string/lit.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -26,6 +26,7 @@
#include <boost/spirit/home/karma/detail/extract_from.hpp>
#include <boost/spirit/home/karma/detail/string_generate.hpp>
#include <boost/spirit/home/karma/detail/string_compare.hpp>
+#include <boost/spirit/home/karma/detail/enable_lit.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/cons.hpp>
@@ -33,6 +34,7 @@
#include <boost/mpl/or.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/utility/enable_if.hpp>
#include <string>
///////////////////////////////////////////////////////////////////////////////
@@ -64,11 +66,21 @@
, tag::char_code<tag::string, CharEncoding>
, 1 /*arity*/
> : mpl::true_ {};
+
+ // enables lit(str)
+ template <typename A0>
+ struct use_terminal<karma::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_string<A0> >::type>
+ : mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace karma
{
+ using spirit::lit;
+ using spirit::lit_type;
+
///////////////////////////////////////////////////////////////////////////
// generate literal strings from a given parameter
///////////////////////////////////////////////////////////////////////////
@@ -249,33 +261,55 @@
}
};
- template <typename CharEncoding, typename Modifiers, typename A0>
- struct make_primitive<
- terminal_ex<
- tag::char_code<tag::string, CharEncoding>
- , fusion::vector1<A0> >
- , Modifiers>
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
{
- static bool const lower =
- has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
- static bool const upper =
- has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+ template <typename CharEncoding, typename Modifiers, typename A0
+ , bool no_attribute>
+ struct make_string_direct
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef typename add_const<A0>::type const_string;
+ typedef literal_string<
+ const_string
+ , typename spirit::detail::get_encoding_with_case<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , no_attribute
+ > result_type;
- typedef typename add_const<A0>::type const_string;
- typedef literal_string<
- const_string
- , typename spirit::detail::get_encoding_with_case<
- Modifiers, unused_type, lower || upper>::type
- , typename detail::get_casetag<Modifiers, lower || upper>::type
- , false
- > result_type;
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
+ }
- template <typename Terminal>
- result_type operator()(Terminal const& term, unused_type) const
- {
- return result_type(fusion::at_c<0>(term.args));
- }
- };
+ // string("..."), lit("...")
+ template <typename CharEncoding, typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<
+ tag::char_code<tag::string, CharEncoding>
+ , fusion::vector1<A0> >
+ , Modifiers>
+ : detail::make_string_direct<CharEncoding, Modifiers, A0, false>
+ {};
+
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_string<A0> >::type>
+ : detail::make_string_direct<
+ typename traits::char_encoding_from_char<
+ typename traits::char_type_of<A0>::type>::type
+ , Modifiers, A0, true>
+ {};
}}} // namespace boost::spirit::karma
namespace boost { namespace spirit { namespace traits
Modified: trunk/boost/spirit/home/lex/lexer/char_token_def.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/char_token_def.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/char_token_def.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -44,13 +44,10 @@
, fusion::vector1<A0>
>
> : mpl::true_ {};
-
}}
namespace boost { namespace spirit { namespace lex
{
- using spirit::lit; // lit('x') is equivalent to 'x'
-
// use char_ from standard character set by default
using spirit::standard::char_type;
using spirit::standard::char_;
@@ -184,7 +181,6 @@
return result_type(fusion::at_c<0>(term.args)[0]);
}
};
-
}}} // namespace boost::spirit::lex
#endif
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 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2010 Bryce Lelbach
Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -21,9 +22,11 @@
#include <boost/spirit/home/qi/char/char_class.hpp>
#include <boost/spirit/home/qi/meta_compiler.hpp>
#include <boost/spirit/home/qi/auxiliary/lazy.hpp>
+#include <boost/spirit/home/qi/detail/enable_lit.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/assert.hpp>
+#include <boost/mpl/identity.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <string>
@@ -89,11 +92,19 @@
template <>
struct use_terminal<qi::domain, wchar_t[2]> // enables L"x"
: mpl::true_ {};
+
+ // enables lit(...)
+ template <typename A0>
+ struct use_terminal<qi::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_char<A0> >::type>
+ : mpl::true_ {};
}}
namespace boost { namespace spirit { namespace qi
{
using spirit::lit; // lit('x') is equivalent to 'x'
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
// Parser for a single character
@@ -254,9 +265,11 @@
///////////////////////////////////////////////////////////////////////////
// Parser for a character set
///////////////////////////////////////////////////////////////////////////
- template <typename CharEncoding, bool no_case = false>
+ template <typename CharEncoding, bool no_attribute, bool no_case = false>
struct char_set
- : char_parser<char_set<CharEncoding, false>, typename CharEncoding::char_type>
+ : char_parser<char_set<CharEncoding, no_attribute, false>
+ , typename mpl::if_c<no_attribute, unused_type
+ , typename CharEncoding::char_type>::type>
{
typedef typename CharEncoding::char_type char_type;
typedef CharEncoding char_encoding;
@@ -320,9 +333,11 @@
support::detail::basic_chset<char_type> chset;
};
- template <typename CharEncoding>
- struct char_set<CharEncoding, true> // case insensitive
- : char_parser<char_set<CharEncoding, true>, typename CharEncoding::char_type>
+ template <typename CharEncoding, bool no_attribute>
+ struct char_set<CharEncoding, no_attribute, true> // case insensitive
+ : char_parser<char_set<CharEncoding, no_attribute, true>
+ , typename mpl::if_c<no_attribute, unused_type
+ , typename CharEncoding::char_type>::type>
{
typedef typename CharEncoding::char_type char_type;
typedef CharEncoding char_encoding;
@@ -455,12 +470,13 @@
}
};
+ ///////////////////////////////////////////////////////////////////////////
+ // char_('x')
template <typename CharEncoding, typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<
tag::char_code<tag::char_, CharEncoding>
- , fusion::vector1<A0>
- >
+ , fusion::vector1<A0> >
, Modifiers>
{
static bool const no_case =
@@ -473,7 +489,7 @@
typedef typename
mpl::if_<
traits::is_string<A0>
- , char_set<char_encoding, no_case>
+ , char_set<char_encoding, false, no_case>
, literal_char<char_encoding, false, no_case>
>::type
result_type;
@@ -485,6 +501,36 @@
}
};
+ // lit('x')
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_char<A0> >::type>
+ {
+ static bool const no_case =
+ has_modifier<
+ Modifiers
+ , tag::char_code_base<tag::no_case>
+ >::value;
+
+ typedef typename traits::char_encoding_from_char<
+ typename traits::char_type_of<A0>::type>::type encoding;
+
+ typedef literal_char<
+ typename spirit::detail::get_encoding_with_case<
+ Modifiers, encoding, no_case>::type
+ , true, no_case>
+ result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args));
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename CharEncoding, typename Modifiers, typename Char>
struct make_primitive<
terminal_ex<
Added: trunk/boost/spirit/home/qi/detail/enable_lit.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/detail/enable_lit.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,29 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#if !defined(BOOST_SPIRIT_QI_DETAIL_ENABLE_LIT_JAN_06_2011_0945PM)
+#define BOOST_SPIRIT_QI_DETAIL_ENABLE_LIT_JAN_06_2011_0945PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/domain.hpp>
+#include <boost/spirit/home/qi/parser.hpp>
+#include <boost/spirit/home/qi/meta_compiler.hpp>
+#include <boost/spirit/home/qi/auxiliary/lazy.hpp>
+#include <boost/fusion/include/vector.hpp>
+#include <boost/spirit/home/support/string_traits.hpp>
+
+namespace boost { namespace spirit
+{
+ // enables lazy lit(...) for qi
+ template <>
+ struct use_lazy_terminal<qi::domain, tag::lit, 1>
+ : mpl::true_ {};
+}}
+
+#endif
+
Modified: trunk/boost/spirit/home/qi/numeric/bool.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/bool.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/bool.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -65,6 +65,7 @@
struct use_terminal<qi::domain, bool>
: mpl::true_ {};
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename A0> // enables bool_(...)
struct use_terminal<qi::domain
@@ -106,8 +107,9 @@
using spirit::true__type;
using spirit::false_;
using spirit::false__type;
-
- using spirit::lit; // lit(true) is equivalent to true
+
+ using spirit::lit; // lit(true) is equivalent to true
+ using spirit::lit_type;
namespace detail
{
@@ -219,7 +221,7 @@
return result_type();
}
};
-
+
template <typename T, typename Modifiers
, typename Policies = bool_policies<T> >
struct make_direct_bool
@@ -242,7 +244,7 @@
return result_type(fusion::at_c<0>(term.args));
}
};
-
+
template <typename T, typename Modifiers, bool b
, typename Policies = bool_policies<T> >
struct make_predefined_direct_bool
@@ -265,7 +267,6 @@
}
};
-
template <typename T, typename Modifiers
, typename Policies = bool_policies<T> >
struct make_literal_bool
@@ -288,13 +289,14 @@
return result_type(i);
}
};
-
+
///////////////////////////////////////////////////////////////////////////
#if 0
template <typename Modifiers>
struct make_primitive<bool, Modifiers>
: make_literal_bool<bool, Modifiers> {};
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers>
struct make_primitive<tag::false_, Modifiers>
@@ -322,7 +324,7 @@
template <typename Modifiers>
struct make_primitive<tag::bool_, Modifiers>
: make_bool<bool, Modifiers> {};
-
+
template <typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<tag::bool_
Modified: trunk/boost/spirit/home/qi/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/int.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -120,7 +120,7 @@
template <> // enables *lazy* long_long(n)
struct use_lazy_terminal<qi::domain, tag::long_long, 1> : mpl::true_ {};
#endif
-
+
///////////////////////////////////////////////////////////////////////////
// enables any custom int_parser
template <typename T, unsigned Radix, unsigned MinDigits
@@ -296,7 +296,6 @@
///////////////////////////////////////////////////////////////////////////
#if 0
-
template <typename Modifiers>
struct make_primitive<short, Modifiers>
: make_literal_int<short> {};
@@ -315,6 +314,7 @@
: make_literal_int<boost::long_long_type> {};
#endif
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits
, typename Modifiers>
@@ -322,7 +322,7 @@
tag::int_parser<T, Radix, MinDigits, MaxDigits>
, Modifiers>
: make_int<T, Radix, MinDigits, MaxDigits> {};
-
+
template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits
, typename A0, typename Modifiers>
struct make_primitive<
Modified: trunk/boost/spirit/home/qi/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/real.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -73,6 +73,7 @@
struct use_terminal<qi::domain, long double>
: mpl::true_ {};
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename A0> // enables float_(...)
struct use_terminal<qi::domain
@@ -276,6 +277,7 @@
struct make_primitive<long double, Modifiers>
: make_literal_real<long double> {};
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename T, typename Policies, typename Modifiers>
struct make_primitive<
@@ -292,29 +294,29 @@
template <typename Modifiers>
struct make_primitive<tag::float_, Modifiers>
: make_real<float> {};
-
+
template <typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<tag::float_
, fusion::vector1<A0> >, Modifiers>
: make_direct_real<float> {};
-
+
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers>
struct make_primitive<tag::double_, Modifiers>
: make_real<double> {};
-
+
template <typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<tag::double_
, fusion::vector1<A0> >, Modifiers>
: make_direct_real<double> {};
-
+
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers>
struct make_primitive<tag::long_double, Modifiers>
: make_real<long double> {};
-
+
template <typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<tag::long_double
Modified: trunk/boost/spirit/home/qi/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/uint.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -81,11 +81,11 @@
template <> // enables ulong_
struct use_terminal<qi::domain, tag::ulong_> : mpl::true_ {};
-#if 0
+#if 0
template <> // enables lit(unsigned long(n))
struct use_terminal<qi::domain, unsigned long> : mpl::true_ {};
#endif
-
+
template <typename A0> // enables ulong_(n)
struct use_terminal<qi::domain
, terminal_ex<tag::ulong_, fusion::vector1<A0> > >
@@ -93,7 +93,7 @@
template <> // enables *lazy* ulong_(n)
struct use_lazy_terminal<qi::domain, tag::ulong_, 1> : mpl::true_ {};
-
+
///////////////////////////////////////////////////////////////////////////
#ifdef BOOST_HAS_LONG_LONG
template <> // enables ulong_long
@@ -112,6 +112,7 @@
template <> // enables *lazy* ulong_long(n)
struct use_lazy_terminal<qi::domain, tag::ulong_long, 1> : mpl::true_ {};
#endif
+
///////////////////////////////////////////////////////////////////////////
template <> // enables bin
struct use_terminal<qi::domain, tag::bin> : mpl::true_ {};
@@ -120,10 +121,10 @@
struct use_terminal<qi::domain
, terminal_ex<tag::bin, fusion::vector1<A0> > >
: is_arithmetic<A0> {};
-
+
template <> // enables *lazy* bin(n)
struct use_lazy_terminal<qi::domain, tag::bin, 1> : mpl::true_ {};
-
+
///////////////////////////////////////////////////////////////////////////
template <> // enables oct
struct use_terminal<qi::domain, tag::oct> : mpl::true_ {};
@@ -132,10 +133,10 @@
struct use_terminal<qi::domain
, terminal_ex<tag::oct, fusion::vector1<A0> > >
: is_arithmetic<A0> {};
-
+
template <> // enables *lazy* oct(n)
struct use_lazy_terminal<qi::domain, tag::oct, 1> : mpl::true_ {};
-
+
///////////////////////////////////////////////////////////////////////////
template <> // enables hex
struct use_terminal<qi::domain, tag::hex> : mpl::true_ {};
@@ -144,10 +145,10 @@
struct use_terminal<qi::domain
, terminal_ex<tag::hex, fusion::vector1<A0> > >
: is_arithmetic<A0> {};
-
+
template <> // enables *lazy* hex(n)
struct use_lazy_terminal<qi::domain, tag::hex, 1> : mpl::true_ {};
-
+
///////////////////////////////////////////////////////////////////////////
// enables any custom uint_parser
template <typename T, unsigned Radix, unsigned MinDigits
@@ -290,7 +291,7 @@
return result_type();
}
};
-
+
template <typename T, unsigned Radix = 10, unsigned MinDigits = 1
, int MaxDigits = -1>
struct make_direct_uint
@@ -303,7 +304,7 @@
return result_type(fusion::at_c<0>(term.args));
}
};
-
+
template <typename T, unsigned Radix = 10, unsigned MinDigits = 1
, int MaxDigits = -1>
struct make_literal_uint
@@ -315,7 +316,7 @@
return result_type(i);
}
};
-
+
///////////////////////////////////////////////////////////////////////////
#if 0
template <typename Modifiers>
@@ -336,6 +337,7 @@
: make_literal_uint<boost::ulong_long_type> {};
#endif
#endif
+
///////////////////////////////////////////////////////////////////////////
template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits
, typename Modifiers>
Modified: trunk/boost/spirit/home/qi/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/string/lit.hpp (original)
+++ trunk/boost/spirit/home/qi/string/lit.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2010 Bryce Lelbach
Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -18,6 +19,7 @@
#include <boost/spirit/home/qi/parser.hpp>
#include <boost/spirit/home/qi/meta_compiler.hpp>
#include <boost/spirit/home/qi/auxiliary/lazy.hpp>
+#include <boost/spirit/home/qi/detail/enable_lit.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/support/modify.hpp>
@@ -33,6 +35,7 @@
#include <boost/mpl/assert.hpp>
#include <boost/mpl/if.hpp>
#include <boost/detail/workaround.hpp>
+#include <boost/utility/enable_if.hpp>
#include <string>
namespace boost { namespace spirit
@@ -59,11 +62,18 @@
, 1 /*arity*/
> : mpl::true_ {};
+ // enables lit(...)
+ template <typename A0>
+ struct use_terminal<qi::domain
+ , terminal_ex<tag::lit, fusion::vector1<A0> >
+ , typename enable_if<traits::is_string<A0> >::type>
+ : mpl::true_ {};
}}
namespace boost { namespace spirit { namespace qi
{
using spirit::lit;
+ using spirit::lit_type;
///////////////////////////////////////////////////////////////////////////
// Parse for literal strings
@@ -203,7 +213,48 @@
}
};
- template <typename Modifiers, typename CharEncoding, typename A0>
+ // lit("...")
+ template <typename Modifiers, typename A0>
+ struct make_primitive<
+ terminal_ex<tag::lit, fusion::vector1<A0> >
+ , Modifiers
+ , typename enable_if<traits::is_string<A0> >::type>
+ {
+ typedef has_modifier<Modifiers, tag::char_code_base<tag::no_case> > no_case;
+
+ typedef typename add_const<A0>::type const_string;
+ typedef typename mpl::if_<
+ no_case
+ , no_case_literal_string<const_string, true>
+ , literal_string<const_string, true> >::type
+ result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return op(fusion::at_c<0>(term.args), no_case());
+ }
+
+ template <typename String>
+ result_type op(String const& str, mpl::false_) const
+ {
+ return result_type(str);
+ }
+
+ template <typename String>
+ result_type op(String const& str, mpl::true_) const
+ {
+ typedef typename traits::char_encoding_from_char<
+ typename traits::char_type_of<A0>::type>::type encoding_type;
+ typename spirit::detail::get_encoding<Modifiers,
+ encoding_type>::type encoding;
+ return result_type(traits::get_c_string(str), encoding);
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // string("...")
+ template <typename CharEncoding, typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<
tag::char_code<tag::string, CharEncoding>
Modified: trunk/boost/spirit/home/support/common_terminals.hpp
==============================================================================
--- trunk/boost/spirit/home/support/common_terminals.hpp (original)
+++ trunk/boost/spirit/home/support/common_terminals.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -60,8 +60,7 @@
template <typename Encoding>
struct encoding
: proto::terminal<tag::char_code<tag::encoding, Encoding> >::type
- {
- };
+ {};
// Our basic terminals
BOOST_SPIRIT_DEFINE_TERMINALS(
@@ -86,11 +85,9 @@
( duplicate )
)
- // Here we are reusing proto::lit
- using proto::lit;
-
// Our extended terminals
BOOST_SPIRIT_DEFINE_TERMINALS_EX(
+ ( lit )
( bin )
( oct )
( hex )
@@ -142,7 +139,6 @@
struct attr_cast {};
struct as {};
}
-
}}
///////////////////////////////////////////////////////////////////////////////
@@ -209,6 +205,27 @@
BOOST_SPIRIT_DEFINE_CHAR_CODES(standard)
BOOST_SPIRIT_DEFINE_CHAR_CODES(standard_wide)
+namespace boost { namespace spirit { namespace traits
+{
+ template <typename Char>
+ struct char_encoding_from_char;
+
+ template <>
+ struct char_encoding_from_char<char>
+ : mpl::identity<spirit::char_encoding::standard>
+ {};
+
+ template <>
+ struct char_encoding_from_char<wchar_t>
+ : mpl::identity<spirit::char_encoding::standard_wide>
+ {};
+
+ template <typename T>
+ struct char_encoding_from_char<T const>
+ : char_encoding_from_char<T>
+ {};
+}}}
+
#if defined(BOOST_SPIRIT_UNICODE)
BOOST_SPIRIT_DEFINE_CHAR_CODES(unicode)
Added: trunk/boost/spirit/home/support/numeric_traits.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/support/numeric_traits.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,97 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#if !defined(BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM)
+#define BOOST_SPIRIT_NUMERIC_TRAITS_JAN_07_2011_0722AM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+#include <boost/mpl/bool.hpp>
+
+namespace boost { namespace spirit { namespace traits
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Determine if T is a boolean type
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_bool : mpl::false_ {};
+
+ template <typename T>
+ struct is_bool<T const> : is_bool<T> {};
+
+ template <>
+ struct is_bool<bool> : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Determine if T is a signed integer type
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_int : mpl::false_ {};
+
+ template <typename T>
+ struct is_int<T const> : is_int<T> {};
+
+ template <>
+ struct is_int<short> : mpl::true_ {};
+
+ template <>
+ struct is_int<int> : mpl::true_ {};
+
+ template <>
+ struct is_int<long> : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct is_int<boost::long_long_type> : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Determine if T is an unsigned integer type
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_uint : mpl::false_ {};
+
+ template <typename T>
+ struct is_uint<T const> : is_uint<T> {};
+
+#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
+ template <>
+ struct is_uint<unsigned short> : mpl::true_ {};
+#endif
+
+ template <>
+ struct is_uint<unsigned int> : mpl::true_ {};
+
+ template <>
+ struct is_uint<unsigned long> : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct is_uint<boost::ulong_long_type> : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Determine if T is a floating point type
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_real : mpl::false_ {};
+
+ template <typename T>
+ struct is_real<T const> : is_uint<T> {};
+
+ template <>
+ struct is_real<float> : mpl::true_ {};
+
+ template <>
+ struct is_real<double> : mpl::true_ {};
+
+ template <>
+ struct is_real<long double> : mpl::true_ {};
+}}}
+
+#endif
Modified: trunk/boost/spirit/home/support/string_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/string_traits.hpp (original)
+++ trunk/boost/spirit/home/support/string_traits.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2010 Bryce Lelbach
Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -26,6 +27,21 @@
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
+ // Determine if T is a character type
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_char : mpl::false_ {};
+
+ template <typename T>
+ struct is_char<T const> : is_char<T> {};
+
+ template <>
+ struct is_char<char> : mpl::true_ {};
+
+ template <>
+ struct is_char<wchar_t> : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
// Determine if T is a string
///////////////////////////////////////////////////////////////////////////
template <typename T>
@@ -83,6 +99,12 @@
struct char_type_of<T const> : char_type_of<T> {};
template <>
+ struct char_type_of<char> : mpl::identity<char> {};
+
+ template <>
+ struct char_type_of<wchar_t> : mpl::identity<wchar_t> {};
+
+ template <>
struct char_type_of<char const*> : mpl::identity<char const> {};
template <>
Modified: trunk/boost/thread/win32/thread_heap_alloc.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_heap_alloc.hpp (original)
+++ trunk/boost/thread/win32/thread_heap_alloc.hpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -56,7 +56,7 @@
{
namespace detail
{
- inline BOOST_THREAD_DECL void* allocate_raw_heap_memory(unsigned size)
+ inline /*BOOST_THREAD_DECL*/ void* allocate_raw_heap_memory(unsigned size)
{
void* const heap_memory=detail::win32::HeapAlloc(detail::win32::GetProcessHeap(),0,size);
if(!heap_memory)
@@ -66,7 +66,7 @@
return heap_memory;
}
- inline BOOST_THREAD_DECL void free_raw_heap_memory(void* heap_memory)
+ inline /*BOOST_THREAD_DECL*/ void free_raw_heap_memory(void* heap_memory)
{
BOOST_VERIFY(detail::win32::HeapFree(detail::win32::GetProcessHeap(),0,heap_memory)!=0);
}
Modified: trunk/libs/spirit/doc/lex/token_primitives.qbk
==============================================================================
--- trunk/libs/spirit/doc/lex/token_primitives.qbk (original)
+++ trunk/libs/spirit/doc/lex/token_primitives.qbk 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -43,7 +43,6 @@
[table
[[Name]]
- [[`boost::spirit::lit // alias: boost::spirit::lex::lit` ]]
[[`lex::char_`]]
]
@@ -65,8 +64,6 @@
[[Expression] [Description]]
[[`ch`] [Create a token definition matching the character
literal `ch`. ]]
- [[`lit(ch)`] [Create a token definition matching the character
- literal `ch`. ]]
[[`lex::char_(ch)`] [Create a token definition matching the character
`ch`.]]
]
Modified: trunk/libs/spirit/doc/what_s_new.qbk
==============================================================================
--- trunk/libs/spirit/doc/what_s_new.qbk (original)
+++ trunk/libs/spirit/doc/what_s_new.qbk 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -24,6 +24,9 @@
* Introduced a new customization point __customize_assign_to_container_from_value__
which is invoked for container attributes whenever a attribute value needs to
be added to that container.
+* Replaced `proto::lit` (which was used to implement `spirit::lit`) with a
+ separate version allowing to distinguish 'lit(foo)' from 'foo'. This should
+ not change any semantics nor should it break exiting code.
[heading Bug Fixes in Qi or Karma]
@@ -33,6 +36,10 @@
* Fixed the __karma__ generator [karma_string `string(s)`]. It succeeded even
if `s` matched only a prefix of its attribute.
+[heading New Features in Lex]
+
+* `lex::lit()` has been removed.
+
[heading What's changed in __lex__ from V2.4.1 (Boost V1.45.0) to V2.4.2 (Boost V1.46.0)]
[heading New Features in Lex]
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -35,7 +35,8 @@
[ run qi/binary.cpp : : : : qi_binary ]
[ run qi/bool1.cpp : : : : qi_bool1 ]
[ run qi/bool2.cpp : : : : qi_bool2 ]
- [ run qi/char.cpp : : : : qi_char ]
+ [ run qi/char1.cpp : : : : qi_char1 ]
+ [ run qi/char2.cpp : : : : qi_char2 ]
[ run qi/char_class.cpp : : : : qi_char_class ]
[ run qi/debug.cpp : : : : qi_debug ]
[ run qi/difference.cpp : : : : qi_difference ]
@@ -50,7 +51,8 @@
[ run qi/kleene.cpp : : : : qi_kleene ]
[ run qi/lazy.cpp : : : : qi_lazy ]
[ run qi/lexeme.cpp : : : : qi_lexeme ]
- [ run qi/lit.cpp : : : : qi_lit ]
+ [ run qi/lit1.cpp : : : : qi_lit1 ]
+ [ run qi/lit2.cpp : : : : qi_lit2 ]
[ run qi/list.cpp : : : : qi_list ]
[ run qi/hold.cpp : : : : qi_hold ]
[ run qi/match_manip1.cpp : : : : qi_match_manip1 ]
@@ -133,6 +135,7 @@
[ run karma/center_alignment.cpp : : : : karma_center_alignment ]
[ run karma/char1.cpp : : : : karma_char1 ]
[ run karma/char2.cpp : : : : karma_char2 ]
+ [ run karma/char3.cpp : : : : karma_char3 ]
[ run karma/char_class.cpp : : : : karma_char_class ]
[ run karma/columns.cpp : : : : karma_columns ]
[ run karma/debug.cpp : : : : karma_debug ]
Modified: trunk/libs/spirit/test/karma/char1.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/char1.cpp (original)
+++ trunk/libs/spirit/test/karma/char1.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/karma/char2.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/char2.cpp (original)
+++ trunk/libs/spirit/test/karma/char2.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Added: trunk/libs/spirit/test/karma/char3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/char3.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,105 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+//#define KARMA_FAIL_COMPILATION
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/karma_char.hpp>
+#include <boost/spirit/include/karma_generate.hpp>
+#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_phoenix_attributes.hpp>
+
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_statement.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+///////////////////////////////////////////////////////////////////////////////
+int
+main()
+{
+ using namespace boost::spirit;
+ using namespace boost::phoenix;
+ using boost::spirit::karma::lit;
+
+ {
+ BOOST_TEST(test("x", lit('x')));
+ BOOST_TEST(!test("x", lit('y')));
+
+ BOOST_TEST(test("x", lit('x'), 'x'));
+ BOOST_TEST(!test("", lit('y'), 'x'));
+
+// BOOST_TEST(test("a", lit('a', 'z'), 'a'));
+// BOOST_TEST(test("b", lit('a', 'z'), 'b'));
+// BOOST_TEST(!test("", lit('a', 'z'), 'A'));
+
+ BOOST_TEST(!test("", ~lit('x')));
+
+ BOOST_TEST(!test("", ~lit('x'), 'x'));
+ BOOST_TEST(test("x", ~lit('y'), 'x'));
+
+// BOOST_TEST(!test("", ~lit('a', 'z'), 'a'));
+// BOOST_TEST(!test("", ~lit('a', 'z'), 'b'));
+// BOOST_TEST(test("A", ~lit('a', 'z'), 'A'));
+
+ BOOST_TEST(test("x", ~~lit('x')));
+ BOOST_TEST(!test("x", ~~lit('y')));
+
+ BOOST_TEST(test("x", ~~lit('x'), 'x'));
+ BOOST_TEST(!test("", ~~lit('y'), 'x'));
+
+// BOOST_TEST(test("a", ~~lit('a', 'z'), 'a'));
+// BOOST_TEST(test("b", ~~lit('a', 'z'), 'b'));
+// BOOST_TEST(!test("", ~~lit('a', 'z'), 'A'));
+ }
+
+ {
+ BOOST_TEST(test(L"x", lit('x')));
+ BOOST_TEST(test(L"x", lit(L'x')));
+ BOOST_TEST(!test(L"x", lit('y')));
+ BOOST_TEST(!test(L"x", lit(L'y')));
+
+ BOOST_TEST(test(L"x", lit(L'x'), L'x'));
+ BOOST_TEST(!test(L"", lit('y'), L'x'));
+
+// BOOST_TEST(test("a", lit("a", "z"), 'a'));
+// BOOST_TEST(test(L"a", lit(L"a", L"z"), L'a'));
+
+ BOOST_TEST(!test(L"", ~lit('x')));
+ BOOST_TEST(!test(L"", ~lit(L'x')));
+
+ BOOST_TEST(!test(L"", ~lit(L'x'), L'x'));
+ BOOST_TEST(test(L"x", ~lit('y'), L'x'));
+ }
+
+ { // lazy chars
+ using namespace boost::phoenix;
+
+ BOOST_TEST((test("x", lit(val('x')))));
+ BOOST_TEST((test(L"x", lit(val(L'x')))));
+
+ BOOST_TEST((test("x", lit(val('x')), 'x')));
+ BOOST_TEST((test(L"x", lit(val(L'x')), L'x')));
+
+ BOOST_TEST((!test("", lit(val('y')), 'x')));
+ BOOST_TEST((!test(L"", lit(val(L'y')), L'x')));
+ }
+
+ // we can pass optionals as attributes to any generator
+ {
+ boost::optional<char> v;
+ boost::optional<wchar_t> w;
+
+ BOOST_TEST(!test("", lit('x'), v));
+ BOOST_TEST(!test(L"", lit(L'x'), w));
+ }
+
+ return boost::report_errors();
+}
Modified: trunk/libs/spirit/test/karma/encoding.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/encoding.cpp (original)
+++ trunk/libs/spirit/test/karma/encoding.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -41,26 +41,20 @@
BOOST_TEST(test("Á", iso8859_1[upper['á']]));
BOOST_TEST(test("á", iso8859_1[lower[char_('á')]]));
BOOST_TEST(test("Á", iso8859_1[upper[char_('á')]]));
+ BOOST_TEST(test("á", iso8859_1[lower[lit('á')]]));
+ BOOST_TEST(test("Á", iso8859_1[upper[lit('á')]]));
BOOST_TEST(test("á", iso8859_1[lower[char_]], 'á'));
BOOST_TEST(test("Á", iso8859_1[upper[char_]], 'á'));
BOOST_TEST(test("á", iso8859_1[lower['Á']]));
BOOST_TEST(test("Á", iso8859_1[upper['Á']]));
BOOST_TEST(test("á", iso8859_1[lower[char_('Á')]]));
BOOST_TEST(test("Á", iso8859_1[upper[char_('Á')]]));
+ BOOST_TEST(test("á", iso8859_1[lower[lit('Á')]]));
+ BOOST_TEST(test("Á", iso8859_1[upper[lit('Á')]]));
BOOST_TEST(test("á", iso8859_1[lower[char_]], 'Á'));
BOOST_TEST(test("Á", iso8859_1[upper[char_]], 'Á'));
}
-// {
-// BOOST_TEST(test("É", iso8859_1[no_case[char_("å-ï")]]));
-// BOOST_TEST(!test("ÿ", iso8859_1[no_case[char_("å-ï")]]));
-// }
-//
-// {
-// BOOST_TEST(test("Áá", iso8859_1[no_case["áÁ"]]));
-// BOOST_TEST(test("Áá", iso8859_1[no_case[lit("áÁ")]]));
-// }
-
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
#pragma setlocale("")
#endif
@@ -71,10 +65,10 @@
#endif
{
BOOST_TEST(test("ää", iso8859_1[lower["Ää"]]));
- BOOST_TEST(test("ää", iso8859_1[lower["Ää"]]));
+ BOOST_TEST(test("ää", iso8859_1[lower[lit("Ää")]]));
BOOST_TEST(test("ÄÄ", iso8859_1[upper["Ää"]]));
- BOOST_TEST(test("ÄÄ", iso8859_1[upper["Ää"]]));
+ BOOST_TEST(test("ÄÄ", iso8859_1[upper[lit("Ää")]]));
}
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
#pragma setlocale("")
Modified: trunk/libs/spirit/test/karma/int1.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/int1.cpp (original)
+++ trunk/libs/spirit/test/karma/int1.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/karma/int2.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/int2.cpp (original)
+++ trunk/libs/spirit/test/karma/int2.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/karma/int3.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/int3.cpp (original)
+++ trunk/libs/spirit/test/karma/int3.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/karma/real3.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/real3.cpp (original)
+++ trunk/libs/spirit/test/karma/real3.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -50,7 +50,6 @@
BOOST_TEST(test("-123420000000000000000.0", fixed, -1.23420e20));
}
-
// support for using real_concept with a Karma generator has been implemented
// in Boost versions > 1.36 only, additionally real_concept is available only
// if BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is not defined
Deleted: trunk/libs/spirit/test/qi/char.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/char.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
+++ (empty file)
@@ -1,174 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2011 Joel de Guzman
- Copyright (c) 2001-2011 Hartmut Kaiser
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-
-#include <iostream>
-#include "test.hpp"
-
-int
-main()
-{
- using spirit_test::test;
- using spirit_test::test_attr;
- using spirit_test::print_info;
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test("x", 'x'));
- BOOST_TEST(test(L"x", L'x'));
- BOOST_TEST(!test("y", 'x'));
- BOOST_TEST(!test(L"y", L'x'));
-
- BOOST_TEST(test("x", char_));
- BOOST_TEST(test("x", char_('x')));
- BOOST_TEST(!test("x", char_('y')));
- BOOST_TEST(test("x", char_('a', 'z')));
- BOOST_TEST(!test("x", char_('0', '9')));
-
- BOOST_TEST(!test("x", ~char_));
- BOOST_TEST(!test("x", ~char_('x')));
- BOOST_TEST(test(" ", ~char_('x')));
- BOOST_TEST(test("X", ~char_('x')));
- BOOST_TEST(!test("x", ~char_('b', 'y')));
- BOOST_TEST(test("a", ~char_('b', 'y')));
- BOOST_TEST(test("z", ~char_('b', 'y')));
-
- BOOST_TEST(test("x", ~~char_));
- BOOST_TEST(test("x", ~~char_('x')));
- BOOST_TEST(!test(" ", ~~char_('x')));
- BOOST_TEST(!test("X", ~~char_('x')));
- BOOST_TEST(test("x", ~~char_('b', 'y')));
- BOOST_TEST(!test("a", ~~char_('b', 'y')));
- BOOST_TEST(!test("z", ~~char_('b', 'y')));
- }
-
- {
- using namespace boost::spirit::ascii;
- using boost::spirit::qi::lit;
-
- BOOST_TEST(test("x", lit('x')));
- BOOST_TEST(!test("x", lit('y')));
-
- BOOST_TEST(!test("x", ~lit('x')));
- BOOST_TEST(test(" ", ~lit('x')));
- BOOST_TEST(test("X", ~lit('x')));
-
- BOOST_TEST(test("x", ~~lit('x')));
- BOOST_TEST(!test(" ", ~~lit('x')));
- BOOST_TEST(!test("X", ~~lit('x')));
- }
-
- {
- using namespace boost::spirit::ascii;
-
- BOOST_TEST(test(" x", 'x', space));
- BOOST_TEST(test(L" x", L'x', space));
-
- BOOST_TEST(test(" x", char_, space));
- BOOST_TEST(test(" x", char_('x'), space));
- BOOST_TEST(!test(" x", char_('y'), space));
- BOOST_TEST(test(" x", char_('a', 'z'), space));
- BOOST_TEST(!test(" x", char_('0', '9'), space));
- }
-
- {
- using namespace boost::spirit::standard_wide;
-
- BOOST_TEST(test(L"x", char_));
- BOOST_TEST(test(L"x", char_(L'x')));
- BOOST_TEST(!test(L"x", char_(L'y')));
- BOOST_TEST(test(L"x", char_(L'a', L'z')));
- BOOST_TEST(!test(L"x", char_(L'0', L'9')));
-
- BOOST_TEST(!test(L"x", ~char_));
- BOOST_TEST(!test(L"x", ~char_(L'x')));
- BOOST_TEST(test(L" ", ~char_(L'x')));
- BOOST_TEST(test(L"X", ~char_(L'x')));
- BOOST_TEST(!test(L"x", ~char_(L'b', L'y')));
- BOOST_TEST(test(L"a", ~char_(L'b', L'y')));
- BOOST_TEST(test(L"z", ~char_(L'b', L'y')));
-
- BOOST_TEST(test(L"x", ~~char_));
- BOOST_TEST(test(L"x", ~~char_(L'x')));
- BOOST_TEST(!test(L" ", ~~char_(L'x')));
- BOOST_TEST(!test(L"X", ~~char_(L'x')));
- BOOST_TEST(test(L"x", ~~char_(L'b', L'y')));
- BOOST_TEST(!test(L"a", ~~char_(L'b', L'y')));
- BOOST_TEST(!test(L"z", ~~char_(L'b', L'y')));
- }
-
-
- { // single char strings!
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- BOOST_TEST(test("x", "x"));
- BOOST_TEST(test(L"x", L"x"));
- BOOST_TEST(test("x", ascii::char_("x")));
- BOOST_TEST(test(L"x", wide::char_(L"x")));
-
- BOOST_TEST(test("x", ascii::char_("a", "z")));
- BOOST_TEST(test(L"x", ascii::char_(L"a", L"z")));
- }
-
- {
- // chsets
- namespace ascii = boost::spirit::ascii;
- namespace wide = boost::spirit::standard_wide;
-
- BOOST_TEST(test("x", ascii::char_("a-z")));
- BOOST_TEST(!test("1", ascii::char_("a-z")));
- BOOST_TEST(test("1", ascii::char_("a-z0-9")));
-
- BOOST_TEST(test("x", wide::char_(L"a-z")));
- BOOST_TEST(!test("1", wide::char_(L"a-z")));
- BOOST_TEST(test("1", wide::char_(L"a-z0-9")));
-
- std::string set = "a-z0-9";
- BOOST_TEST(test("x", ascii::char_(set)));
-
-#ifdef SPIRIT_NO_COMPILE_CHECK
- test("", ascii::char_(L"a-z0-9"));
-#endif
- }
-
- { // lazy chars
-
- using namespace boost::spirit::ascii;
-
- using boost::phoenix::val;
- using boost::phoenix::ref;
- using boost::spirit::_1;
-
- BOOST_TEST((test("x", char_(val('x')))));
- BOOST_TEST((test("h", char_(val('a'), val('n')))));
- BOOST_TEST(test("0", char_(val("a-z0-9"))));
-
- char ch; // make sure lazy chars have an attribute
- BOOST_TEST(test("x", char_(val('x'))[ref(ch) = _1]));
- BOOST_TEST(ch == 'x');
- }
-
- { // testing "what"
-
- using boost::spirit::qi::what;
- using boost::spirit::ascii::char_;
- using boost::spirit::ascii::alpha;
-
- print_info(what('x'));
- print_info(what(char_('a','z')));
- print_info(what(alpha));
- }
-
- return boost::report_errors();
-}
Copied: trunk/libs/spirit/test/qi/char1.cpp (from r67745, /trunk/libs/spirit/test/qi/char.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/char.cpp (original)
+++ trunk/libs/spirit/test/qi/char1.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -54,22 +54,6 @@
{
using namespace boost::spirit::ascii;
- using boost::spirit::qi::lit;
-
- BOOST_TEST(test("x", lit('x')));
- BOOST_TEST(!test("x", lit('y')));
-
- BOOST_TEST(!test("x", ~lit('x')));
- BOOST_TEST(test(" ", ~lit('x')));
- BOOST_TEST(test("X", ~lit('x')));
-
- BOOST_TEST(test("x", ~~lit('x')));
- BOOST_TEST(!test(" ", ~~lit('x')));
- BOOST_TEST(!test("X", ~~lit('x')));
- }
-
- {
- using namespace boost::spirit::ascii;
BOOST_TEST(test(" x", 'x', space));
BOOST_TEST(test(L" x", L'x', space));
Added: trunk/libs/spirit/test/qi/char2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/char2.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,71 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+#include <iostream>
+#include "test.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+ using spirit_test::print_info;
+
+ {
+ using boost::spirit::qi::lit;
+
+ BOOST_TEST(test("x", lit('x')));
+ BOOST_TEST(!test("x", lit('y')));
+
+ BOOST_TEST(!test("x", ~lit('x')));
+ BOOST_TEST(test(" ", ~lit('x')));
+ BOOST_TEST(test("X", ~lit('x')));
+
+ BOOST_TEST(test("x", ~~lit('x')));
+ BOOST_TEST(!test(" ", ~~lit('x')));
+ BOOST_TEST(!test("X", ~~lit('x')));
+ }
+
+ {
+ using boost::spirit::qi::lit;
+ using boost::spirit::qi::space;
+
+ BOOST_TEST(test(" x", lit('x'), space));
+ BOOST_TEST(!test(" x", lit('y'), space));
+ }
+
+ {
+ using boost::spirit::qi::lit;
+
+ BOOST_TEST(test(L"x", lit(L'x')));
+ BOOST_TEST(!test(L"x", lit(L'y')));
+
+ BOOST_TEST(!test(L"x", ~lit(L'x')));
+ BOOST_TEST(test(L" ", ~lit(L'x')));
+ BOOST_TEST(test(L"X", ~lit(L'x')));
+
+ BOOST_TEST(test(L"x", ~~lit(L'x')));
+ BOOST_TEST(!test(L" ", ~~lit(L'x')));
+ BOOST_TEST(!test(L"X", ~~lit(L'x')));
+ }
+
+ { // lazy chars
+ using boost::spirit::qi::lit;
+
+ using boost::phoenix::val;
+
+ BOOST_TEST((test("x", lit(val('x')))));
+ }
+
+ return boost::report_errors();
+}
Deleted: trunk/libs/spirit/test/qi/lit.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/lit.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
+++ (empty file)
@@ -1,108 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2011 Joel de Guzman
- http://spirit.sourceforge.net/
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-#include <boost/detail/lightweight_test.hpp>
-#include <boost/detail/workaround.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-
-#include <iostream>
-#include "test.hpp"
-
-int
-main()
-{
- using spirit_test::test;
- using spirit_test::test_attr;
- using boost::spirit::qi::lit;
- using boost::spirit::qi::_1;
-
- {
- BOOST_TEST((test("kimpo", "kimpo")));
- BOOST_TEST((test("kimpo", lit("kimpo"))));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test("x", lit("x"))));
- BOOST_TEST((test(L"x", lit(L"x"))));
-#endif
- std::basic_string<char> s("kimpo");
- std::basic_string<wchar_t> ws(L"kimpo");
- BOOST_TEST((test("kimpo", s)));
- BOOST_TEST((test(L"kimpo", ws)));
- BOOST_TEST((test("kimpo", lit(s))));
- BOOST_TEST((test(L"kimpo", lit(ws))));
- }
-
- {
- BOOST_TEST((test(L"kimpo", L"kimpo")));
- BOOST_TEST((test(L"kimpo", lit(L"kimpo"))));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(L"x", lit(L"x"))));
-#endif
- BOOST_TEST((test(L"x", lit(L'x'))));
- BOOST_TEST((test(L"x", lit(L'x'))));
- }
-
- {
- std::basic_string<char> s("kimpo");
- BOOST_TEST((test("kimpo", lit(s))));
-
- std::basic_string<wchar_t> ws(L"kimpo");
- BOOST_TEST((test(L"kimpo", lit(ws))));
- }
-
- {
- using namespace boost::spirit::ascii;
- BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
- BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(" x", lit("x"), space)));
-#endif
- BOOST_TEST((test(" x", lit('x'), space)));
- BOOST_TEST((test(L" x", lit(L'x'), space)));
- }
-
- {
- using namespace boost::spirit::ascii;
- BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
- BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(" x", lit("x"), space)));
-#endif
- BOOST_TEST((test(" x", lit('x'), space)));
- BOOST_TEST((test(L" x", lit(L'x'), space)));
- }
-
- {
- using namespace boost::spirit::ascii;
- std::string s;
- BOOST_TEST((test_attr("kimpo", string("kimpo"), s)));
- BOOST_TEST(s == "kimpo");
- s.clear();
- BOOST_TEST((test_attr(L"kimpo", string(L"kimpo"), s)));
- BOOST_TEST(s == "kimpo");
- s.clear();
- BOOST_TEST((test_attr("x", string("x"), s)));
- BOOST_TEST(s == "x");
- }
-
- { // lazy string
-
- using namespace boost::spirit::ascii;
- namespace phx = boost::phoenix;
-
- BOOST_TEST((test("x", string(phx::val("x")))));
-
- std::string str; // make sure lazy lits have an attribute
- BOOST_TEST(test("x", string(phx::val("x"))[phx::ref(str) = _1]));
- BOOST_TEST(str == "x");
- }
-
- return boost::report_errors();
-}
Copied: trunk/libs/spirit/test/qi/lit1.cpp (from r67745, /trunk/libs/spirit/test/qi/lit.cpp)
==============================================================================
--- /trunk/libs/spirit/test/qi/lit.cpp (original)
+++ trunk/libs/spirit/test/qi/lit1.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -21,62 +21,50 @@
{
using spirit_test::test;
using spirit_test::test_attr;
- using boost::spirit::qi::lit;
+ using boost::spirit::qi::string;
using boost::spirit::qi::_1;
{
BOOST_TEST((test("kimpo", "kimpo")));
- BOOST_TEST((test("kimpo", lit("kimpo"))));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test("x", lit("x"))));
- BOOST_TEST((test(L"x", lit(L"x"))));
-#endif
+ BOOST_TEST((test("kimpo", string("kimpo"))));
+
+ BOOST_TEST((test("x", string("x"))));
+ BOOST_TEST((test(L"x", string(L"x"))));
+
std::basic_string<char> s("kimpo");
std::basic_string<wchar_t> ws(L"kimpo");
BOOST_TEST((test("kimpo", s)));
BOOST_TEST((test(L"kimpo", ws)));
- BOOST_TEST((test("kimpo", lit(s))));
- BOOST_TEST((test(L"kimpo", lit(ws))));
+ BOOST_TEST((test("kimpo", string(s))));
+ BOOST_TEST((test(L"kimpo", string(ws))));
}
{
BOOST_TEST((test(L"kimpo", L"kimpo")));
- BOOST_TEST((test(L"kimpo", lit(L"kimpo"))));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(L"x", lit(L"x"))));
-#endif
- BOOST_TEST((test(L"x", lit(L'x'))));
- BOOST_TEST((test(L"x", lit(L'x'))));
+ BOOST_TEST((test(L"kimpo", string(L"kimpo"))));
+ BOOST_TEST((test(L"x", string(L"x"))));
}
{
std::basic_string<char> s("kimpo");
- BOOST_TEST((test("kimpo", lit(s))));
+ BOOST_TEST((test("kimpo", string(s))));
std::basic_string<wchar_t> ws(L"kimpo");
- BOOST_TEST((test(L"kimpo", lit(ws))));
+ BOOST_TEST((test(L"kimpo", string(ws))));
}
{
using namespace boost::spirit::ascii;
- BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
- BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(" x", lit("x"), space)));
-#endif
- BOOST_TEST((test(" x", lit('x'), space)));
- BOOST_TEST((test(L" x", lit(L'x'), space)));
+ BOOST_TEST((test(" kimpo", string("kimpo"), space)));
+ BOOST_TEST((test(L" kimpo", string(L"kimpo"), space)));
+ BOOST_TEST((test(" x", string("x"), space)));
}
{
using namespace boost::spirit::ascii;
- BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
- BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- BOOST_TEST((test(" x", lit("x"), space)));
-#endif
- BOOST_TEST((test(" x", lit('x'), space)));
- BOOST_TEST((test(L" x", lit(L'x'), space)));
+ BOOST_TEST((test(" kimpo", string("kimpo"), space)));
+ BOOST_TEST((test(L" kimpo", string(L"kimpo"), space)));
+ BOOST_TEST((test(" x", string("x"), space)));
}
{
Added: trunk/libs/spirit/test/qi/lit2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/lit2.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -0,0 +1,58 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+
+#include <iostream>
+#include "test.hpp"
+
+int
+main()
+{
+ using spirit_test::test;
+ using spirit_test::test_attr;
+ using boost::spirit::qi::lit;
+ using boost::spirit::qi::_1;
+
+ {
+ BOOST_TEST((test("kimpo", lit("kimpo"))));
+
+ std::basic_string<char> s("kimpo");
+ std::basic_string<wchar_t> ws(L"kimpo");
+ BOOST_TEST((test("kimpo", lit(s))));
+ BOOST_TEST((test(L"kimpo", lit(ws))));
+ }
+
+ {
+ std::basic_string<char> s("kimpo");
+ BOOST_TEST((test("kimpo", lit(s))));
+
+ std::basic_string<wchar_t> ws(L"kimpo");
+ BOOST_TEST((test(L"kimpo", lit(ws))));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+ BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
+ BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
+ }
+
+ {
+ using namespace boost::spirit::ascii;
+ BOOST_TEST((test(" kimpo", lit("kimpo"), space)));
+ BOOST_TEST((test(L" kimpo", lit(L"kimpo"), space)));
+ }
+
+ return boost::report_errors();
+}
Modified: trunk/libs/spirit/test/qi/rule1.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule1.cpp (original)
+++ trunk/libs/spirit/test/qi/rule1.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,5 @@
/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/qi/rule2.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule2.cpp (original)
+++ trunk/libs/spirit/test/qi/rule2.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,5 @@
/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/qi/rule3.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule3.cpp (original)
+++ trunk/libs/spirit/test/qi/rule3.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,5 @@
/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Modified: trunk/libs/spirit/test/qi/rule4.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule4.cpp (original)
+++ trunk/libs/spirit/test/qi/rule4.cpp 2011-01-07 12:50:06 EST (Fri, 07 Jan 2011)
@@ -1,5 +1,5 @@
/*=============================================================================
- Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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