mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
Spirit: replaced proto::lit with spirit::lit
[SVN r67754]
This commit is contained in:
@@ -43,7 +43,6 @@ Also, see __include_structure__.
|
||||
|
||||
[table
|
||||
[[Name]]
|
||||
[[`boost::spirit::lit // alias: boost::spirit::lex::lit` ]]
|
||||
[[`lex::char_`]]
|
||||
]
|
||||
|
||||
@@ -65,8 +64,6 @@ defined in __primitive_lexer_concept__.
|
||||
[[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`.]]
|
||||
]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
>
|
||||
> : 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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit { namespace karma
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
}
|
||||
};
|
||||
|
||||
// char_(...)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace detail
|
||||
{
|
||||
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, 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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// char_(...), lit(...)
|
||||
template <typename CharEncoding, typename Modifiers, typename A0>
|
||||
struct make_primitive<
|
||||
terminal_ex<
|
||||
tag::char_code<tag::char_, CharEncoding>
|
||||
, fusion::vector1<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;
|
||||
terminal_ex<
|
||||
tag::char_code<tag::char_, CharEncoding>
|
||||
, fusion::vector1<A0> >
|
||||
, Modifiers>
|
||||
: detail::make_char_direct<CharEncoding, Modifiers, A0, false>
|
||||
{};
|
||||
|
||||
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;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, unused_type) const
|
||||
{
|
||||
return result_type(fusion::at_c<0>(term.args));
|
||||
}
|
||||
};
|
||||
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 @@ namespace boost { namespace spirit { namespace karma
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// char_('a', 'z')
|
||||
template <typename CharEncoding, typename Modifiers, typename A0, typename A1>
|
||||
struct make_primitive<
|
||||
|
||||
29
include/boost/spirit/home/karma/detail/enable_lit.hpp
Normal file
29
include/boost/spirit/home/karma/detail/enable_lit.hpp
Normal file
@@ -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
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
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 @@ namespace boost { namespace spirit { namespace karma
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
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 @@ namespace boost { namespace spirit { namespace karma
|
||||
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
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
#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 @@ namespace boost { namespace spirit { namespace karma
|
||||
: 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
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
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)
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
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 @@ namespace boost { namespace spirit { namespace karma
|
||||
, Modifiers>
|
||||
: detail::make_uint_direct<T, Modifiers, Radix> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, typename Modifiers>
|
||||
@@ -526,6 +536,33 @@ namespace boost { namespace spirit { namespace karma
|
||||
: 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
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace karma
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace detail
|
||||
{
|
||||
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;
|
||||
|
||||
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>
|
||||
{
|
||||
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;
|
||||
terminal_ex<
|
||||
tag::char_code<tag::string, CharEncoding>
|
||||
, fusion::vector1<A0> >
|
||||
, Modifiers>
|
||||
: detail::make_string_direct<CharEncoding, Modifiers, A0, false>
|
||||
{};
|
||||
|
||||
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 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
|
||||
|
||||
@@ -44,13 +44,10 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace lex
|
||||
return result_type(fusion::at_c<0>(term.args)[0]);
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace boost::spirit::lex
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 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 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 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 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
}
|
||||
};
|
||||
|
||||
// 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<
|
||||
|
||||
29
include/boost/spirit/home/qi/detail/enable_lit.hpp
Normal file
29
include/boost/spirit/home/qi/detail/enable_lit.hpp
Normal file
@@ -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
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace boost { namespace spirit
|
||||
struct use_terminal<qi::domain, bool>
|
||||
: mpl::true_ {};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename A0> // enables bool_(...)
|
||||
struct use_terminal<qi::domain
|
||||
@@ -106,8 +107,9 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename Modifiers
|
||||
, typename Policies = bool_policies<T> >
|
||||
struct make_direct_bool
|
||||
@@ -242,7 +244,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename Modifiers
|
||||
, typename Policies = bool_policies<T> >
|
||||
struct make_literal_bool
|
||||
@@ -288,13 +289,14 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
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_
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<short, Modifiers>
|
||||
: make_literal_int<short> {};
|
||||
@@ -315,6 +314,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
: make_literal_int<boost::long_long_type> {};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits
|
||||
, typename Modifiers>
|
||||
@@ -322,7 +322,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
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<
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace boost { namespace spirit
|
||||
struct use_terminal<qi::domain, long double>
|
||||
: mpl::true_ {};
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename A0> // enables float_(...)
|
||||
struct use_terminal<qi::domain
|
||||
@@ -276,6 +277,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
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
|
||||
|
||||
@@ -81,11 +81,11 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit
|
||||
|
||||
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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T, unsigned Radix = 10, unsigned MinDigits = 1
|
||||
, int MaxDigits = -1>
|
||||
struct make_direct_uint
|
||||
@@ -303,7 +304,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
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 @@ namespace boost { namespace spirit { namespace qi
|
||||
return result_type(i);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
template <typename Modifiers>
|
||||
@@ -336,6 +337,7 @@ namespace boost { namespace spirit { namespace qi
|
||||
: make_literal_uint<boost::ulong_long_type> {};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits
|
||||
, typename Modifiers>
|
||||
|
||||
@@ -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 @@ namespace boost { namespace spirit
|
||||
, 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 @@ namespace boost { namespace spirit { namespace qi
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
|
||||
@@ -60,8 +60,7 @@ namespace boost { namespace spirit
|
||||
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 @@ namespace boost { namespace spirit
|
||||
( 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 @@ namespace boost { namespace spirit
|
||||
struct attr_cast {};
|
||||
struct as {};
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -209,6 +205,27 @@ BOOST_SPIRIT_DEFINE_CHAR_CODES(iso8859_1)
|
||||
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)
|
||||
|
||||
|
||||
97
include/boost/spirit/home/support/numeric_traits.hpp
Normal file
97
include/boost/spirit/home/support/numeric_traits.hpp
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -25,6 +26,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
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -82,6 +98,12 @@ namespace boost { namespace spirit { namespace traits
|
||||
template <typename T>
|
||||
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> {};
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ import testing ;
|
||||
[ 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 @@ import testing ;
|
||||
[ 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 @@ import testing ;
|
||||
[ 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 ]
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
105
test/karma/char3.cpp
Normal file
105
test/karma/char3.cpp
Normal file
@@ -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();
|
||||
}
|
||||
@@ -41,26 +41,20 @@ main()
|
||||
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 @@ main()
|
||||
#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("")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -50,7 +50,6 @@ int main()
|
||||
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
|
||||
|
||||
@@ -52,22 +52,6 @@ main()
|
||||
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;
|
||||
|
||||
71
test/qi/char2.cpp
Normal file
71
test/qi/char2.cpp
Normal file
@@ -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();
|
||||
}
|
||||
@@ -21,62 +21,50 @@ main()
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
{
|
||||
58
test/qi/lit2.cpp
Normal file
58
test/qi/lit2.cpp
Normal file
@@ -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();
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user