summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/char
diff options
context:
space:
mode:
Diffstat (limited to 'boost/spirit/home/x3/char')
-rw-r--r--boost/spirit/home/x3/char/any_char.hpp41
-rw-r--r--boost/spirit/home/x3/char/char.hpp105
-rw-r--r--boost/spirit/home/x3/char/char_class.hpp26
-rw-r--r--boost/spirit/home/x3/char/char_class_tags.hpp29
-rw-r--r--boost/spirit/home/x3/char/char_parser.hpp6
-rw-r--r--boost/spirit/home/x3/char/char_set.hpp136
-rw-r--r--boost/spirit/home/x3/char/detail/cast_char.hpp4
-rw-r--r--boost/spirit/home/x3/char/literal_char.hpp10
-rw-r--r--boost/spirit/home/x3/char/negated_char_parser.hpp6
-rw-r--r--boost/spirit/home/x3/char/unicode.hpp6
10 files changed, 295 insertions, 74 deletions
diff --git a/boost/spirit/home/x3/char/any_char.hpp b/boost/spirit/home/x3/char/any_char.hpp
index 7ff769b8b2..380645d2ff 100644
--- a/boost/spirit/home/x3/char/any_char.hpp
+++ b/boost/spirit/home/x3/char/any_char.hpp
@@ -7,11 +7,9 @@
#if !defined(BOOST_SPIRIT_X3_ANY_CHAR_APRIL_16_2006_1051AM)
#define BOOST_SPIRIT_X3_ANY_CHAR_APRIL_16_2006_1051AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
+#include <boost/type_traits/extent.hpp>
#include <boost/spirit/home/x3/char/literal_char.hpp>
+#include <boost/spirit/home/x3/char/char_set.hpp>
namespace boost { namespace spirit { namespace x3
{
@@ -30,10 +28,39 @@ namespace boost { namespace spirit { namespace x3
}
template <typename Char>
- literal_char<Encoding>
- operator()(Char ch) const
+ literal_char<Encoding> operator()(Char ch) const
+ {
+ return { ch };
+ }
+
+ template <typename Char>
+ literal_char<Encoding> operator()(const Char (&ch)[2]) const
+ {
+ return { ch[0] };
+ }
+
+ template <typename Char, std::size_t N>
+ char_set<Encoding> operator()(const Char (&ch)[N]) const
+ {
+ return { ch };
+ }
+
+ template <typename Char>
+ char_range<Encoding> operator()(Char from, Char to) const
+ {
+ return { from, to };
+ }
+
+ template <typename Char>
+ char_range<Encoding> operator()(Char (&from)[2], Char (&to)[2]) const
+ {
+ return { from[0], to[0] };
+ }
+
+ template <typename Char>
+ char_set<Encoding> operator()(std::basic_string<Char> const& s) const
{
- return literal_char<Encoding>(ch);
+ return { s };
}
};
}}}
diff --git a/boost/spirit/home/x3/char/char.hpp b/boost/spirit/home/x3/char/char.hpp
index 9452dcd86d..5cfd720152 100644
--- a/boost/spirit/home/x3/char/char.hpp
+++ b/boost/spirit/home/x3/char/char.hpp
@@ -7,12 +7,9 @@
#if !defined(BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM)
#define BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/char/any_char.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
+#include <boost/spirit/home/support/char_encoding/iso8859_1.hpp>
#include <boost/spirit/home/support/char_encoding/standard.hpp>
#include <boost/spirit/home/support/char_encoding/standard_wide.hpp>
@@ -21,22 +18,72 @@ namespace boost { namespace spirit { namespace x3
namespace standard
{
typedef any_char<char_encoding::standard> char_type;
- char_type const char_ = char_type();
+ auto const char_ = char_type{};
+
+ inline literal_char<char_encoding::standard, unused_type>
+ lit(char ch)
+ {
+ return { ch };
+ }
+
+ inline literal_char<char_encoding::standard, unused_type>
+ lit(wchar_t ch)
+ {
+ return { ch };
+ }
+
}
using standard::char_type;
using standard::char_;
+ using standard::lit;
namespace standard_wide
{
typedef any_char<char_encoding::standard_wide> char_type;
- char_type const char_ = char_type();
+ auto const char_ = char_type{};
+
+ inline literal_char<char_encoding::standard_wide, unused_type>
+ lit(wchar_t ch)
+ {
+ return { ch };
+ }
}
namespace ascii
{
typedef any_char<char_encoding::ascii> char_type;
- char_type const char_ = char_type();
+ auto const char_ = char_type{};
+
+ inline literal_char<char_encoding::ascii, unused_type>
+ lit(char ch)
+ {
+ return { ch };
+ }
+
+ inline literal_char<char_encoding::ascii, unused_type>
+ lit(wchar_t ch)
+ {
+ return { ch };
+ }
+ }
+
+ namespace iso8859_1
+ {
+ typedef any_char<char_encoding::iso8859_1> char_type;
+ auto const char_ = char_type{};
+
+ inline literal_char<char_encoding::iso8859_1, unused_type>
+ lit(char ch)
+ {
+ return { ch };
+ }
+
+ inline literal_char<char_encoding::iso8859_1, unused_type>
+ lit(wchar_t ch)
+ {
+ return { ch };
+ }
}
namespace extension
@@ -52,7 +99,7 @@ namespace boost { namespace spirit { namespace x3
static type call(char ch)
{
- return type(ch);
+ return { ch };
}
};
@@ -67,22 +114,42 @@ namespace boost { namespace spirit { namespace x3
static type call(wchar_t ch)
{
- return type(ch);
+ return { ch };
}
};
- }
- inline literal_char<char_encoding::standard, unused_type>
- lit(char ch)
- {
- return literal_char<char_encoding::standard, unused_type>(ch);
- }
+ template <>
+ struct as_parser<char [2]>
+ {
+ typedef literal_char<
+ char_encoding::standard, unused_type>
+ type;
+
+ typedef type value_type;
+
+ static type call(char const ch[])
+ {
+ return { ch[0] };
+ }
+ };
+
+ template <>
+ struct as_parser<wchar_t [2]>
+ {
+ typedef literal_char<
+ char_encoding::standard_wide, unused_type>
+ type;
+
+ typedef type value_type;
+
+ static type call(wchar_t const ch[] )
+ {
+ return { ch[0] };
+ }
+ };
- inline literal_char<char_encoding::standard_wide, unused_type>
- lit(wchar_t ch)
- {
- return literal_char<char_encoding::standard_wide, unused_type>(ch);
}
+
}}}
#endif
diff --git a/boost/spirit/home/x3/char/char_class.hpp b/boost/spirit/home/x3/char/char_class.hpp
index 18b7131c0f..7fae90fdcd 100644
--- a/boost/spirit/home/x3/char/char_class.hpp
+++ b/boost/spirit/home/x3/char/char_class.hpp
@@ -7,35 +7,16 @@
#if !defined(BOOST_SPIRIT_X3_CHAR_CLASS_APRIL_16_2006_1051AM)
#define BOOST_SPIRIT_X3_CHAR_CLASS_APRIL_16_2006_1051AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/char/char_parser.hpp>
#include <boost/spirit/home/x3/char/detail/cast_char.hpp>
#include <boost/spirit/home/support/char_encoding/standard.hpp>
#include <boost/spirit/home/support/char_encoding/standard_wide.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
#include <boost/spirit/home/support/char_encoding/iso8859_1.hpp>
-
+#include <boost/spirit/home/x3/char/char_class_tags.hpp>
namespace boost { namespace spirit { namespace x3
{
///////////////////////////////////////////////////////////////////////////
- struct char_tag {};
- struct alnum_tag {};
- struct alpha_tag {};
- struct blank_tag {};
- struct cntrl_tag {};
- struct digit_tag {};
- struct graph_tag {};
- struct print_tag {};
- struct punct_tag {};
- struct space_tag {};
- struct xdigit_tag {};
- struct lower_tag {};
- struct upper_tag {};
-
- ///////////////////////////////////////////////////////////////////////////
template <typename Encoding>
struct char_class_base
{
@@ -80,10 +61,11 @@ namespace boost { namespace spirit { namespace x3
static bool const has_attribute = true;
template <typename Char, typename Context>
- bool test(Char ch, Context const&) const
+ bool test(Char ch, Context const& context) const
{
return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch))
- && char_class_base<Encoding>::is(tag(), ch);
+ && char_class_base<Encoding>::is(
+ get_case_compare<Encoding>(context).get_char_class_tag(tag()), ch);
}
};
diff --git a/boost/spirit/home/x3/char/char_class_tags.hpp b/boost/spirit/home/x3/char/char_class_tags.hpp
new file mode 100644
index 0000000000..0f3f61aae6
--- /dev/null
+++ b/boost/spirit/home/x3/char/char_class_tags.hpp
@@ -0,0 +1,29 @@
+/*=============================================================================
+ Copyright (c) 2001-2014 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)
+==============================================================================*/
+#if !defined(BOOST_SPIRIT_X3_CHAR_CLASS_TAGS_APRIL_16_2006_1051AM)
+#define BOOST_SPIRIT_X3_CHAR_CLASS_TAGS_APRIL_16_2006_1051AM
+
+
+namespace boost { namespace spirit { namespace x3
+{
+ ///////////////////////////////////////////////////////////////////////////
+ struct char_tag {};
+ struct alnum_tag {};
+ struct alpha_tag {};
+ struct blank_tag {};
+ struct cntrl_tag {};
+ struct digit_tag {};
+ struct graph_tag {};
+ struct print_tag {};
+ struct punct_tag {};
+ struct space_tag {};
+ struct xdigit_tag {};
+ struct lower_tag {};
+ struct upper_tag {};
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/char/char_parser.hpp b/boost/spirit/home/x3/char/char_parser.hpp
index 6943804369..973d493721 100644
--- a/boost/spirit/home/x3/char/char_parser.hpp
+++ b/boost/spirit/home/x3/char/char_parser.hpp
@@ -7,13 +7,10 @@
#if !defined(BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM)
#define BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/core/skip_over.hpp>
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
+#include <boost/spirit/home/x3/support/no_case.hpp>
namespace boost { namespace spirit { namespace x3
{
@@ -29,7 +26,6 @@ namespace boost { namespace spirit { namespace x3
, Context const& context, unused_type, Attribute& attr) const
{
x3::skip_over(first, last, context);
-
if (first != last && this->derived().test(*first, context))
{
x3::traits::move_to(*first, attr);
diff --git a/boost/spirit/home/x3/char/char_set.hpp b/boost/spirit/home/x3/char/char_set.hpp
new file mode 100644
index 0000000000..5a37ff6bea
--- /dev/null
+++ b/boost/spirit/home/x3/char/char_set.hpp
@@ -0,0 +1,136 @@
+/*=============================================================================
+ Copyright (c) 2001-2014 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)
+==============================================================================*/
+#if !defined(BOOST_SPIRIT_X3_CHAR_SET_OCT_12_2014_1051AM)
+#define BOOST_SPIRIT_X3_CHAR_SET_OCT_12_2014_1051AM
+
+#include <boost/spirit/home/x3/char/char_parser.hpp>
+#include <boost/spirit/home/x3/char/detail/cast_char.hpp>
+#include <boost/spirit/home/x3/support/traits/string_traits.hpp>
+#include <boost/spirit/home/x3/support/utility/utf8.hpp>
+#include <boost/spirit/home/x3/support/no_case.hpp>
+#include <boost/spirit/home/support/char_set/basic_chset.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Parser for a character range
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Encoding, typename Attribute = typename Encoding::char_type>
+ struct char_range
+ : char_parser< char_range<Encoding, Attribute> >
+ {
+
+ typedef typename Encoding::char_type char_type;
+ typedef Encoding encoding;
+ typedef Attribute attribute_type;
+ static bool const has_attribute =
+ !is_same<unused_type, attribute_type>::value;
+
+
+ char_range(char_type from_, char_type to_)
+ : from(from_), to(to_) {}
+
+ template <typename Char, typename Context>
+ bool test(Char ch_, Context& context) const
+ {
+
+ char_type ch = char_type(ch_); // optimize for token based parsing
+ return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_))
+ && (get_case_compare<encoding>(context)(ch, from) > 0 )
+ && (get_case_compare<encoding>(context)(ch , to) < 0 );
+ }
+
+ char_type from, to;
+ };
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Parser for a character set
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Encoding, typename Attribute = typename Encoding::char_type>
+ struct char_set : char_parser<char_set<Encoding, Attribute>>
+ {
+ typedef typename Encoding::char_type char_type;
+ typedef Encoding encoding;
+ typedef Attribute attribute_type;
+ static bool const has_attribute =
+ !is_same<unused_type, attribute_type>::value;
+
+ template <typename String>
+ char_set(String const& str)
+ {
+ using spirit::x3::detail::cast_char;
+
+ typedef typename
+ remove_const<
+ typename traits::char_type_of<String>::type
+ >::type
+ in_type;
+
+ in_type const* definition =
+ (in_type const*)traits::get_c_string(str);
+ in_type ch = *definition++;
+ while (ch)
+ {
+ in_type next = *definition++;
+ if (next == '-')
+ {
+ next = *definition++;
+ if (next == 0)
+ {
+ chset.set(cast_char<char_type>(ch));
+ chset.set('-');
+ break;
+ }
+ chset.set(
+ cast_char<char_type>(ch),
+ cast_char<char_type>(next)
+ );
+ }
+ else
+ {
+ chset.set(cast_char<char_type>(ch));
+ }
+ ch = next;
+ }
+ }
+
+ template <typename Char, typename Context>
+ bool test(Char ch_, Context const& context) const
+ {
+ return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_))
+ && get_case_compare<encoding>(context).in_set(ch_,chset);
+ }
+
+ support::detail::basic_chset<char_type> chset;
+ };
+
+ template <typename Encoding, typename Attribute>
+ struct get_info<char_set<Encoding, Attribute>>
+ {
+ typedef std::string result_type;
+ std::string operator()(char_set<Encoding, Attribute> const& p) const
+ {
+ return "char-set";
+ }
+ };
+
+ template <typename Encoding, typename Attribute>
+ struct get_info<char_range<Encoding, Attribute>>
+ {
+ typedef std::string result_type;
+ std::string operator()(char_range<Encoding, Attribute> const& p) const
+ {
+ return "char_range \"" + to_utf8(Encoding::toucs4(p.from)) + '-' + to_utf8(Encoding::toucs4(p.to))+ '"';
+ }
+ };
+
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/char/detail/cast_char.hpp b/boost/spirit/home/x3/char/detail/cast_char.hpp
index 03bda27a29..2b802c641d 100644
--- a/boost/spirit/home/x3/char/detail/cast_char.hpp
+++ b/boost/spirit/home/x3/char/detail/cast_char.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM)
#define BOOST_SPIRIT_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/type_traits/make_signed.hpp>
diff --git a/boost/spirit/home/x3/char/literal_char.hpp b/boost/spirit/home/x3/char/literal_char.hpp
index 94b2a239a6..ebeceee4df 100644
--- a/boost/spirit/home/x3/char/literal_char.hpp
+++ b/boost/spirit/home/x3/char/literal_char.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_LITERAL_CHAR_APRIL_16_2006_1051AM)
#define BOOST_SPIRIT_X3_LITERAL_CHAR_APRIL_16_2006_1051AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/char/char_parser.hpp>
#include <boost/spirit/home/x3/support/utility/utf8.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -31,12 +27,12 @@ namespace boost { namespace spirit { namespace x3
: ch(static_cast<char_type>(ch)) {}
template <typename Char, typename Context>
- bool test(Char ch_, Context const&) const
+ bool test(Char ch_, Context const& context) const
{
return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_))
- && ch == char_type(ch_);
+ && (get_case_compare<encoding>(context)(ch, char_type(ch_)) == 0);
}
-
+
char_type ch;
};
diff --git a/boost/spirit/home/x3/char/negated_char_parser.hpp b/boost/spirit/home/x3/char/negated_char_parser.hpp
index 392d712759..66692dc7a2 100644
--- a/boost/spirit/home/x3/char/negated_char_parser.hpp
+++ b/boost/spirit/home/x3/char/negated_char_parser.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_NEGATED_CHAR_PARSER_APR_16_2006_0906AM)
#define BOOST_SPIRIT_X3_NEGATED_CHAR_PARSER_APR_16_2006_0906AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/support/traits/has_attribute.hpp>
#include <boost/spirit/home/x3/char/char_parser.hpp>
@@ -40,7 +36,7 @@ namespace boost { namespace spirit { namespace x3
inline negated_char_parser<Positive>
operator~(char_parser<Positive> const& cp)
{
- return negated_char_parser<Positive>(cp.derived());
+ return { cp.derived() };
}
template <typename Positive>
diff --git a/boost/spirit/home/x3/char/unicode.hpp b/boost/spirit/home/x3/char/unicode.hpp
index 6954c40e40..290c7a4adc 100644
--- a/boost/spirit/home/x3/char/unicode.hpp
+++ b/boost/spirit/home/x3/char/unicode.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_UNICODE_JAN_20_2012_1218AM)
#define BOOST_SPIRIT_X3_UNICODE_JAN_20_2012_1218AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/char/char_parser.hpp>
#include <boost/spirit/home/x3/char/char.hpp>
#include <boost/spirit/home/x3/char/detail/cast_char.hpp>
@@ -431,7 +427,7 @@ namespace boost { namespace spirit { namespace x3
namespace unicode
{
typedef any_char<char_encoding::unicode> char_type;
- char_type const char_ = char_type();
+ auto const char_ = char_type{};
///////////////////////////////////////////////////////////////////////////
// Unicode Major Categories