summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:30:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:32:57 +0900
commit71d216b90256936a9638f325af9bc69d720e75de (patch)
tree9c5f682d341c7c88ad0c8e3d4b262e00b6fb691a /boost/spirit/home/x3
parent733b5d5ae2c5d625211e2985ac25728ac3f54883 (diff)
downloadboost-71d216b90256936a9638f325af9bc69d720e75de.tar.gz
boost-71d216b90256936a9638f325af9bc69d720e75de.tar.bz2
boost-71d216b90256936a9638f325af9bc69d720e75de.zip
Imported Upstream version 1.59.0
Change-Id: I2dde00f4eca71df3eea9d251dcaecde18a6c90a5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/spirit/home/x3')
-rw-r--r--boost/spirit/home/x3/auxiliary.hpp6
-rw-r--r--boost/spirit/home/x3/auxiliary/any_parser.hpp4
-rw-r--r--boost/spirit/home/x3/auxiliary/attr.hpp12
-rw-r--r--boost/spirit/home/x3/auxiliary/eoi.hpp6
-rw-r--r--boost/spirit/home/x3/auxiliary/eol.hpp6
-rw-r--r--boost/spirit/home/x3/auxiliary/eps.hpp16
-rw-r--r--boost/spirit/home/x3/auxiliary/guard.hpp4
-rw-r--r--boost/spirit/home/x3/binary.hpp (renamed from boost/spirit/home/x3/support/utility/detail/testing.hpp)14
-rw-r--r--boost/spirit/home/x3/binary/binary.hpp175
-rw-r--r--boost/spirit/home/x3/char.hpp5
-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
-rw-r--r--boost/spirit/home/x3/core.hpp4
-rw-r--r--boost/spirit/home/x3/core/action.hpp6
-rw-r--r--boost/spirit/home/x3/core/call.hpp9
-rw-r--r--boost/spirit/home/x3/core/detail/parse_into_container.hpp77
-rw-r--r--boost/spirit/home/x3/core/parse.hpp4
-rw-r--r--boost/spirit/home/x3/core/parser.hpp12
-rw-r--r--boost/spirit/home/x3/core/proxy.hpp4
-rw-r--r--boost/spirit/home/x3/core/skip_over.hpp4
-rw-r--r--boost/spirit/home/x3/directive.hpp14
-rw-r--r--boost/spirit/home/x3/directive/confix.hpp83
-rw-r--r--boost/spirit/home/x3/directive/expect.hpp8
-rw-r--r--boost/spirit/home/x3/directive/lexeme.hpp12
-rw-r--r--boost/spirit/home/x3/directive/matches.hpp51
-rw-r--r--boost/spirit/home/x3/directive/no_case.hpp54
-rw-r--r--boost/spirit/home/x3/directive/no_skip.hpp8
-rw-r--r--boost/spirit/home/x3/directive/omit.hpp8
-rw-r--r--boost/spirit/home/x3/directive/raw.hpp4
-rw-r--r--boost/spirit/home/x3/directive/repeat.hpp157
-rw-r--r--boost/spirit/home/x3/directive/seek.hpp (renamed from boost/spirit/home/x3/extensions/seek.hpp)8
-rw-r--r--boost/spirit/home/x3/directive/skip.hpp16
-rw-r--r--boost/spirit/home/x3/directive/with.hpp6
-rw-r--r--boost/spirit/home/x3/extensions.hpp18
-rw-r--r--boost/spirit/home/x3/nonterminal.hpp4
-rw-r--r--boost/spirit/home/x3/nonterminal/debug_handler_state.hpp4
-rw-r--r--boost/spirit/home/x3/nonterminal/detail/rule.hpp63
-rw-r--r--boost/spirit/home/x3/nonterminal/rule.hpp35
-rw-r--r--boost/spirit/home/x3/nonterminal/simple_trace.hpp4
-rw-r--r--boost/spirit/home/x3/numeric.hpp4
-rw-r--r--boost/spirit/home/x3/numeric/bool.hpp93
-rw-r--r--boost/spirit/home/x3/numeric/bool_policies.hpp16
-rw-r--r--boost/spirit/home/x3/numeric/int.hpp4
-rw-r--r--boost/spirit/home/x3/numeric/real_policies.hpp4
-rw-r--r--boost/spirit/home/x3/numeric/uint.hpp4
-rw-r--r--boost/spirit/home/x3/operator.hpp4
-rw-r--r--boost/spirit/home/x3/operator/alternative.hpp15
-rw-r--r--boost/spirit/home/x3/operator/and_predicate.hpp6
-rw-r--r--boost/spirit/home/x3/operator/detail/alternative.hpp35
-rw-r--r--boost/spirit/home/x3/operator/detail/sequence.hpp62
-rw-r--r--boost/spirit/home/x3/operator/difference.hpp8
-rw-r--r--boost/spirit/home/x3/operator/kleene.hpp6
-rw-r--r--boost/spirit/home/x3/operator/list.hpp6
-rw-r--r--boost/spirit/home/x3/operator/not_predicate.hpp6
-rw-r--r--boost/spirit/home/x3/operator/optional.hpp6
-rw-r--r--boost/spirit/home/x3/operator/plus.hpp6
-rw-r--r--boost/spirit/home/x3/operator/sequence.hpp15
-rw-r--r--boost/spirit/home/x3/string.hpp4
-rw-r--r--boost/spirit/home/x3/string/detail/no_case_string_parse.hpp60
-rw-r--r--boost/spirit/home/x3/string/detail/string_parse.hpp16
-rw-r--r--boost/spirit/home/x3/string/detail/tst.hpp20
-rw-r--r--boost/spirit/home/x3/string/literal_string.hpp162
-rw-r--r--boost/spirit/home/x3/string/symbols.hpp146
-rw-r--r--boost/spirit/home/x3/string/tst.hpp16
-rw-r--r--boost/spirit/home/x3/string/tst_map.hpp12
-rw-r--r--boost/spirit/home/x3/support/ast/variant.hpp29
-rw-r--r--boost/spirit/home/x3/support/context.hpp46
-rw-r--r--boost/spirit/home/x3/support/no_case.hpp102
-rw-r--r--boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp4
-rw-r--r--boost/spirit/home/x3/support/numeric_utils/extract_int.hpp4
-rw-r--r--boost/spirit/home/x3/support/numeric_utils/extract_real.hpp4
-rw-r--r--boost/spirit/home/x3/support/numeric_utils/pow10.hpp4
-rw-r--r--boost/spirit/home/x3/support/numeric_utils/sign.hpp4
-rw-r--r--boost/spirit/home/x3/support/subcontext.hpp10
-rw-r--r--boost/spirit/home/x3/support/traits/attribute_category.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/attribute_of.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/attribute_type.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/container_traits.hpp34
-rw-r--r--boost/spirit/home/x3/support/traits/handles_container.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/has_attribute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/is_parser.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/is_substitute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/is_variant.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/make_attribute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/move_to.hpp8
-rw-r--r--boost/spirit/home/x3/support/traits/numeric_traits.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/optional_traits.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/print_attribute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/print_token.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/string_traits.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/transform_attribute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/tuple_traits.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/value_traits.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/variant_find_substitute.hpp4
-rw-r--r--boost/spirit/home/x3/support/traits/variant_has_substitute.hpp4
-rw-r--r--boost/spirit/home/x3/support/unused.hpp11
-rw-r--r--boost/spirit/home/x3/support/utility/annotate_on_success.hpp51
-rw-r--r--boost/spirit/home/x3/support/utility/error_reporting.hpp110
-rw-r--r--boost/spirit/home/x3/support/utility/integer_sequence.hpp94
-rw-r--r--boost/spirit/home/x3/support/utility/is_callable.hpp16
-rw-r--r--boost/spirit/home/x3/support/utility/sfinae.hpp5
-rw-r--r--boost/spirit/home/x3/support/utility/testing.hpp292
-rw-r--r--boost/spirit/home/x3/support/utility/unrefcv.hpp4
-rw-r--r--boost/spirit/home/x3/support/utility/utf8.hpp7
-rw-r--r--boost/spirit/home/x3/version.hpp19
113 files changed, 1927 insertions, 1037 deletions
diff --git a/boost/spirit/home/x3/auxiliary.hpp b/boost/spirit/home/x3/auxiliary.hpp
index afa89b2883..baa8a94c8b 100644
--- a/boost/spirit/home/x3/auxiliary.hpp
+++ b/boost/spirit/home/x3/auxiliary.hpp
@@ -8,17 +8,11 @@
#if !defined(BOOST_SPIRIT_X3_AUXILIARY_FEBRUARY_03_2007_0355PM)
#define BOOST_SPIRIT_X3_AUXILIARY_FEBRUARY_03_2007_0355PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/auxiliary/any_parser.hpp>
#include <boost/spirit/home/x3/auxiliary/eps.hpp>
#include <boost/spirit/home/x3/auxiliary/guard.hpp>
-//~ #include <boost/spirit/home/x3/auxiliary/lazy.hpp>
#include <boost/spirit/home/x3/auxiliary/eol.hpp>
#include <boost/spirit/home/x3/auxiliary/eoi.hpp>
#include <boost/spirit/home/x3/auxiliary/attr.hpp>
-//~ #include <boost/spirit/home/x3/auxiliary/attr_cast.hpp>
#endif
diff --git a/boost/spirit/home/x3/auxiliary/any_parser.hpp b/boost/spirit/home/x3/auxiliary/any_parser.hpp
index 0e257c04b1..2f97d26da7 100644
--- a/boost/spirit/home/x3/auxiliary/any_parser.hpp
+++ b/boost/spirit/home/x3/auxiliary/any_parser.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM)
#define BOOST_SPIRIT_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/subcontext.hpp>
diff --git a/boost/spirit/home/x3/auxiliary/attr.hpp b/boost/spirit/home/x3/auxiliary/attr.hpp
index 364cca0bee..5b3c7a5d85 100644
--- a/boost/spirit/home/x3/auxiliary/attr.hpp
+++ b/boost/spirit/home/x3/auxiliary/attr.hpp
@@ -9,10 +9,6 @@
#ifndef BOOST_SPIRIT_X3_ATTR_JUL_23_2008_0956AM
#define BOOST_SPIRIT_X3_ATTR_JUL_23_2008_0956AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
@@ -112,24 +108,24 @@ namespace boost { namespace spirit { namespace x3
typename remove_reference<Value>::type>::type>
operator()(Value&& value) const
{
- return {std::forward<Value>(value)};
+ return { std::forward<Value>(value) };
}
template <typename Value, std::size_t N>
attr_parser<typename remove_cv<Value>::type[N]>
operator()(Value (&value)[N]) const
{
- return {value};
+ return { value };
}
template <typename Value, std::size_t N>
attr_parser<typename remove_cv<Value>::type[N]>
operator()(Value (&&value)[N]) const
{
- return {value};
+ return { value };
}
};
- attr_gen const attr = attr_gen();
+ auto const attr = attr_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/auxiliary/eoi.hpp b/boost/spirit/home/x3/auxiliary/eoi.hpp
index 55bd51cfc4..778a20ba78 100644
--- a/boost/spirit/home/x3/auxiliary/eoi.hpp
+++ b/boost/spirit/home/x3/auxiliary/eoi.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_EOI_MARCH_23_2007_0454PM)
#define BOOST_SPIRIT_X3_EOI_MARCH_23_2007_0454PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/skip_over.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
@@ -39,7 +35,7 @@ namespace boost { namespace spirit { namespace x3
result_type operator()(eoi_parser const &) const { return "eoi"; }
};
- eoi_parser const eoi = eoi_parser();
+ auto const eoi = eoi_parser{};
}}}
#endif
diff --git a/boost/spirit/home/x3/auxiliary/eol.hpp b/boost/spirit/home/x3/auxiliary/eol.hpp
index 3d191b4269..00e4488937 100644
--- a/boost/spirit/home/x3/auxiliary/eol.hpp
+++ b/boost/spirit/home/x3/auxiliary/eol.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM)
#define BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/skip_over.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
@@ -53,7 +49,7 @@ namespace boost { namespace spirit { namespace x3
result_type operator()(eol_parser const &) const { return "eol"; }
};
- eol_parser const eol = eol_parser();
+ auto const eol = eol_parser{};
}}}
#endif
diff --git a/boost/spirit/home/x3/auxiliary/eps.hpp b/boost/spirit/home/x3/auxiliary/eps.hpp
index ab4d307931..816eea7b0f 100644
--- a/boost/spirit/home/x3/auxiliary/eps.hpp
+++ b/boost/spirit/home/x3/auxiliary/eps.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM)
#define BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/skip_over.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
@@ -72,21 +68,19 @@ namespace boost { namespace spirit { namespace x3
return true;
}
- semantic_predicate
- operator()(bool predicate) const
+ inline semantic_predicate operator()(bool predicate) const
{
- return semantic_predicate(predicate);
+ return { predicate };
}
template <typename F>
- lazy_semantic_predicate<F>
- operator()(F f) const
+ lazy_semantic_predicate<F> operator()(F f) const
{
- return lazy_semantic_predicate<F>(f);
+ return { f };
}
};
- eps_parser const eps = eps_parser();
+ auto const eps = eps_parser{};
}}}
#endif
diff --git a/boost/spirit/home/x3/auxiliary/guard.hpp b/boost/spirit/home/x3/auxiliary/guard.hpp
index 6fd63c822c..b2f1695fbc 100644
--- a/boost/spirit/home/x3/auxiliary/guard.hpp
+++ b/boost/spirit/home/x3/auxiliary/guard.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_GUARD_FERBRUARY_02_2013_0649PM)
#define BOOST_SPIRIT_X3_GUARD_FERBRUARY_02_2013_0649PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/directive/expect.hpp>
diff --git a/boost/spirit/home/x3/support/utility/detail/testing.hpp b/boost/spirit/home/x3/binary.hpp
index 1423d9fc7b..a5010db8ff 100644
--- a/boost/spirit/home/x3/support/utility/detail/testing.hpp
+++ b/boost/spirit/home/x3/binary.hpp
@@ -1,16 +1,16 @@
/*=============================================================================
- Copyright (c) 2014 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)
==============================================================================*/
-#if !defined(BOOST_SPIRIT_X3_DETAIL_TESTING_JUNE_05_2014_00422PM)
-#define BOOST_SPIRIT_X3_DETAIL_TESTING_JUNE_05_2014_00422PM
-
-namespace boost { namespace spirit { namespace x3 { namespace testing
-{
+#if !defined(BOOST_SPIRIT_X3_BINARY_MAY_08_2007_0906AM)
+#define BOOST_SPIRIT_X3_BINARY_MAY_08_2007_0906AM
+#if defined(_MSC_VER)
+#pragma once
+#endif
-}}}}
+#include <boost/spirit/home/x3/binary/binary.hpp>
#endif
diff --git a/boost/spirit/home/x3/binary/binary.hpp b/boost/spirit/home/x3/binary/binary.hpp
new file mode 100644
index 0000000000..b3d3a79473
--- /dev/null
+++ b/boost/spirit/home/x3/binary/binary.hpp
@@ -0,0 +1,175 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Hartmut Kaiser
+ 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)
+==============================================================================*/
+#if !defined(BOOST_SPIRIT_X3_BINARY_MAY_08_2007_0808AM)
+#define BOOST_SPIRIT_X3_BINARY_MAY_08_2007_0808AM
+
+#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 <cstdint>
+
+#include <boost/endian/conversion.hpp>
+#include <boost/endian/arithmetic.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_enum.hpp>
+#include <boost/type_traits/is_floating_point.hpp>
+#include <boost/config.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ template <typename V, typename T
+ , boost::endian::order endian, std::size_t bits>
+ struct binary_lit_parser
+ : parser<binary_lit_parser<V, T, endian, bits> >
+ {
+ static bool const has_attribute = false;
+
+ binary_lit_parser(V n_)
+ : n(n_) {}
+
+ template <typename Iterator, typename Context, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& context, unused_type, Attribute& attr_param) const
+ {
+ x3::skip_over(first, last, context);
+
+ auto bytes = reinterpret_cast<const unsigned char*>(&n);
+
+ Iterator it = first;
+ for (unsigned int i = 0; i < sizeof(n); ++i)
+ {
+ if (it == last || *bytes++ != static_cast<unsigned char>(*it++))
+ return false;
+ }
+
+ first = it;
+ x3::traits::move_to(n, attr_param);
+ return true;
+ }
+
+ boost::endian::endian_arithmetic<endian, T, bits> n;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, boost::endian::order endian, std::size_t bits>
+ struct any_binary_parser : parser<any_binary_parser<T, endian, bits > >
+ {
+
+ typedef T attribute_type;
+ static bool const has_attribute =
+ !is_same<unused_type, attribute_type>::value;
+
+ template <typename Iterator, typename Context, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& context, unused_type, Attribute& attr_param) const
+ {
+ x3::skip_over(first, last, context);
+
+ attribute_type attr_;
+ auto bytes = reinterpret_cast<unsigned char*>(&attr_);
+
+ Iterator it = first;
+ for (unsigned int i = 0; i < sizeof(attr_); ++i)
+ {
+ if (it == last)
+ return false;
+ *bytes++ = *it++;
+ }
+
+ first = it;
+ x3::traits::move_to(
+ endian::conditional_reverse<endian, endian::order::native>(attr_)
+ , attr_param );
+ return true;
+ }
+
+ template <typename V>
+ binary_lit_parser< V, T, endian, bits> operator()(V n) const
+ {
+ return {n};
+ }
+ };
+
+#define BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(name, endiantype, attrtype, bits) \
+ typedef any_binary_parser< attrtype, boost::endian::order::endiantype, bits > name##type; \
+ name##type const name = name##type();
+
+
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(byte_, native, uint_least8_t, 8)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(word, native, uint_least16_t, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_word, big, uint_least16_t, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_word, little, uint_least16_t, 16)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(dword, native, uint_least32_t, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_dword, big, uint_least32_t, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_dword, little, uint_least32_t, 32)
+#ifdef BOOST_HAS_LONG_LONG
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(qword, native, uint_least64_t, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_qword, big, uint_least64_t, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_qword, little, uint_least64_t, 64)
+#endif
+
+ // Use a pseudo configuration macro to make clear that endian libray support
+ // for floating point types is required. Must be removed as soon as the endian library
+ // properly supports floating point types.
+#ifdef BOOST_ENDIAN_HAS_FLOATING_POINT
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(bin_float, native, float, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_bin_float, big, float, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_bin_float, little, float, 32)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(bin_double, native, double, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(big_bin_double, big, double, 64)
+ BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(little_bin_double, little, double, 64)
+#endif
+
+#undef BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T, std::size_t bits>
+ struct get_info<any_binary_parser<T, endian::order::little, bits>>
+ {
+ typedef std::string result_type;
+ std::string operator()(any_binary_parser<T, endian::order::little, bits> const& p) const
+ {
+ return "little-endian binary";
+ }
+ };
+
+ template <typename T, std::size_t bits>
+ struct get_info<any_binary_parser<T, endian::order::big, bits>>
+ {
+ typedef std::string result_type;
+ std::string operator()(any_binary_parser<T, endian::order::big, bits> const& p) const
+ {
+ return "big-endian binary";
+ }
+ };
+
+ template <typename V, typename T, std::size_t bits>
+ struct get_info<binary_lit_parser<V, T, endian::order::little, bits>>
+ {
+ typedef std::string result_type;
+ std::string operator()(binary_lit_parser<V, T, endian::order::little, bits> const& p) const
+ {
+ return "little-endian binary";
+ }
+ };
+
+ template <typename V, typename T, std::size_t bits>
+ struct get_info<binary_lit_parser<V, T, endian::order::big, bits>>
+ {
+ typedef std::string result_type;
+ std::string operator()(binary_lit_parser<V, T, endian::order::big, bits> const& p) const
+ {
+ return "big-endian binary";
+ }
+ };
+
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/char.hpp b/boost/spirit/home/x3/char.hpp
index 19d26de3a2..da8155b6b0 100644
--- a/boost/spirit/home/x3/char.hpp
+++ b/boost/spirit/home/x3/char.hpp
@@ -7,14 +7,11 @@
#if !defined(BOOST_SPIRIT_X3_CHAR_FEBRUARY_02_2007_0921AM)
#define BOOST_SPIRIT_X3_CHAR_FEBRUARY_02_2007_0921AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/char/char_parser.hpp>
#include <boost/spirit/home/x3/char/negated_char_parser.hpp>
#include <boost/spirit/home/x3/char/char.hpp>
#include <boost/spirit/home/x3/char/char_class.hpp>
+#include <boost/spirit/home/x3/char/char_set.hpp>
#if defined(BOOST_SPIRIT_X3_UNICODE)
#include <boost/spirit/home/x3/char/unicode.hpp>
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
diff --git a/boost/spirit/home/x3/core.hpp b/boost/spirit/home/x3/core.hpp
index a4f875e38a..b732c408e0 100644
--- a/boost/spirit/home/x3/core.hpp
+++ b/boost/spirit/home/x3/core.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_CORE_APRIL_04_2012_0318PM)
#define BOOST_SPIRIT_X3_CORE_APRIL_04_2012_0318PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parse.hpp>
//~ #include <boost/spirit/home/x3/core/parse_attr.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
diff --git a/boost/spirit/home/x3/core/action.hpp b/boost/spirit/home/x3/core/action.hpp
index 890933fff1..7c34ac0ece 100644
--- a/boost/spirit/home/x3/core/action.hpp
+++ b/boost/spirit/home/x3/core/action.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_ACTION_JANUARY_07_2007_1128AM)
#define SPIRIT_ACTION_JANUARY_07_2007_1128AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/support/traits/make_attribute.hpp>
@@ -113,7 +109,7 @@ namespace boost { namespace spirit { namespace x3
inline action<typename extension::as_parser<P>::value_type, Action>
operator/(P const& p, Action f)
{
- return {as_parser(p), f};
+ return { as_parser(p), f };
}
}}}
diff --git a/boost/spirit/home/x3/core/call.hpp b/boost/spirit/home/x3/core/call.hpp
index a4139751df..9674c93efe 100644
--- a/boost/spirit/home/x3/core/call.hpp
+++ b/boost/spirit/home/x3/core/call.hpp
@@ -19,8 +19,7 @@ namespace boost { namespace spirit { namespace x3
struct rule_val_context_tag;
template <typename Context>
- inline auto _val(Context const& context)
- -> decltype(x3::get<rule_val_context_tag>(context))
+ inline decltype(auto) _val(Context const& context)
{
return x3::get<rule_val_context_tag>(context);
}
@@ -29,8 +28,7 @@ namespace boost { namespace spirit { namespace x3
struct where_context_tag;
template <typename Context>
- inline auto _where(Context const& context)
- -> decltype(x3::get<where_context_tag>(context))
+ inline decltype(auto) _where(Context const& context)
{
return x3::get<where_context_tag>(context);
}
@@ -39,8 +37,7 @@ namespace boost { namespace spirit { namespace x3
struct attr_context_tag;
template <typename Context>
- inline auto _attr(Context const& context)
- -> decltype(x3::get<attr_context_tag>(context))
+ inline decltype(auto) _attr(Context const& context)
{
return x3::get<attr_context_tag>(context);
}
diff --git a/boost/spirit/home/x3/core/detail/parse_into_container.hpp b/boost/spirit/home/x3/core/detail/parse_into_container.hpp
index 4b19115a67..96424a4278 100644
--- a/boost/spirit/home/x3/core/detail/parse_into_container.hpp
+++ b/boost/spirit/home/x3/core/detail/parse_into_container.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_PARSE_INTO_CONTAINER_JAN_15_2013_0957PM)
#define SPIRIT_PARSE_INTO_CONTAINER_JAN_15_2013_0957PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <type_traits>
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
@@ -41,21 +37,24 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
}
};
-
+/* $$$ clang reports: warning: class template partial specialization contains
+ * a template parameter that can not be deduced; this partial specialization
+ * will never be used $$$
+ *
// save to associative fusion container where Key
// is variant over possible keys
template <typename ...T>
struct save_to_assoc_attr<variant<T...> >
{
typedef variant<T...> variant_t;
-
+
template <typename Value, typename Attribute>
static void call(const variant_t key, Value& value, Attribute& attr)
{
apply_visitor(saver_visitor<Attribute, Value>(attr, value), key);
}
};
-
+*/
template <typename Attribute, typename Value>
struct saver_visitor : boost::static_visitor<void>
{
@@ -64,7 +63,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
Attribute& attr;
Value& value;
-
+
template <typename Key>
void operator()(Key) const
{
@@ -72,6 +71,13 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
}
};
+ template <typename Parser, typename Container, typename Context>
+ struct parser_accepts_container
+ : traits::is_substitute<
+ typename traits::attribute_of<Parser, Context>::type
+ , Container
+ >
+ {};
template <typename Parser>
struct parse_into_container_base_impl
@@ -81,10 +87,10 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
// Parser has attribute (synthesize; Attribute is a container)
template <typename Iterator, typename Context
, typename RContext, typename Attribute>
- static bool call_synthesize(
+ static bool call_synthesize_x(
Parser const& parser
, Iterator& first, Iterator const& last
- , Context const& context, RContext& rcontext, Attribute& attr)
+ , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_)
{
// synthesized attribute needs to be value initialized
typedef typename
@@ -100,6 +106,33 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
return true;
}
+ // Parser has attribute (synthesize; Attribute is a container)
+ template <typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ static bool call_synthesize_x(
+ Parser const& parser
+ , Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_)
+ {
+ return parser.parse(first, last, context, rcontext, attr);
+ }
+
+ // Parser has attribute (synthesize; Attribute is a container)
+ template <typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ static bool call_synthesize(
+ Parser const& parser
+ , Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr)
+ {
+ typedef
+ parser_accepts_container<Parser, Attribute, Context>
+ parser_accepts_container;
+
+ return call_synthesize_x(parser, first, last, context, rcontext, attr
+ , parser_accepts_container());
+ }
+
// Parser has attribute (synthesize; Attribute is a single element fusion sequence)
template <typename Iterator, typename Context
, typename RContext, typename Attribute>
@@ -173,7 +206,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
{
return parser.parse(first, last, context, rcontext, unused);
}
-
+
public:
@@ -190,7 +223,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
template <typename Parser, typename Context, typename RContext, typename Enable = void>
struct parse_into_container_impl : parse_into_container_base_impl<Parser> {};
- template <typename Parser, typename Container, typename RContext, typename Context>
+ template <typename Parser, typename Container, typename Context>
struct parser_attr_is_substitute_for_container_value
: traits::is_substitute<
typename traits::attribute_of<Parser, Context>::type
@@ -206,7 +239,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
static bool call(
Parser const& parser
, Iterator& first, Iterator const& last
- , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_)
+ , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_)
{
return parse_into_container_base_impl<Parser>::call(
parser, first, last, context, rcontext, attr);
@@ -216,7 +249,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
static bool call(
Parser const& parser
, Iterator& first, Iterator const& last
- , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_)
+ , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_)
{
return parser.parse(first, last, context, rcontext, attr);
}
@@ -226,9 +259,21 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
, Iterator& first, Iterator const& last
, Context const& context, RContext& rcontext, Attribute& attr)
{
+ typedef parser_accepts_container<
+ Parser, Attribute, Context>
+ parser_accepts_container;
+
+ typedef parser_attr_is_substitute_for_container_value<
+ Parser, Attribute, Context>
+ parser_attr_is_substitute_for_container_value;
+
+ typedef mpl::or_<
+ parser_accepts_container
+ , mpl::not_<parser_attr_is_substitute_for_container_value>>
+ pass_attibute_as_is;
+
return call(parser, first, last, context, rcontext, attr,
- parser_attr_is_substitute_for_container_value<
- Parser, Attribute, Context, RContext>());
+ pass_attibute_as_is());
}
};
diff --git a/boost/spirit/home/x3/core/parse.hpp b/boost/spirit/home/x3/core/parse.hpp
index ac36e3c7ea..234903037f 100644
--- a/boost/spirit/home/x3/core/parse.hpp
+++ b/boost/spirit/home/x3/core/parse.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_PARSE_APRIL_16_2006_0442PM)
#define BOOST_SPIRIT_X3_PARSE_APRIL_16_2006_0442PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/core/skip_over.hpp>
diff --git a/boost/spirit/home/x3/core/parser.hpp b/boost/spirit/home/x3/core/parser.hpp
index bc63a7438b..0df69304e0 100644
--- a/boost/spirit/home/x3/core/parser.hpp
+++ b/boost/spirit/home/x3/core/parser.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_PARSER_OCTOBER_16_2008_0254PM)
#define BOOST_SPIRIT_X3_PARSER_OCTOBER_16_2008_0254PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/bool.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/remove_cv.hpp>
@@ -30,10 +26,6 @@
namespace boost { namespace spirit { namespace x3
{
- using x3::unused_type;
- using x3::unused;
- using x3::get;
-
template <typename Subject, typename Action>
struct action;
@@ -81,7 +73,7 @@ namespace boost { namespace spirit { namespace x3
typedef Subject subject_type;
static bool const has_action = Subject::has_action;
- unary_parser(Subject subject)
+ unary_parser(Subject const& subject)
: subject(subject) {}
unary_parser const& get_unary() const { return *this; }
@@ -98,7 +90,7 @@ namespace boost { namespace spirit { namespace x3
static bool const has_action =
left_type::has_action || right_type::has_action;
- binary_parser(Left left, Right right)
+ binary_parser(Left const& left, Right const& right)
: left(left), right(right) {}
binary_parser const& get_binary() const { return *this; }
diff --git a/boost/spirit/home/x3/core/proxy.hpp b/boost/spirit/home/x3/core/proxy.hpp
index 1a0ade59a8..6fe818d8b2 100644
--- a/boost/spirit/home/x3/core/proxy.hpp
+++ b/boost/spirit/home/x3/core/proxy.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_PROXY_FEBRUARY_1_2013_0211PM)
#define BOOST_SPIRIT_X3_PROXY_FEBRUARY_1_2013_0211PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
diff --git a/boost/spirit/home/x3/core/skip_over.hpp b/boost/spirit/home/x3/core/skip_over.hpp
index 643ddb1f5b..ef7982a8cd 100644
--- a/boost/spirit/home/x3/core/skip_over.hpp
+++ b/boost/spirit/home/x3/core/skip_over.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_SKIP_APRIL_16_2006_0625PM)
#define BOOST_SPIRIT_X3_SKIP_APRIL_16_2006_0625PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
diff --git a/boost/spirit/home/x3/directive.hpp b/boost/spirit/home/x3/directive.hpp
index 81f7a8536a..0ff683f930 100644
--- a/boost/spirit/home/x3/directive.hpp
+++ b/boost/spirit/home/x3/directive.hpp
@@ -1,5 +1,5 @@
/*=============================================================================
- Copyright (c) 2001-2014 Joel de Guzman
+ Copyright (c) 2001-2015 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)
@@ -7,21 +7,19 @@
#if !defined(BOOST_SPIRIT_X3_DIRECTIVE_FEBRUARY_05_2007_0313PM)
#define BOOST_SPIRIT_X3_DIRECTIVE_FEBRUARY_05_2007_0313PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
//~ #include <boost/spirit/home/x3/directive/as.hpp>
+#include <boost/spirit/home/x3/directive/confix.hpp>
//~ #include <boost/spirit/home/x3/directive/encoding.hpp>
//~ #include <boost/spirit/home/x3/directive/hold.hpp>
#include <boost/spirit/home/x3/directive/expect.hpp>
#include <boost/spirit/home/x3/directive/lexeme.hpp>
+#include <boost/spirit/home/x3/directive/matches.hpp>
+#include <boost/spirit/home/x3/directive/no_case.hpp>
#include <boost/spirit/home/x3/directive/no_skip.hpp>
-//~ #include <boost/spirit/home/x3/directive/matches.hpp>
-//~ #include <boost/spirit/home/x3/directive/no_case.hpp>
#include <boost/spirit/home/x3/directive/omit.hpp>
#include <boost/spirit/home/x3/directive/raw.hpp>
-//~ #include <boost/spirit/home/x3/directive/repeat.hpp>
+#include <boost/spirit/home/x3/directive/repeat.hpp>
+#include <boost/spirit/home/x3/directive/seek.hpp>
#include <boost/spirit/home/x3/directive/skip.hpp>
#include <boost/spirit/home/x3/directive/with.hpp>
diff --git a/boost/spirit/home/x3/directive/confix.hpp b/boost/spirit/home/x3/directive/confix.hpp
new file mode 100644
index 0000000000..0d99e58f4e
--- /dev/null
+++ b/boost/spirit/home/x3/directive/confix.hpp
@@ -0,0 +1,83 @@
+/*=============================================================================
+ Copyright (c) 2009 Chris Hoeppler
+ Copyright (c) 2014 Lee Clagett
+
+ 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_CONFIX_MAY_30_2014_1819PM)
+#define BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM
+
+#include <boost/spirit/home/x3/core/parser.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ template<typename Prefix, typename Subject, typename Postfix>
+ struct confix_directive :
+ unary_parser<Subject, confix_directive<Prefix, Subject, Postfix>>
+ {
+ typedef unary_parser<
+ Subject, confix_directive<Prefix, Subject, Postfix>> base_type;
+ static bool const is_pass_through_unary = true;
+ static bool const handles_container = Subject::handles_container;
+
+ confix_directive(Prefix const& prefix
+ , Subject const& subject
+ , Postfix const& postfix) :
+ base_type(subject),
+ prefix(prefix),
+ postfix(postfix)
+ {
+ }
+
+ template<typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse(
+ Iterator& first, Iterator const& last
+ , Context& context, RContext& rcontext, Attribute& attr) const
+ {
+ Iterator save = first;
+
+ if (!(prefix.parse(first, last, context, rcontext, unused) &&
+ this->subject.parse(first, last, context, rcontext, attr) &&
+ postfix.parse(first, last, context, rcontext, unused)))
+ {
+ first = save;
+ return false;
+ }
+
+ return true;
+ }
+
+ Prefix prefix;
+ Postfix postfix;
+ };
+
+ template<typename Prefix, typename Postfix>
+ struct confix_gen
+ {
+ template<typename Subject>
+ confix_directive<
+ Prefix, typename extension::as_parser<Subject>::value_type, Postfix>
+ operator[](Subject const& subject) const
+ {
+ return { prefix, as_parser(subject), postfix };
+ }
+
+ Prefix prefix;
+ Postfix postfix;
+ };
+
+
+ template<typename Prefix, typename Postfix>
+ confix_gen<typename extension::as_parser<Prefix>::value_type,
+ typename extension::as_parser<Postfix>::value_type>
+ confix(Prefix const& prefix, Postfix const& postfix)
+ {
+ return { as_parser(prefix), as_parser(postfix) };
+ }
+
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/directive/expect.hpp b/boost/spirit/home/x3/directive/expect.hpp
index 4e59ce5dca..879d92c2df 100644
--- a/boost/spirit/home/x3/directive/expect.hpp
+++ b/boost/spirit/home/x3/directive/expect.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_EXPECT_MARCH_16_2012_1024PM)
#define SPIRIT_EXPECT_MARCH_16_2012_1024PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/throw_exception.hpp>
@@ -70,11 +66,11 @@ namespace boost { namespace spirit { namespace x3
expect_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- expect_gen const expect = expect_gen();
+ auto const expect = expect_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/lexeme.hpp b/boost/spirit/home/x3/directive/lexeme.hpp
index e5104272f9..ce3a6def80 100644
--- a/boost/spirit/home/x3/directive/lexeme.hpp
+++ b/boost/spirit/home/x3/directive/lexeme.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_LEXEME_MARCH_24_2007_0802AM)
#define SPIRIT_LEXEME_MARCH_24_2007_0802AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/core/skip_over.hpp>
@@ -29,7 +25,7 @@ namespace boost { namespace spirit { namespace x3
lexeme_directive(Subject const& subject)
: base_type(subject) {}
-
+
template <typename Iterator, typename Context
, typename RContext, typename Attribute>
typename enable_if<has_skipper<Context>, bool>::type
@@ -58,8 +54,6 @@ namespace boost { namespace spirit { namespace x3
, Context const& context, RContext& rcontext, Attribute& attr) const
{
// no need to pre-skip if skipper is unused
- //- x3::skip_over(first, last, context);
-
return this->subject.parse(
first, last
, context
@@ -74,11 +68,11 @@ namespace boost { namespace spirit { namespace x3
lexeme_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- lexeme_gen const lexeme = lexeme_gen();
+ auto const lexeme = lexeme_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/matches.hpp b/boost/spirit/home/x3/directive/matches.hpp
new file mode 100644
index 0000000000..2aae43b50d
--- /dev/null
+++ b/boost/spirit/home/x3/directive/matches.hpp
@@ -0,0 +1,51 @@
+/*=============================================================================
+ Copyright (c) 2015 Mario Lang
+ 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_HOME_X3_EXTENSIONS_MATCHES_HPP)
+#define BOOST_SPIRIT_HOME_X3_EXTENSIONS_MATCHES_HPP
+
+#include <boost/spirit/home/x3/core/parser.hpp>
+#include <boost/spirit/home/x3/support/traits/move_to.hpp>
+#include <boost/spirit/home/x3/support/unused.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ template <typename Subject>
+ struct matches_directive : unary_parser<Subject, matches_directive<Subject>>
+ {
+ using base_type = unary_parser<Subject, matches_directive<Subject>>;
+ static bool const has_attribute = true;
+ using attribute_type = bool;
+
+ matches_directive(Subject const& subject) : base_type(subject) {}
+
+ template <typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr) const
+ {
+ bool const result = this->subject.parse(
+ first, last, context, rcontext, unused);
+ traits::move_to(result, attr);
+ return true;
+ }
+ };
+
+ struct matches_gen
+ {
+ template <typename Subject>
+ matches_directive<typename extension::as_parser<Subject>::value_type>
+ operator[](Subject const& subject) const
+ {
+ return { as_parser(subject) };
+ }
+ };
+
+ auto const matches = matches_gen{};
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/directive/no_case.hpp b/boost/spirit/home/x3/directive/no_case.hpp
new file mode 100644
index 0000000000..b00315614a
--- /dev/null
+++ b/boost/spirit/home/x3/directive/no_case.hpp
@@ -0,0 +1,54 @@
+/*=============================================================================
+ Copyright (c) 2014 Thomas Bernard
+
+ 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(SPIRIT_NO_CASE_SEPT_16_2014_0912PM)
+#define SPIRIT_NO_CASE_SEPT_16_2014_0912PM
+
+#include <boost/spirit/home/x3/support/context.hpp>
+#include <boost/spirit/home/x3/support/unused.hpp>
+#include <boost/spirit/home/x3/support/no_case.hpp>
+#include <boost/spirit/home/x3/core/parser.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ // propagate no_case information through the context
+ template <typename Subject>
+ struct no_case_directive : unary_parser<Subject, no_case_directive<Subject>>
+ {
+ typedef unary_parser<Subject, no_case_directive<Subject> > base_type;
+ static bool const is_pass_through_unary = true;
+ static bool const handles_container = Subject::handles_container;
+
+ no_case_directive(Subject const& subject)
+ : base_type(subject) {}
+
+ template <typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr) const
+ {
+ return this->subject.parse(
+ first, last
+ , make_context<no_case_tag>(no_case_compare_, context)
+ , rcontext
+ , attr);
+ }
+ };
+
+ struct no_case_gen
+ {
+ template <typename Subject>
+ no_case_directive<typename extension::as_parser<Subject>::value_type>
+ operator[](Subject const& subject) const
+ {
+ return { as_parser(subject) };
+ }
+ };
+
+ auto const no_case = no_case_gen{};
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/directive/no_skip.hpp b/boost/spirit/home/x3/directive/no_skip.hpp
index 14dee4d85c..c6245f577a 100644
--- a/boost/spirit/home/x3/directive/no_skip.hpp
+++ b/boost/spirit/home/x3/directive/no_skip.hpp
@@ -9,10 +9,6 @@
#if !defined(SPIRIT_NO_SKIP_JAN_16_2010_0802PM)
#define SPIRIT_NO_SKIP_JAN_16_2010_0802PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/core/skip_over.hpp>
@@ -72,11 +68,11 @@ namespace boost { namespace spirit { namespace x3
no_skip_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- no_skip_gen const no_skip = no_skip_gen();
+ auto const no_skip = no_skip_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/omit.hpp b/boost/spirit/home/x3/directive/omit.hpp
index 43ebd49aaf..3053676983 100644
--- a/boost/spirit/home/x3/directive/omit.hpp
+++ b/boost/spirit/home/x3/directive/omit.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_OMIT_MARCH_24_2007_0802AM)
#define SPIRIT_OMIT_MARCH_24_2007_0802AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
@@ -45,11 +41,11 @@ namespace boost { namespace spirit { namespace x3
omit_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- omit_gen const omit = omit_gen();
+ auto const omit = omit_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/raw.hpp b/boost/spirit/home/x3/directive/raw.hpp
index e6bcd9a3a1..8432e13888 100644
--- a/boost/spirit/home/x3/directive/raw.hpp
+++ b/boost/spirit/home/x3/directive/raw.hpp
@@ -60,11 +60,11 @@ namespace boost { namespace spirit { namespace x3
raw_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- raw_gen const raw = raw_gen();
+ auto const raw = raw_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/repeat.hpp b/boost/spirit/home/x3/directive/repeat.hpp
new file mode 100644
index 0000000000..1cdee97fb9
--- /dev/null
+++ b/boost/spirit/home/x3/directive/repeat.hpp
@@ -0,0 +1,157 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+ Copyright (c) 2001-2011 Hartmut Kaiser
+ Copyright (c) 2014 Thomas Bernard
+
+ 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(SPIRIT_X3_REPEAT_APRIL_16_2014_0848AM)
+#define SPIRIT_X3_REPEAT_APRIL_16_2014_0848AM
+
+#include <boost/function_types/function_type.hpp>
+#include <boost/function_types/parameter_types.hpp>
+#include <boost/spirit/home/x3/core/parser.hpp>
+#include <boost/spirit/home/x3/operator/kleene.hpp>
+
+namespace boost { namespace spirit { namespace x3 { namespace detail
+{
+ template <typename T>
+ struct exact_count // handles repeat(exact)[p]
+ {
+ typedef T type;
+ bool got_max(T i) const { return i >= exact_value; }
+ bool got_min(T i) const { return i >= exact_value; }
+
+ T const exact_value;
+ };
+
+ template <typename T>
+ struct finite_count // handles repeat(min, max)[p]
+ {
+ typedef T type;
+ bool got_max(T i) const { return i >= max_value; }
+ bool got_min(T i) const { return i >= min_value; }
+
+ T const min_value;
+ T const max_value;
+ };
+
+ template <typename T>
+ struct infinite_count // handles repeat(min, inf)[p]
+ {
+ typedef T type;
+ bool got_max(T /*i*/) const { return false; }
+ bool got_min(T i) const { return i >= min_value; }
+
+ T const min_value;
+ };
+}}}}
+
+namespace boost { namespace spirit { namespace x3
+{
+ template<typename Subject, typename RepeatCountLimit>
+ struct repeat_directive : unary_parser<Subject, repeat_directive<Subject,RepeatCountLimit>>
+ {
+ typedef unary_parser<Subject, repeat_directive<Subject,RepeatCountLimit>> base_type;
+ static bool const is_pass_through_unary = true;
+ static bool const handles_container = true;
+
+ repeat_directive(Subject const& subject, RepeatCountLimit const& repeat_limit_)
+ : base_type(subject)
+ , repeat_limit(repeat_limit_)
+ {}
+
+ template<typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse(
+ Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr) const
+ {
+ Iterator local_iterator = first;
+ typename RepeatCountLimit::type i{};
+ for (/**/; !repeat_limit.got_min(i); ++i)
+ {
+ if (!detail::parse_into_container(
+ this->subject, local_iterator, last, context, rcontext, attr))
+ return false;
+ }
+
+ first = local_iterator;
+ // parse some more up to the maximum specified
+ for (/**/; !repeat_limit.got_max(i); ++i)
+ {
+ if (!detail::parse_into_container(
+ this->subject, first, last, context, rcontext, attr))
+ break;
+ }
+ return true;
+ }
+
+ RepeatCountLimit repeat_limit;
+ };
+
+ // Infinite loop tag type
+ struct inf_type {};
+ const inf_type inf = inf_type();
+
+ struct repeat_gen
+ {
+ template<typename Subject>
+ kleene<typename extension::as_parser<Subject>::value_type>
+ operator[](Subject const& subject) const
+ {
+ return { as_parser(subject) };
+ }
+
+ template <typename T>
+ struct repeat_gen_lvl1
+ {
+ repeat_gen_lvl1(T&& repeat_limit_)
+ : repeat_limit(repeat_limit_)
+ {}
+
+ template<typename Subject>
+ repeat_directive< typename extension::as_parser<Subject>::value_type, T>
+ operator[](Subject const& subject) const
+ {
+ return { as_parser(subject),repeat_limit };
+ }
+
+ T repeat_limit;
+ };
+
+ template <typename T>
+ repeat_gen_lvl1<detail::exact_count<T>>
+ operator()(T const exact) const
+ {
+ return { detail::exact_count<T>{exact} };
+ }
+
+ template <typename T>
+ repeat_gen_lvl1<detail::finite_count<T>>
+ operator()(T const min_val, T const max_val) const
+ {
+ return { detail::finite_count<T>{min_val,max_val} };
+ }
+
+ template <typename T>
+ repeat_gen_lvl1<detail::infinite_count<T>>
+ operator()(T const min_val, inf_type const &) const
+ {
+ return { detail::infinite_count<T>{min_val} };
+ }
+ };
+
+ auto const repeat = repeat_gen{};
+}}}
+
+namespace boost { namespace spirit { namespace x3 { namespace traits
+{
+ template <typename Subject, typename RepeatCountLimit, typename Context>
+ struct attribute_of<x3::repeat_directive<Subject,RepeatCountLimit>, Context>
+ : build_container<typename attribute_of<Subject, Context>::type> {};
+}}}}
+
+
+#endif
diff --git a/boost/spirit/home/x3/extensions/seek.hpp b/boost/spirit/home/x3/directive/seek.hpp
index bcd9544794..e56a37b5c3 100644
--- a/boost/spirit/home/x3/extensions/seek.hpp
+++ b/boost/spirit/home/x3/directive/seek.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM)
#define BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
namespace boost { namespace spirit { namespace x3
@@ -60,11 +56,11 @@ namespace boost { namespace spirit { namespace x3
seek_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- seek_gen const seek = seek_gen();
+ auto const seek = seek_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/skip.hpp b/boost/spirit/home/x3/directive/skip.hpp
index c880720791..8d8bc78aca 100644
--- a/boost/spirit/home/x3/directive/skip.hpp
+++ b/boost/spirit/home/x3/directive/skip.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_SKIP_JANUARY_26_2008_0422PM)
#define SPIRIT_SKIP_JANUARY_26_2008_0422PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/core/skip_over.hpp>
@@ -91,34 +87,34 @@ namespace boost { namespace spirit { namespace x3
template <typename Skipper>
struct skip_gen
{
- explicit skip_gen(Skipper const& skipper)
+ skip_gen(Skipper const& skipper)
: skipper_(skipper) {}
template <typename Subject>
skip_directive<typename extension::as_parser<Subject>::value_type, Skipper>
operator[](Subject const& subject) const
{
- return {as_parser(subject), skipper_};
+ return { as_parser(subject), skipper_ };
}
Skipper skipper_;
};
-
+
template <typename Skipper>
skip_gen<Skipper> const operator()(Skipper const& skipper) const
{
- return skip_gen<Skipper>(skipper);
+ return { skipper };
}
template <typename Subject>
reskip_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
};
- reskip_gen const skip = reskip_gen();
+ auto const skip = reskip_gen{};
}}}
#endif
diff --git a/boost/spirit/home/x3/directive/with.hpp b/boost/spirit/home/x3/directive/with.hpp
index cc6c442a34..359f5adf1c 100644
--- a/boost/spirit/home/x3/directive/with.hpp
+++ b/boost/spirit/home/x3/directive/with.hpp
@@ -87,20 +87,20 @@ namespace boost { namespace spirit { namespace x3
with_directive<typename extension::as_parser<Subject>::value_type, ID, T>
operator[](Subject const& subject) const
{
- return {as_parser(subject), val};
+ return { as_parser(subject), val };
}
};
template <typename ID, typename T>
inline with_gen<ID, T> with(T& val)
{
- return with_gen<ID, T>{val};
+ return { val };
}
template <typename ID, typename T>
inline with_gen<ID, T const> with(T const& val)
{
- return with_gen<ID, T const>{val};
+ return { val };
}
}}}
diff --git a/boost/spirit/home/x3/extensions.hpp b/boost/spirit/home/x3/extensions.hpp
deleted file mode 100644
index a40b719c35..0000000000
--- a/boost/spirit/home/x3/extensions.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*=============================================================================
- Copyright (c) 2001-2014 Joel de Guzman
- Copyright (c) 2014 Thomas Bernard
- Copyright (c) 2014 Lee Clagett
-
- 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_EXTENSIONS_APRIL_6_2014_1421PM)
-#define BOOST_SPIRIT_X3_EXTENSIONS_APRIL_6_2014_1421PM
-
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-#include <boost/spirit/home/x3/extensions/seek.hpp>
-
-#endif
diff --git a/boost/spirit/home/x3/nonterminal.hpp b/boost/spirit/home/x3/nonterminal.hpp
index 1e589bd903..b26fda8680 100644
--- a/boost/spirit/home/x3/nonterminal.hpp
+++ b/boost/spirit/home/x3/nonterminal.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_NONTERMINAL_FEBRUARY_12_2007_1018AM)
#define BOOST_SPIRIT_X3_NONTERMINAL_FEBRUARY_12_2007_1018AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/nonterminal/rule.hpp>
//~ #include <boost/spirit/home/x3/nonterminal/error_handler.hpp>
//~ #include <boost/spirit/home/x3/nonterminal/debug_handler.hpp>
diff --git a/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp b/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp
index 800023f013..9ece9b7a74 100644
--- a/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp
+++ b/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_DEBUG_HANDLER_STATE_APR_21_2010_0733PM)
#define BOOST_SPIRIT_X3_DEBUG_HANDLER_STATE_APR_21_2010_0733PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
namespace boost { namespace spirit { namespace x3
{
enum debug_handler_state
diff --git a/boost/spirit/home/x3/nonterminal/detail/rule.hpp b/boost/spirit/home/x3/nonterminal/detail/rule.hpp
index 54e2eef234..71dc4c549f 100644
--- a/boost/spirit/home/x3/nonterminal/detail/rule.hpp
+++ b/boost/spirit/home/x3/nonterminal/detail/rule.hpp
@@ -7,11 +7,10 @@
#if !defined(BOOST_SPIRIT_X3_DETAIL_RULE_JAN_08_2012_0326PM)
#define BOOST_SPIRIT_X3_DETAIL_RULE_JAN_08_2012_0326PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
+#include <boost/spirit/home/x3/auxiliary/guard.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
+#include <boost/spirit/home/x3/core/skip_over.hpp>
+#include <boost/spirit/home/x3/directive/expect.hpp>
#include <boost/spirit/home/x3/support/traits/make_attribute.hpp>
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
#include <boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp>
@@ -25,8 +24,8 @@ namespace boost { namespace spirit { namespace x3
{
template <typename ID>
struct identity;
-
- template <typename ID, typename Attribute = unused_type>
+
+ template <typename ID, typename Attribute = unused_type, bool force_attribute = false>
struct rule;
struct parse_pass_context_tag;
@@ -43,7 +42,7 @@ namespace boost { namespace spirit { namespace x3
bool r;
};
}
-
+
// default parse_rule implementation
template <typename ID, typename Attribute, typename Iterator
, typename Context, typename ActualAttribute>
@@ -88,7 +87,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
detail::simple_trace_type& f;
};
#endif
-
+
template <typename ID, typename Iterator, typename Context, typename Enable = void>
struct has_on_error : mpl::false_ {};
@@ -106,7 +105,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
>
: mpl::true_
{};
-
+
template <typename ID, typename Iterator, typename Attribute, typename Context, typename Enable = void>
struct has_on_success : mpl::false_ {};
@@ -136,7 +135,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
{
typedef identity<ID> type;
};
-
+
template <typename ID, typename RHS, typename Context>
Context const&
make_rule_context(RHS const& rhs, Context const& context
@@ -144,7 +143,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
{
return context;
}
-
+
template <typename ID, typename RHS, typename Context>
auto make_rule_context(RHS const& rhs, Context const& context
, mpl::true_ /* is_default_parse_rule */ )
@@ -163,7 +162,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
{
return true;
}
-
+
template <typename Iterator, typename Context, typename ActualAttribute>
static bool call_on_success(
Iterator& first, Iterator const& last
@@ -179,7 +178,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
);
return pass;
}
-
+
template <typename RHS, typename Iterator, typename Context
, typename RContext, typename ActualAttribute>
static bool parse_rhs_main(
@@ -219,7 +218,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
r = call_on_success(first_, i, context, attr
, has_on_success<ID, Iterator, Context, ActualAttribute>());
}
-
+
if (r)
first = i;
return r;
@@ -331,7 +330,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
#endif
ok_parse=parse_rhs(rhs, first, last, context, attr_, attr_
, mpl::bool_
- < ( RHS::has_action
+ < ( RHS::has_action
&& !ExplicitAttrPropagation::value
)
>()
@@ -345,40 +344,6 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
}
return ok_parse;
}
-
-// template <typename RuleDef, typename Iterator, typename Context
-// , typename ActualAttribute, typename AttributeContext>
-// static bool call_from_rule(
-// RuleDef const& rule_def
-// , char const* rule_name
-// , Iterator& first, Iterator const& last
-// , Context const& context, ActualAttribute& attr, AttributeContext& attr_ctx)
-// {
-// // This is called when a rule-body has already been established.
-// // The rule body is already established by the rule_definition class,
-// // we will not do it again. We'll simply call the RHS by calling
-// // call_rule_definition.
-//
-// return call_rule_definition(
-// rule_def.rhs, rule_name, first, last
-// , context, attr, attr_ctx.attr_ptr
-// , mpl::bool_<(RuleDef::explicit_attribute_propagation)>());
-// }
-//
-// template <typename RuleDef, typename Iterator, typename Context
-// , typename ActualAttribute>
-// static bool call_from_rule(
-// RuleDef const& rule_def
-// , char const* rule_name
-// , Iterator& first, Iterator const& last
-// , Context const& context, ActualAttribute& attr, unused_type)
-// {
-// // This is called when a rule-body has *not yet* been established.
-// // The rule body is established by the rule_definition class, so
-// // we call it to parse and establish the rule-body.
-//
-// return rule_def.parse(first, last, context, unused, attr); // $$$ fix unused param $$$
-// }
};
}}}}
diff --git a/boost/spirit/home/x3/nonterminal/rule.hpp b/boost/spirit/home/x3/nonterminal/rule.hpp
index 049c6be57b..56075f34d7 100644
--- a/boost/spirit/home/x3/nonterminal/rule.hpp
+++ b/boost/spirit/home/x3/nonterminal/rule.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_RULE_JAN_08_2012_0326PM)
#define BOOST_SPIRIT_X3_RULE_JAN_08_2012_0326PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/nonterminal/detail/rule.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/spirit/home/x3/support/context.hpp>
@@ -26,7 +22,7 @@ namespace boost { namespace spirit { namespace x3
{
template <typename ID>
struct identity {};
-
+
// default parse_rule implementation
template <typename ID, typename Attribute, typename Iterator
, typename Context, typename ActualAttribute>
@@ -57,7 +53,7 @@ namespace boost { namespace spirit { namespace x3
static bool const force_attribute =
force_attribute_;
- rule_definition(RHS rhs, char const* name)
+ rule_definition(RHS const& rhs, char const* name)
: rhs(rhs), name(name) {}
template <typename Iterator, typename Context, typename Attribute_>
@@ -76,7 +72,7 @@ namespace boost { namespace spirit { namespace x3
char const* name;
};
- template <typename ID, typename Attribute>
+ template <typename ID, typename Attribute, bool force_attribute_>
struct rule : parser<rule<ID, Attribute>>
{
typedef ID id;
@@ -85,6 +81,7 @@ namespace boost { namespace spirit { namespace x3
!is_same<Attribute, unused_type>::value;
static bool const handles_container =
traits::is_container<Attribute>::value;
+ static bool const force_attribute = force_attribute_;
#if !defined(BOOST_SPIRIT_X3_NO_RTTI)
rule() : name(typeid(rule).name()) {}
@@ -97,10 +94,10 @@ namespace boost { namespace spirit { namespace x3
template <typename RHS>
rule_definition<
- ID, typename extension::as_parser<RHS>::value_type, Attribute, false>
+ ID, typename extension::as_parser<RHS>::value_type, Attribute, force_attribute_>
operator=(RHS const& rhs) const
{
- return {as_parser(rhs), name};
+ return { as_parser(rhs), name };
}
template <typename RHS>
@@ -108,7 +105,7 @@ namespace boost { namespace spirit { namespace x3
ID, typename extension::as_parser<RHS>::value_type, Attribute, true>
operator%=(RHS const& rhs) const
{
- return {as_parser(rhs), name};
+ return { as_parser(rhs), name };
}
@@ -121,15 +118,15 @@ namespace boost { namespace spirit { namespace x3
char const* name;
};
-
+
namespace traits
{
template <typename T, typename Enable = void>
struct is_rule : mpl::false_ {};
-
+
template <typename ID, typename Attribute>
struct is_rule<rule<ID, Attribute>> : mpl::true_ {};
-
+
template <typename ID, typename Attribute, typename RHS, bool force_attribute>
struct is_rule<rule_definition<ID, RHS, Attribute, force_attribute>> : mpl::true_ {};
}
@@ -143,7 +140,7 @@ namespace boost { namespace spirit { namespace x3
return r.name;
}
};
-
+
#define BOOST_SPIRIT_DECLARE_(r, data, rule_type) \
template <typename Iterator, typename Context, typename Attribute> \
bool parse_rule( \
@@ -155,16 +152,16 @@ namespace boost { namespace spirit { namespace x3
#define BOOST_SPIRIT_DECLARE(...) BOOST_PP_SEQ_FOR_EACH( \
BOOST_SPIRIT_DECLARE_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
/***/
-
-#define BOOST_SPIRIT_DEFINE_(r, data, def) \
+
+#define BOOST_SPIRIT_DEFINE_(r, data, rule_name) \
template <typename Iterator, typename Context, typename Attribute> \
inline bool parse_rule( \
- decltype(def)::lhs_type rule_ \
+ decltype(rule_name) rule_ \
, Iterator& first, Iterator const& last \
, Context const& context, Attribute& attr) \
{ \
using boost::spirit::x3::unused; \
- auto const& def_ = (def); \
+ static auto const def_ = (rule_name = BOOST_PP_CAT(rule_name, _def)); \
return def_.parse(first, last, context, unused, attr); \
} \
/***/
@@ -180,7 +177,7 @@ namespace boost { namespace spirit { namespace x3
, Context const& context, rule_type::attribute_type& attr); \
/***/
-
+
}}}
#endif
diff --git a/boost/spirit/home/x3/nonterminal/simple_trace.hpp b/boost/spirit/home/x3/nonterminal/simple_trace.hpp
index b049b4ec3c..dd369c811b 100644
--- a/boost/spirit/home/x3/nonterminal/simple_trace.hpp
+++ b/boost/spirit/home/x3/nonterminal/simple_trace.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_SIMPLE_TRACE_DECEMBER_06_2008_1102AM)
#define BOOST_SPIRIT_X3_SIMPLE_TRACE_DECEMBER_06_2008_1102AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/support/traits/print_token.hpp>
#include <boost/spirit/home/x3/support/traits/print_attribute.hpp>
diff --git a/boost/spirit/home/x3/numeric.hpp b/boost/spirit/home/x3/numeric.hpp
index c44d668569..ae4d9caa26 100644
--- a/boost/spirit/home/x3/numeric.hpp
+++ b/boost/spirit/home/x3/numeric.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_NUMERIC_FEBRUARY_05_2007_1231PM)
#define BOOST_SPIRIT_X3_NUMERIC_FEBRUARY_05_2007_1231PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/numeric/bool.hpp>
#include <boost/spirit/home/x3/numeric/int.hpp>
#include <boost/spirit/home/x3/numeric/uint.hpp>
diff --git a/boost/spirit/home/x3/numeric/bool.hpp b/boost/spirit/home/x3/numeric/bool.hpp
index 1fb21c16fe..1fd7018b0f 100644
--- a/boost/spirit/home/x3/numeric/bool.hpp
+++ b/boost/spirit/home/x3/numeric/bool.hpp
@@ -14,9 +14,10 @@
namespace boost { namespace spirit { namespace x3
{
- template <typename T, typename BoolPolicies = bool_policies<T>>
- struct bool_parser : parser<bool_parser<T, BoolPolicies>>
+ template <typename T, typename Encoding, typename BoolPolicies = bool_policies<T>>
+ struct bool_parser : parser<bool_parser<T, Encoding, BoolPolicies>>
{
+ typedef Encoding encoding;
typedef T attribute_type;
static bool const has_attribute = true;
@@ -28,16 +29,16 @@ namespace boost { namespace spirit { namespace x3
template <typename Iterator, typename Context>
bool parse(Iterator& first, Iterator const& last
- , Context& context, unused_type, T& attr) const
+ , Context const& context, unused_type, T& attr) const
{
x3::skip_over(first, last, context);
- return policies.parse_true(first, last, attr)
- || policies.parse_false(first, last, attr);
+ return policies.parse_true(first, last, attr, get_case_compare<encoding>(context))
+ || policies.parse_false(first, last, attr, get_case_compare<encoding>(context));
}
template <typename Iterator, typename Context, typename Attribute>
bool parse(Iterator& first, Iterator const& last
- , Context& context, unused_type, Attribute& attr_param) const
+ , Context const& context, unused_type, Attribute& attr_param) const
{
// this case is called when Attribute is not T
T attr_;
@@ -52,9 +53,10 @@ namespace boost { namespace spirit { namespace x3
BoolPolicies policies;
};
- template <typename T, typename BoolPolicies = bool_policies<T>>
- struct literal_bool_parser : parser<bool_parser<T, BoolPolicies>>
+ template <typename T, typename Encoding, typename BoolPolicies = bool_policies<T>>
+ struct literal_bool_parser : parser<bool_parser<T, Encoding, BoolPolicies>>
{
+ typedef Encoding encoding;
typedef T attribute_type;
static bool const has_attribute = true;
@@ -67,21 +69,28 @@ namespace boost { namespace spirit { namespace x3
: policies(policies), n_(n) {}
template <typename Iterator, typename Context>
+ bool parse_main(Iterator& first, Iterator const& last
+ , Context& context, T& attr) const
+ {
+ x3::skip_over(first, last, context);
+ return (n_ && policies.parse_true(first, last, attr, get_case_compare<encoding>(context)))
+ || (!n_ && policies.parse_false(first, last, attr, get_case_compare<encoding>(context)));
+ }
+
+ template <typename Iterator, typename Context>
bool parse(Iterator& first, Iterator const& last
, Context& context, unused_type, T& attr) const
{
- x3::skip_over(first, last, context);
- return (n_ && policies.parse_true(first, last, attr))
- || (!n_ && policies.parse_false(first, last, attr));
+ return parse_main(first, last, context, attr);
}
template <typename Iterator, typename Context, typename Attribute>
bool parse(Iterator& first, Iterator const& last
- , Context& context, unused_type, Attribute& attr_param) const
+ , Context const& context, unused_type, Attribute& attr_param) const
{
// this case is called when Attribute is not T
T attr_;
- if (parse(first, last, context, unused, attr_))
+ if (parse_main(first, last, context, attr_))
{
traits::move_to(attr_, attr_param);
return true;
@@ -93,14 +102,58 @@ namespace boost { namespace spirit { namespace x3
T n_;
};
- typedef bool_parser<bool> bool_type;
- bool_type const bool_ = {};
+ namespace standard
+ {
+ typedef bool_parser<bool, char_encoding::standard> bool_type;
+ bool_type const bool_ = {};
+
+ typedef literal_bool_parser<bool, char_encoding::standard> true_type;
+ true_type const true_ = { true };
+
+ typedef literal_bool_parser<bool, char_encoding::standard> false_type;
+ false_type const false_ = { false };
+ }
+
+ namespace standard_wide
+ {
+ typedef bool_parser<bool, char_encoding::standard_wide> bool_type;
+ bool_type const bool_ = {};
+
+ typedef literal_bool_parser<bool, char_encoding::standard_wide> true_type;
+ true_type const true_ = { true };
+
+ typedef literal_bool_parser<bool, char_encoding::standard_wide> false_type;
+ false_type const false_ = { false };
+ }
+
+ namespace ascii
+ {
+ typedef bool_parser<bool, char_encoding::ascii> bool_type;
+ bool_type const bool_ = {};
+
+ typedef literal_bool_parser<bool, char_encoding::ascii> true_type;
+ true_type const true_ = { true };
+
+ typedef literal_bool_parser<bool, char_encoding::ascii> false_type;
+ false_type const false_ = { false };
+ }
+
+ namespace iso8859_1
+ {
+ typedef bool_parser<bool, char_encoding::iso8859_1> bool_type;
+ bool_type const bool_ = {};
+
+ typedef literal_bool_parser<bool, char_encoding::iso8859_1> true_type;
+ true_type const true_ = { true };
+
+ typedef literal_bool_parser<bool, char_encoding::iso8859_1> false_type;
+ false_type const false_ = { false };
+ }
- typedef literal_bool_parser<bool> true_type;
- true_type const true_ = { true };
+ using standard::bool_;
+ using standard::true_;
+ using standard::false_;
- typedef literal_bool_parser<bool> false_type;
- false_type const false_ = { false };
-}}}
+ }}}
#endif
diff --git a/boost/spirit/home/x3/numeric/bool_policies.hpp b/boost/spirit/home/x3/numeric/bool_policies.hpp
index bafc5b5294..7e5227e2a1 100644
--- a/boost/spirit/home/x3/numeric/bool_policies.hpp
+++ b/boost/spirit/home/x3/numeric/bool_policies.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM)
#define SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/string/detail/string_parse.hpp>
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
@@ -23,11 +19,11 @@ namespace boost { namespace spirit { namespace x3
template <typename T = bool>
struct bool_policies
{
- template <typename Iterator, typename Attribute>
+ template <typename Iterator, typename Attribute, typename CaseCompare>
static bool
- parse_true(Iterator& first, Iterator const& last, Attribute& attr_)
+ parse_true(Iterator& first, Iterator const& last, Attribute& attr_, CaseCompare const& case_compare)
{
- if (detail::string_parse("true", first, last, unused))
+ if (detail::string_parse("true", first, last, unused, case_compare))
{
traits::move_to(T(true), attr_); // result is true
return true;
@@ -35,11 +31,11 @@ namespace boost { namespace spirit { namespace x3
return false;
}
- template <typename Iterator, typename Attribute>
+ template <typename Iterator, typename Attribute, typename CaseCompare>
static bool
- parse_false(Iterator& first, Iterator const& last, Attribute& attr_)
+ parse_false(Iterator& first, Iterator const& last, Attribute& attr_, CaseCompare const& case_compare)
{
- if (detail::string_parse("false", first, last, unused))
+ if (detail::string_parse("false", first, last, unused, case_compare))
{
traits::move_to(T(false), attr_); // result is false
return true;
diff --git a/boost/spirit/home/x3/numeric/int.hpp b/boost/spirit/home/x3/numeric/int.hpp
index ba9ceb8243..2c1832686e 100644
--- a/boost/spirit/home/x3/numeric/int.hpp
+++ b/boost/spirit/home/x3/numeric/int.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_INT_APR_17_2006_0830AM)
#define BOOST_SPIRIT_X3_INT_APR_17_2006_0830AM
-#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/numeric_utils/extract_int.hpp>
diff --git a/boost/spirit/home/x3/numeric/real_policies.hpp b/boost/spirit/home/x3/numeric/real_policies.hpp
index 4e02b266c5..b8fb38c387 100644
--- a/boost/spirit/home/x3/numeric/real_policies.hpp
+++ b/boost/spirit/home/x3/numeric/real_policies.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_REAL_POLICIES_APRIL_17_2006_1158PM)
#define SPIRIT_REAL_POLICIES_APRIL_17_2006_1158PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/string/detail/string_parse.hpp>
#include <boost/spirit/home/x3/support/numeric_utils/extract_int.hpp>
diff --git a/boost/spirit/home/x3/numeric/uint.hpp b/boost/spirit/home/x3/numeric/uint.hpp
index 624bae52de..172c108705 100644
--- a/boost/spirit/home/x3/numeric/uint.hpp
+++ b/boost/spirit/home/x3/numeric/uint.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_UINT_APR_17_2006_0901AM)
#define BOOST_SPIRIT_X3_UINT_APR_17_2006_0901AM
-#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/numeric_utils/extract_int.hpp>
diff --git a/boost/spirit/home/x3/operator.hpp b/boost/spirit/home/x3/operator.hpp
index 1244e2f04d..c67f18c4cc 100644
--- a/boost/spirit/home/x3/operator.hpp
+++ b/boost/spirit/home/x3/operator.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_OPERATOR_FEBRUARY_02_2007_0558PM)
#define BOOST_SPIRIT_X3_OPERATOR_FEBRUARY_02_2007_0558PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/operator/sequence.hpp>
#include <boost/spirit/home/x3/operator/alternative.hpp>
//~ #include <boost/spirit/home/x3/operator/sequential_or.hpp>
diff --git a/boost/spirit/home/x3/operator/alternative.hpp b/boost/spirit/home/x3/operator/alternative.hpp
index 1566780bc6..c3a1e40f3f 100644
--- a/boost/spirit/home/x3/operator/alternative.hpp
+++ b/boost/spirit/home/x3/operator/alternative.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_ALTERNATIVE_JAN_07_2013_1131AM)
#define SPIRIT_ALTERNATIVE_JAN_07_2013_1131AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/operator/detail/alternative.hpp>
@@ -22,7 +18,7 @@ namespace boost { namespace spirit { namespace x3
{
typedef binary_parser<Left, Right, alternative<Left, Right>> base_type;
- alternative(Left left, Right right)
+ alternative(Left const& left, Right const& right)
: base_type(left, right) {}
template <typename Iterator, typename Context, typename RContext>
@@ -40,11 +36,8 @@ namespace boost { namespace spirit { namespace x3
Iterator& first, Iterator const& last
, Context const& context, RContext& rcontext, Attribute& attr) const
{
- if (detail::parse_alternative(this->left, first, last, context, rcontext, attr))
- return true;
- if (detail::parse_alternative(this->right, first, last, context, rcontext, attr))
- return true;
- return false;
+ return detail::parse_alternative(this->left, first, last, context, rcontext, attr)
+ || detail::parse_alternative(this->right, first, last, context, rcontext, attr);
}
};
@@ -54,7 +47,7 @@ namespace boost { namespace spirit { namespace x3
, typename extension::as_parser<Right>::value_type>
operator|(Left const& left, Right const& right)
{
- return {as_parser(left), as_parser(right)};
+ return { as_parser(left), as_parser(right) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/and_predicate.hpp b/boost/spirit/home/x3/operator/and_predicate.hpp
index e0892cd8cf..1d650f7521 100644
--- a/boost/spirit/home/x3/operator/and_predicate.hpp
+++ b/boost/spirit/home/x3/operator/and_predicate.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM)
#define SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
namespace boost { namespace spirit { namespace x3
@@ -40,7 +36,7 @@ namespace boost { namespace spirit { namespace x3
inline and_predicate<typename extension::as_parser<Subject>::value_type>
operator&(Subject const& subject)
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/detail/alternative.hpp b/boost/spirit/home/x3/operator/detail/alternative.hpp
index 54f86e00df..9fbc4f4dc4 100644
--- a/boost/spirit/home/x3/operator/detail/alternative.hpp
+++ b/boost/spirit/home/x3/operator/detail/alternative.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_ALTERNATIVE_DETAIL_JAN_07_2013_1245PM)
#define SPIRIT_ALTERNATIVE_DETAIL_JAN_07_2013_1245PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/support/traits/is_variant.hpp>
#include <boost/spirit/home/x3/support/traits/tuple_traits.hpp>
@@ -23,9 +19,9 @@
#include <boost/mpl/copy_if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/vector.hpp>
-#include <boost/mpl/joint_view.hpp>
#include <boost/fusion/include/front.hpp>
@@ -182,34 +178,21 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
template <typename LL, typename LR, typename R, typename C>
struct get_alternative_types<alternative<LL, LR>, R, C>
- {
- typedef typename
- mpl::push_back<
- typename get_alternative_types<LL, LR, C>::type
- , typename traits::attribute_of<R, C>::type
- >::type
- type;
- };
+ : mpl::push_back< typename get_alternative_types<LL, LR, C>::type
+ , typename traits::attribute_of<R, C>::type> {};
template <typename L, typename RL, typename RR, typename C>
struct get_alternative_types<L, alternative<RL, RR>, C>
- {
- typedef typename
- mpl::push_front<
- typename get_alternative_types<RL, RR, C>::type
- , typename traits::attribute_of<L, C>::type
- >::type
- type;
- };
+ : mpl::push_front< typename get_alternative_types<RL, RR, C>::type
+ , typename traits::attribute_of<L, C>::type> {};
template <typename LL, typename LR, typename RL, typename RR, typename C>
struct get_alternative_types<alternative<LL, LR>, alternative<RL, RR>, C>
{
- typedef
- mpl::joint_view<
- typename get_alternative_types<LL, LR, C>::type
- , typename get_alternative_types<RL, RR, C>::type
- >
+ typedef typename get_alternative_types<LL, LR, C>::type left;
+ typedef typename get_alternative_types<RL, RR, C>::type right;
+ typedef typename
+ mpl::insert_range<left, typename mpl::end<left>::type, right>::type
type;
};
diff --git a/boost/spirit/home/x3/operator/detail/sequence.hpp b/boost/spirit/home/x3/operator/detail/sequence.hpp
index 1163707128..e54a8f6a9e 100644
--- a/boost/spirit/home/x3/operator/detail/sequence.hpp
+++ b/boost/spirit/home/x3/operator/detail/sequence.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_SEQUENCE_DETAIL_JAN_06_2013_1015AM)
#define SPIRIT_SEQUENCE_DETAIL_JAN_06_2013_1015AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
#include <boost/spirit/home/x3/support/traits/make_attribute.hpp>
@@ -31,9 +27,9 @@
#include <boost/mpl/copy_if.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/mpl/insert_range.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/vector.hpp>
-#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/add_reference.hpp>
@@ -247,34 +243,21 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
template <typename LL, typename LR, typename R, typename C>
struct get_sequence_types<sequence<LL, LR>, R, C>
- {
- typedef typename
- mpl::push_back<
- typename get_sequence_types<LL, LR, C>::type
- , typename traits::attribute_of<R, C>::type
- >::type
- type;
- };
+ : mpl::push_back< typename get_sequence_types<LL, LR, C>::type
+ , typename traits::attribute_of<R, C>::type> {};
template <typename L, typename RL, typename RR, typename C>
struct get_sequence_types<L, sequence<RL, RR>, C>
- {
- typedef typename
- mpl::push_front<
- typename get_sequence_types<RL, RR, C>::type
- , typename traits::attribute_of<L, C>::type
- >::type
- type;
- };
+ : mpl::push_front< typename get_sequence_types<RL, RR, C>::type
+ , typename traits::attribute_of<L, C>::type> {};
template <typename LL, typename LR, typename RL, typename RR, typename C>
struct get_sequence_types<sequence<LL, LR>, sequence<RL, RR>, C>
{
- typedef
- mpl::joint_view<
- typename get_sequence_types<LL, LR, C>::type
- , typename get_sequence_types<RL, RR, C>::type
- >
+ typedef typename get_sequence_types<LL, LR, C>::type left;
+ typedef typename get_sequence_types<RL, RR, C>::type right;
+ typedef typename
+ mpl::insert_range<left, typename mpl::end<left>::type, right>::type
type;
};
@@ -334,10 +317,9 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
template <typename Parser, typename Iterator, typename Context
, typename RContext, typename Attribute>
- bool parse_sequence(
- Parser const& parser , Iterator& first, Iterator const& last
- , Context const& context, RContext& rcontext, Attribute& attr
- , traits::plain_attribute)
+ bool parse_sequence_plain(
+ Parser const& parser, Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr)
{
typedef typename Parser::left_type Left;
typedef typename Parser::right_type Right;
@@ -357,6 +339,26 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
return false;
}
+ template <typename Parser, typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse_sequence(
+ Parser const& parser, Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr
+ , traits::plain_attribute)
+ {
+ return parse_sequence_plain(parser, first, last, context, rcontext, attr);
+ }
+
+ template <typename Parser, typename Iterator, typename Context
+ , typename RContext, typename Attribute>
+ bool parse_sequence(
+ Parser const& parser, Iterator& first, Iterator const& last
+ , Context const& context, RContext& rcontext, Attribute& attr
+ , traits::variant_attribute)
+ {
+ return parse_sequence_plain(parser, first, last, context, rcontext, attr);
+ }
+
template <typename Left, typename Right, typename Iterator
, typename Context, typename RContext, typename Attribute>
bool parse_sequence(
diff --git a/boost/spirit/home/x3/operator/difference.hpp b/boost/spirit/home/x3/operator/difference.hpp
index 13a9274de0..a75e713821 100644
--- a/boost/spirit/home/x3/operator/difference.hpp
+++ b/boost/spirit/home/x3/operator/difference.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_DIFFERENCE_FEBRUARY_11_2007_1250PM)
#define SPIRIT_DIFFERENCE_FEBRUARY_11_2007_1250PM
-#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/core/parser.hpp>
@@ -47,7 +43,7 @@ namespace boost { namespace spirit { namespace x3
difference<Left_, Right_>
make(Left_ const& left, Right_ const& right) const
{
- return difference<Left_, Right_>(left, right);
+ return { left, right };
}
};
@@ -57,7 +53,7 @@ namespace boost { namespace spirit { namespace x3
, typename extension::as_parser<Right>::value_type>
operator-(Left const& left, Right const& right)
{
- return {as_parser(left), as_parser(right)};
+ return { as_parser(left), as_parser(right) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/kleene.hpp b/boost/spirit/home/x3/operator/kleene.hpp
index 7e02bf4a02..b0fb5a1df1 100644
--- a/boost/spirit/home/x3/operator/kleene.hpp
+++ b/boost/spirit/home/x3/operator/kleene.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_KLEENE_JANUARY_07_2007_0818AM)
#define SPIRIT_KLEENE_JANUARY_07_2007_0818AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
@@ -44,7 +40,7 @@ namespace boost { namespace spirit { namespace x3
inline kleene<typename extension::as_parser<Subject>::value_type>
operator*(Subject const& subject)
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/list.hpp b/boost/spirit/home/x3/operator/list.hpp
index a463a7f9e0..23b398b128 100644
--- a/boost/spirit/home/x3/operator/list.hpp
+++ b/boost/spirit/home/x3/operator/list.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_LIST_MARCH_24_2007_1031AM)
#define SPIRIT_LIST_MARCH_24_2007_1031AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
@@ -58,7 +54,7 @@ namespace boost { namespace spirit { namespace x3
, typename extension::as_parser<Right>::value_type>
operator%(Left const& left, Right const& right)
{
- return {as_parser(left), as_parser(right)};
+ return { as_parser(left), as_parser(right) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/not_predicate.hpp b/boost/spirit/home/x3/operator/not_predicate.hpp
index 38b24bd2e2..d0302e6142 100644
--- a/boost/spirit/home/x3/operator/not_predicate.hpp
+++ b/boost/spirit/home/x3/operator/not_predicate.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM)
#define SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
namespace boost { namespace spirit { namespace x3
@@ -40,7 +36,7 @@ namespace boost { namespace spirit { namespace x3
inline not_predicate<typename extension::as_parser<Subject>::value_type>
operator!(Subject const& subject)
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/optional.hpp b/boost/spirit/home/x3/operator/optional.hpp
index 16432f89d1..a40228849a 100644
--- a/boost/spirit/home/x3/operator/optional.hpp
+++ b/boost/spirit/home/x3/operator/optional.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_OPTIONAL_MARCH_23_2007_1117PM)
#define SPIRIT_OPTIONAL_MARCH_23_2007_1117PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/proxy.hpp>
#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
@@ -71,7 +67,7 @@ namespace boost { namespace spirit { namespace x3
inline optional<typename extension::as_parser<Subject>::value_type>
operator-(Subject const& subject)
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/plus.hpp b/boost/spirit/home/x3/operator/plus.hpp
index 32c7dbfffb..152731e622 100644
--- a/boost/spirit/home/x3/operator/plus.hpp
+++ b/boost/spirit/home/x3/operator/plus.hpp
@@ -8,10 +8,6 @@
#if !defined(SPIRIT_PLUS_MARCH_13_2007_0127PM)
#define SPIRIT_PLUS_MARCH_13_2007_0127PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
@@ -48,7 +44,7 @@ namespace boost { namespace spirit { namespace x3
inline plus<typename extension::as_parser<Subject>::value_type>
operator+(Subject const& subject)
{
- return {as_parser(subject)};
+ return { as_parser(subject) };
}
}}}
diff --git a/boost/spirit/home/x3/operator/sequence.hpp b/boost/spirit/home/x3/operator/sequence.hpp
index 23d5e3d8d9..661a23cd37 100644
--- a/boost/spirit/home/x3/operator/sequence.hpp
+++ b/boost/spirit/home/x3/operator/sequence.hpp
@@ -7,10 +7,6 @@
#if !defined(SPIRIT_SEQUENCE_JAN_06_2013_1015AM)
#define SPIRIT_SEQUENCE_JAN_06_2013_1015AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/operator/detail/sequence.hpp>
@@ -23,7 +19,7 @@ namespace boost { namespace spirit { namespace x3
{
typedef binary_parser<Left, Right, sequence<Left, Right>> base_type;
- sequence(Left left, Right right)
+ sequence(Left const& left, Right const& right)
: base_type(left, right) {}
template <typename Iterator, typename Context, typename RContext>
@@ -56,16 +52,13 @@ namespace boost { namespace spirit { namespace x3
, typename extension::as_parser<Right>::value_type>
operator>>(Left const& left, Right const& right)
{
- return {as_parser(left), as_parser(right)};
+ return { as_parser(left), as_parser(right) };
}
template <typename Left, typename Right>
- inline sequence<
- typename extension::as_parser<Left>::value_type
- , expect_directive<typename extension::as_parser<Right>::value_type>>
- operator>(Left const& left, Right const& right)
+ auto operator>(Left const& left, Right const& right)
{
- return {as_parser(left), as_parser(right)};
+ return left >> expect[right];
}
}}}
diff --git a/boost/spirit/home/x3/string.hpp b/boost/spirit/home/x3/string.hpp
index e0f5c6ebac..425e731134 100644
--- a/boost/spirit/home/x3/string.hpp
+++ b/boost/spirit/home/x3/string.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_STRING_FEBRUARY_03_2007_0355PM)
#define BOOST_SPIRIT_X3_STRING_FEBRUARY_03_2007_0355PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/string/literal_string.hpp>
#include <boost/spirit/home/x3/string/symbols.hpp>
diff --git a/boost/spirit/home/x3/string/detail/no_case_string_parse.hpp b/boost/spirit/home/x3/string/detail/no_case_string_parse.hpp
new file mode 100644
index 0000000000..6e1bbf4cee
--- /dev/null
+++ b/boost/spirit/home/x3/string/detail/no_case_string_parse.hpp
@@ -0,0 +1,60 @@
+/*=============================================================================
+ 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_NO_CASE_STRING_PARSE_APR_18_2014_1125PM)
+#define BOOST_SPIRIT_X3_NO_CASE_STRING_PARSE_APR_18_2014_1125PM
+
+#include <boost/spirit/home/x3/char/char.hpp>
+#include <boost/spirit/home/x3/support/traits/move_to.hpp>
+
+namespace boost { namespace spirit { namespace x3 { namespace detail
+{
+ template <typename Char, typename Encoding>
+ struct no_case_string
+ {
+ typedef std::basic_string< Char > string_type;
+ typedef typename string_type::const_iterator const_iterator;
+
+ no_case_string(char_type const* str)
+ : lower(str)
+ , upper(str)
+ {
+ typename string_type::iterator loi = lower.begin();
+ typename string_type::iterator upi = upper.begin();
+
+ typedef typename Encoding::char_type encoded_char_type;
+ Encoding encoding;
+ for (; loi != lower.end(); ++loi, ++upi)
+ {
+ *loi = static_cast<char_type>(encoding.tolower(encoded_char_type(*loi)));
+ *upi = static_cast<char_type>(encoding.toupper(encoded_char_type(*upi)));
+ }
+ }
+ string_type lower;
+ string_type upper;
+
+ };
+
+ template <typename String, typename Iterator, typename Attribute>
+ inline bool no_case_string_parse(
+ String const& str
+ , Iterator& first, Iterator const& last, Attribute& attr)
+ {
+ typename String::const_iterator uc_i = str.upper.begin();
+ typename String::const_iterator uc_last = str.upper.end();
+ typename String::const_iterator lc_i = str.lower.begin();
+ Iterator i = first;
+
+ for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i)
+ if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
+ return false;
+ x3::traits::move_to(first, i, attr);
+ first = i;
+ return true;
+ }
+}}}}
+
+#endif
diff --git a/boost/spirit/home/x3/string/detail/string_parse.hpp b/boost/spirit/home/x3/string/detail/string_parse.hpp
index f7a77df804..dd7de67692 100644
--- a/boost/spirit/home/x3/string/detail/string_parse.hpp
+++ b/boost/spirit/home/x3/string/detail/string_parse.hpp
@@ -7,25 +7,21 @@
#if !defined(BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM)
#define BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
namespace boost { namespace spirit { namespace x3 { namespace detail
{
- template <typename Char, typename Iterator, typename Attribute>
+ template <typename Char, typename Iterator, typename Attribute, typename CaseCompareFunc>
inline bool string_parse(
Char const* str
- , Iterator& first, Iterator const& last, Attribute& attr)
+ , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
{
Iterator i = first;
Char ch = *str;
for (; !!ch; ++i)
{
- if (i == last || (ch != *i))
+ if (i == last || (compare(ch, *i) != 0))
return false;
ch = *++str;
}
@@ -35,17 +31,17 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
return true;
}
- template <typename String, typename Iterator, typename Attribute>
+ template <typename String, typename Iterator, typename Attribute, typename CaseCompareFunc>
inline bool string_parse(
String const& str
- , Iterator& first, Iterator const& last, Attribute& attr)
+ , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
{
Iterator i = first;
typename String::const_iterator stri = str.begin();
typename String::const_iterator str_last = str.end();
for (; stri != str_last; ++stri, ++i)
- if (i == last || (*stri != *i))
+ if (i == last || (compare(*stri, *i) != 0))
return false;
x3::traits::move_to(first, i, attr);
first = i;
diff --git a/boost/spirit/home/x3/string/detail/tst.hpp b/boost/spirit/home/x3/string/detail/tst.hpp
index df61f4dec7..50f6df6a95 100644
--- a/boost/spirit/home/x3/string/detail/tst.hpp
+++ b/boost/spirit/home/x3/string/detail/tst.hpp
@@ -7,13 +7,8 @@
#if !defined(BOOST_SPIRIT_X3_TST_MARCH_09_2007_0905AM)
#define BOOST_SPIRIT_X3_TST_MARCH_09_2007_0905AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/call_traits.hpp>
#include <boost/detail/iterator.hpp>
-#include <boost/foreach.hpp>
#include <boost/assert.hpp>
namespace boost { namespace spirit { namespace x3 { namespace detail
@@ -61,9 +56,9 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
return 0;
}
- template <typename Iterator, typename Filter>
+ template <typename Iterator, typename CaseCompare>
static T*
- find(tst_node* start, Iterator& first, Iterator last, Filter filter)
+ find(tst_node* start, Iterator& first, Iterator last, CaseCompare comp)
{
if (first == last)
return 0;
@@ -75,11 +70,8 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
while (p && i != last)
{
- typename
- boost::detail::iterator_traits<Iterator>::value_type
- c = filter(*i); // filter only the input
-
- if (c == p->id)
+ int32_t c = comp(*i,p->id);
+ if (c == 0)
{
if (p->data)
{
@@ -89,7 +81,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
p = p->eq;
i++;
}
- else if (c < p->id)
+ else if (c < 0)
{
p = p->lt;
}
@@ -117,7 +109,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
return 0;
tst_node** pp = &start;
- for(;;)
+ for (;;)
{
typename
boost::detail::iterator_traits<Iterator>::value_type
diff --git a/boost/spirit/home/x3/string/literal_string.hpp b/boost/spirit/home/x3/string/literal_string.hpp
index bf05a9a08e..c562721b2e 100644
--- a/boost/spirit/home/x3/string/literal_string.hpp
+++ b/boost/spirit/home/x3/string/literal_string.hpp
@@ -7,13 +7,11 @@
#if !defined(BOOST_SPIRIT_X3_LITERAL_STRING_APR_18_2006_1125PM)
#define BOOST_SPIRIT_X3_LITERAL_STRING_APR_18_2006_1125PM
-#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/string/detail/string_parse.hpp>
+#include <boost/spirit/home/x3/support/no_case.hpp>
+#include <boost/spirit/home/x3/string/detail/no_case_string_parse.hpp>
#include <boost/spirit/home/x3/support/utility/utf8.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
#include <boost/spirit/home/support/char_encoding/standard.hpp>
@@ -36,7 +34,7 @@ namespace boost { namespace spirit { namespace x3
!is_same<unused_type, attribute_type>::value;
static bool const handles_container = has_attribute;
- literal_string(typename add_reference<String>::type str)
+ literal_string(typename add_reference< typename add_const<String>::type >::type str)
: str(str)
{}
@@ -45,7 +43,7 @@ namespace boost { namespace spirit { namespace x3
, Context const& context, unused_type, Attribute_& attr) const
{
x3::skip_over(first, last, context);
- return detail::string_parse(str, first, last, attr);
+ return detail::string_parse(str, first, last, attr, get_case_compare<encoding>(context));
}
String str;
@@ -56,19 +54,124 @@ namespace boost { namespace spirit { namespace x3
inline literal_string<char const*, char_encoding::standard>
string(char const* s)
{
- return literal_string<char const*, char_encoding::standard>(s);
+ return { s };
+ }
+
+ inline literal_string<std::basic_string<char>, char_encoding::standard>
+ string(std::basic_string<char> const& s)
+ {
+ return { s };
+ }
+
+ inline literal_string<char const*, char_encoding::standard, unused_type>
+ lit(char const* s)
+ {
+ return { s };
+ }
+
+ template <typename Char>
+ literal_string<Char const*, char_encoding::standard, unused_type>
+ lit(std::basic_string<Char> const& s)
+ {
+ return { s.c_str() };
+ }
+ }
+
+ namespace standard_wide
+ {
+ inline literal_string<wchar_t const*, char_encoding::standard_wide>
+ string(wchar_t const* s)
+ {
+ return { s };
+ }
+
+ inline literal_string<std::basic_string<wchar_t>, char_encoding::standard_wide>
+ string(std::basic_string<wchar_t> const& s)
+ {
+ return { s };
+ }
+
+ inline literal_string<wchar_t const*, char_encoding::standard_wide, unused_type>
+ lit(wchar_t const* s)
+ {
+ return { s };
+ }
+
+ inline literal_string<wchar_t const*, char_encoding::standard_wide, unused_type>
+ lit(std::basic_string<wchar_t> const& s)
+ {
+ return { s.c_str() };
}
}
+
+ namespace ascii
+ {
+ inline literal_string<wchar_t const*, char_encoding::ascii>
+ string(wchar_t const* s)
+ {
+ return { s };
+ }
+
+ inline literal_string<std::basic_string<wchar_t>, char_encoding::ascii>
+ string(std::basic_string<wchar_t> const& s)
+ {
+ return { s };
+ }
+
+ inline literal_string<char const*, char_encoding::ascii, unused_type>
+ lit(char const* s)
+ {
+ return { s };
+ }
+
+ template <typename Char>
+ literal_string<Char const*, char_encoding::ascii, unused_type>
+ lit(std::basic_string<Char> const& s)
+ {
+ return { s.c_str() };
+ }
+ }
+
+ namespace iso8859_1
+ {
+ inline literal_string<wchar_t const*, char_encoding::iso8859_1>
+ string(wchar_t const* s)
+ {
+ return { s };
+ }
+
+ inline literal_string<std::basic_string<wchar_t>, char_encoding::iso8859_1>
+ string(std::basic_string<wchar_t> const& s)
+ {
+ return { s };
+ }
+
+ inline literal_string<char const*, char_encoding::iso8859_1, unused_type>
+ lit(char const* s)
+ {
+ return { s };
+ }
+
+ template <typename Char>
+ literal_string<Char const*, char_encoding::iso8859_1, unused_type>
+ lit(std::basic_string<Char> const& s)
+ {
+ return { s.c_str() };
+ }
+ }
+
using standard::string;
+ using standard::lit;
+ using standard_wide::string;
+ using standard_wide::lit;
namespace extension
{
template <int N>
struct as_parser<char[N]>
{
- typedef
- literal_string<
- char const*, char_encoding::standard, unused_type>
+ typedef literal_string<
+ char const*, char_encoding::standard, unused_type>
type;
typedef type value_type;
@@ -85,9 +188,8 @@ namespace boost { namespace spirit { namespace x3
template <int N>
struct as_parser<wchar_t[N]>
{
- typedef
- literal_string<
- wchar_t const*, char_encoding::standard_wide, unused_type>
+ typedef literal_string<
+ wchar_t const*, char_encoding::standard_wide, unused_type>
type;
typedef type value_type;
@@ -100,14 +202,36 @@ namespace boost { namespace spirit { namespace x3
template <int N>
struct as_parser<wchar_t const[N]> : as_parser<wchar_t[N]> {};
- }
- using standard::string;
+ template <>
+ struct as_parser<char const*>
+ {
+ typedef literal_string<
+ char const*, char_encoding::standard, unused_type>
+ type;
- inline literal_string<char const*, char_encoding::standard, unused_type>
- lit(char const* s)
- {
- return literal_string<char const*, char_encoding::standard, unused_type>(s);
+ typedef type value_type;
+
+ static type call(char const* s)
+ {
+ return type(s);
+ }
+ };
+
+ template <typename Char>
+ struct as_parser< std::basic_string<Char> >
+ {
+ typedef literal_string<
+ Char const*, char_encoding::standard, unused_type>
+ type;
+
+ typedef type value_type;
+
+ static type call(std::basic_string<Char> const& s)
+ {
+ return type(s.c_str());
+ }
+ };
}
template <typename String, typename Encoding, typename Attribute>
diff --git a/boost/spirit/home/x3/string/symbols.hpp b/boost/spirit/home/x3/string/symbols.hpp
index b35a00a121..2d00944be2 100644
--- a/boost/spirit/home/x3/string/symbols.hpp
+++ b/boost/spirit/home/x3/string/symbols.hpp
@@ -8,16 +8,18 @@
#if !defined(BOOST_SPIRIT_X3_SYMBOLS_MARCH_11_2007_1055AM)
#define BOOST_SPIRIT_X3_SYMBOLS_MARCH_11_2007_1055AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/core/skip_over.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/string/tst.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/support/traits/string_traits.hpp>
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
+#include <boost/spirit/home/x3/support/no_case.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>
#include <boost/fusion/include/at.hpp>
#include <boost/range.hpp>
@@ -35,15 +37,14 @@
namespace boost { namespace spirit { namespace x3
{
template <
- typename Char = char
+ typename Encoding
, typename T = unused_type
- , typename Lookup = tst<Char, T>
- , typename Filter = tst_pass_through>
- struct symbols : parser<symbols<Char, T, Lookup, Filter>>
+ , typename Lookup = tst<typename Encoding::char_type, T> >
+ struct symbols_parser : parser<symbols_parser<Encoding, T, Lookup>>
{
- typedef Char char_type; // the character type
+ typedef typename Encoding::char_type char_type; // the character type
+ typedef Encoding encoding;
typedef T value_type; // the value associated with each entry
- typedef symbols<Char, T, Lookup, Filter> this_type;
typedef value_type attribute_type;
static bool const has_attribute =
@@ -51,7 +52,7 @@ namespace boost { namespace spirit { namespace x3
static bool const handles_container =
traits::is_container<attribute_type>::value;
- symbols(std::string const& name = "symbols")
+ symbols_parser(std::string const& name = "symbols")
: add(*this)
, remove(*this)
, lookup(new Lookup())
@@ -59,16 +60,7 @@ namespace boost { namespace spirit { namespace x3
{
}
- symbols(symbols const& syms)
- : add(*this)
- , remove(*this)
- , lookup(syms.lookup)
- , name_(syms.name_)
- {
- }
-
- template <typename Filter_>
- symbols(symbols<Char, T, Lookup, Filter_> const& syms)
+ symbols_parser(symbols_parser const& syms)
: add(*this)
, remove(*this)
, lookup(syms.lookup)
@@ -77,7 +69,7 @@ namespace boost { namespace spirit { namespace x3
}
template <typename Symbols>
- symbols(Symbols const& syms, std::string const& name = "symbols")
+ symbols_parser(Symbols const& syms, std::string const& name = "symbols")
: add(*this)
, remove(*this)
, lookup(new Lookup())
@@ -89,7 +81,7 @@ namespace boost { namespace spirit { namespace x3
}
template <typename Symbols, typename Data>
- symbols(Symbols const& syms, Data const& data
+ symbols_parser(Symbols const& syms, Data const& data
, std::string const& name = "symbols")
: add(*this)
, remove(*this)
@@ -102,43 +94,34 @@ namespace boost { namespace spirit { namespace x3
add(*si++, *di++);
}
- symbols(std::initializer_list<std::pair<Char const*, T>> syms
+ symbols_parser(std::initializer_list<std::pair<char_type const*, T>> syms
, std::string const & name="symbols")
: add(*this)
, remove(*this)
, lookup(new Lookup())
, name_(name)
{
- typedef std::initializer_list<std::pair<Char const*, T>> symbols_t;
+ typedef std::initializer_list<std::pair<char_type const*, T>> symbols_t;
typename range_const_iterator<symbols_t>::type si = boost::begin(syms);
for (;si != boost::end(syms); ++si)
add(si->first, si->second);
}
-
- symbols(std::initializer_list<Char const*> syms
+
+ symbols_parser(std::initializer_list<char_type const*> syms
, std::string const &name="symbols")
: add(*this)
, remove(*this)
, lookup(new Lookup())
, name_(name)
{
- typedef std::initializer_list<Char const*> symbols_t;
+ typedef std::initializer_list<char_type const*> symbols_t;
typename range_const_iterator<symbols_t>::type si = boost::begin(syms);
while (si != boost::end(syms))
add(*si++);
}
- symbols&
- operator=(symbols const& rhs)
- {
- name_ = rhs.name_;
- lookup = rhs.lookup;
- return *this;
- }
-
- template <typename Filter_>
- symbols&
- operator=(symbols<Char, T, Lookup, Filter_> const& rhs)
+ symbols_parser&
+ operator=(symbols_parser const& rhs)
{
name_ = rhs.name_;
lookup = rhs.lookup;
@@ -163,14 +146,14 @@ namespace boost { namespace spirit { namespace x3
template <typename Str>
friend adder const&
- operator+=(symbols& sym, Str const& str)
+ operator+=(symbols_parser& sym, Str const& str)
{
return sym.add(str);
}
template <typename Str>
friend remover const&
- operator-=(symbols& sym, Str const& str)
+ operator-=(symbols_parser& sym, Str const& str)
{
return sym.remove(str);
}
@@ -184,48 +167,48 @@ namespace boost { namespace spirit { namespace x3
template <typename Str>
value_type& at(Str const& str)
{
- return *lookup->add(traits::get_string_begin<Char>(str)
- , traits::get_string_end<Char>(str), T());
+ return *lookup->add(traits::get_string_begin<char_type>(str)
+ , traits::get_string_end<char_type>(str), T());
}
template <typename Iterator>
value_type* prefix_find(Iterator& first, Iterator const& last)
{
- return lookup->find(first, last, Filter());
+ return lookup->find(first, last, case_compare<Encoding>());
}
template <typename Iterator>
value_type const* prefix_find(Iterator& first, Iterator const& last) const
{
- return lookup->find(first, last, Filter());
+ return lookup->find(first, last, case_compare<Encoding>());
}
template <typename Str>
value_type* find(Str const& str)
{
- return find_impl(traits::get_string_begin<Char>(str)
- , traits::get_string_end<Char>(str));
+ return find_impl(traits::get_string_begin<char_type>(str)
+ , traits::get_string_end<char_type>(str));
}
template <typename Str>
value_type const* find(Str const& str) const
{
- return find_impl(traits::get_string_begin<Char>(str)
- , traits::get_string_end<Char>(str));
+ return find_impl(traits::get_string_begin<char_type>(str)
+ , traits::get_string_end<char_type>(str));
}
private:
template <typename Iterator>
value_type* find_impl(Iterator begin, Iterator end)
{
- value_type* r = lookup->find(begin, end, Filter());
+ value_type* r = lookup->find(begin, end, case_compare<Encoding>());
return begin == end ? r : 0;
}
template <typename Iterator>
value_type const* find_impl(Iterator begin, Iterator end) const
{
- value_type const* r = lookup->find(begin, end, Filter());
+ value_type const* r = lookup->find(begin, end, case_compare<Encoding>());
return begin == end ? r : 0;
}
@@ -237,7 +220,7 @@ namespace boost { namespace spirit { namespace x3
x3::skip_over(first, last, context);
if (value_type* val_ptr
- = lookup->find(first, last, Filter()))
+ = lookup->find(first, last, get_case_compare<Encoding>(context)))
{
x3::traits::move_to(*val_ptr, attr);
return true;
@@ -259,7 +242,7 @@ namespace boost { namespace spirit { namespace x3
template <typename, typename = unused_type, typename = unused_type>
struct result { typedef adder const& type; };
- adder(symbols& sym)
+ adder(symbols_parser& sym)
: sym(sym)
{
}
@@ -276,8 +259,8 @@ namespace boost { namespace spirit { namespace x3
adder const&
operator()(Str const& s, T const& val = T()) const
{
- sym.lookup->add(traits::get_string_begin<Char>(s)
- , traits::get_string_end<Char>(s), val);
+ sym.lookup->add(traits::get_string_begin<char_type>(s)
+ , traits::get_string_end<char_type>(s), val);
return *this;
}
@@ -285,12 +268,12 @@ namespace boost { namespace spirit { namespace x3
adder const&
operator,(Str const& s) const
{
- sym.lookup->add(traits::get_string_begin<Char>(s)
- , traits::get_string_end<Char>(s), T());
+ sym.lookup->add(traits::get_string_begin<char_type>(s)
+ , traits::get_string_end<char_type>(s), T());
return *this;
}
- symbols& sym;
+ symbols_parser& sym;
};
struct remover
@@ -298,7 +281,7 @@ namespace boost { namespace spirit { namespace x3
template <typename, typename = unused_type, typename = unused_type>
struct result { typedef remover const& type; };
- remover(symbols& sym)
+ remover(symbols_parser& sym)
: sym(sym)
{
}
@@ -315,8 +298,8 @@ namespace boost { namespace spirit { namespace x3
remover const&
operator()(Str const& s) const
{
- sym.lookup->remove(traits::get_string_begin<Char>(s)
- , traits::get_string_end<Char>(s));
+ sym.lookup->remove(traits::get_string_begin<char_type>(s)
+ , traits::get_string_end<char_type>(s));
return *this;
}
@@ -324,12 +307,12 @@ namespace boost { namespace spirit { namespace x3
remover const&
operator,(Str const& s) const
{
- sym.lookup->remove(traits::get_string_begin<Char>(s)
- , traits::get_string_end<Char>(s));
+ sym.lookup->remove(traits::get_string_begin<char_type>(s)
+ , traits::get_string_end<char_type>(s));
return *this;
}
- symbols& sym;
+ symbols_parser& sym;
};
adder add;
@@ -338,17 +321,44 @@ namespace boost { namespace spirit { namespace x3
std::string name_;
};
- template <typename Char, typename T, typename Lookup, typename Filter>
- struct get_info<symbols<Char, T, Lookup, Filter>>
+ template <typename Encoding, typename T, typename Lookup>
+ struct get_info<symbols_parser<Encoding, T, Lookup>>
{
typedef std::string result_type;
- result_type operator()(symbols< Char, T
- , Lookup, Filter
+ result_type operator()(symbols_parser< Encoding, T
+ , Lookup
> const& symbols) const
{
return symbols.name();
}
};
+
+ namespace standard
+ {
+ template <typename T = unused_type>
+ using symbols = symbols_parser<char_encoding::standard, T>;
+ }
+
+ using standard::symbols;
+
+ namespace standard_wide
+ {
+ template <typename T = unused_type>
+ using symbols = symbols_parser<char_encoding::standard_wide, T>;
+ }
+
+ namespace ascii
+ {
+ template <typename T = unused_type>
+ using symbols = symbols_parser<char_encoding::ascii, T>;
+ }
+
+ namespace iso8859_1
+ {
+ template <typename T = unused_type>
+ using symbols = symbols_parser<char_encoding::iso8859_1, T>;
+ }
+
}}}
#if defined(BOOST_MSVC)
diff --git a/boost/spirit/home/x3/string/tst.hpp b/boost/spirit/home/x3/string/tst.hpp
index 5379b032be..704ef92c70 100644
--- a/boost/spirit/home/x3/string/tst.hpp
+++ b/boost/spirit/home/x3/string/tst.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_TST_JUNE_03_2007_1031AM)
#define BOOST_SPIRIT_X3_TST_JUNE_03_2007_1031AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/string/detail/tst.hpp>
namespace boost { namespace spirit { namespace x3
@@ -52,17 +48,17 @@ namespace boost { namespace spirit { namespace x3
return assign(rhs);
}
- template <typename Iterator, typename Filter>
- T* find(Iterator& first, Iterator last, Filter filter) const
+ template <typename Iterator, typename CaseCompare>
+ T* find(Iterator& first, Iterator last, CaseCompare caseCompare) const
{
- return node::find(root, first, last, filter);
+ return node::find(root, first, last, caseCompare);
}
- template <typename Iterator>
+ /*template <typename Iterator>
T* find(Iterator& first, Iterator last) const
{
- return find(first, last, tst_pass_through());
- }
+ return find(first, last, case_compare<tst_pass_through());
+ }*/
template <typename Iterator>
T* add(
diff --git a/boost/spirit/home/x3/string/tst_map.hpp b/boost/spirit/home/x3/string/tst_map.hpp
index 2501324de6..11fb135449 100644
--- a/boost/spirit/home/x3/string/tst_map.hpp
+++ b/boost/spirit/home/x3/string/tst_map.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_TST_MAP_JUNE_03_2007_1143AM)
#define BOOST_SPIRIT_X3_TST_MAP_JUNE_03_2007_1143AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/string/detail/tst.hpp>
#include <unordered_map>
#include <boost/pool/object_pool.hpp>
@@ -129,7 +125,7 @@ namespace boost { namespace spirit { namespace x3
void clear()
{
- BOOST_FOREACH(typename map_type::value_type& x, map)
+ for (typename map_type::value_type& x : map)
{
node::destruct_node(x.second.root, this);
if (x.second.data)
@@ -141,7 +137,7 @@ namespace boost { namespace spirit { namespace x3
template <typename F>
void for_each(F f) const
{
- BOOST_FOREACH(typename map_type::value_type const& x, map)
+ for (typename map_type::value_type const& x : map)
{
std::basic_string<Char> s(1, x.first);
node::for_each(x.second.root, s, f);
@@ -164,7 +160,7 @@ namespace boost { namespace spirit { namespace x3
void copy(tst_map const& rhs)
{
- BOOST_FOREACH(typename map_type::value_type const& x, rhs.map)
+ for (typename map_type::value_type const& x : rhs.map)
{
map_data xx = {node::clone_node(x.second.root, this), 0};
if (x.second.data)
@@ -177,7 +173,7 @@ namespace boost { namespace spirit { namespace x3
{
if (this != &rhs)
{
- BOOST_FOREACH(typename map_type::value_type& x, map)
+ for (typename map_type::value_type& x : map)
{
node::destruct_node(x.second.root, this);
}
diff --git a/boost/spirit/home/x3/support/ast/variant.hpp b/boost/spirit/home/x3/support/ast/variant.hpp
index cf626e88be..52e565d1d4 100644
--- a/boost/spirit/home/x3/support/ast/variant.hpp
+++ b/boost/spirit/home/x3/support/ast/variant.hpp
@@ -7,13 +7,10 @@
#if !defined(BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM)
#define BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/variant.hpp>
#include <boost/mpl/list.hpp>
#include <boost/type_traits/is_base_of.hpp>
+#include <type_traits>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace x3
@@ -126,17 +123,25 @@ namespace boost { namespace spirit { namespace x3
// tell spirit that this is an adapted variant
struct adapted_variant_tag;
- typedef boost::variant<Types...> variant_type;
- typedef mpl::list<typename detail::remove_forward<Types>::type...> types;
- typedef variant<Types...> base_type;
+ using variant_type = boost::variant<Types...>;
+ using types = mpl::list<typename detail::remove_forward<Types>::type...>;
+ using base_type = variant; // The current instantiation
+
+ template<typename T>
+ using non_self_t // used only for SFINAE checks below
+ = std::enable_if_t<!(std::is_base_of<base_type
+ ,std::remove_reference_t<T>
+ >
+ ::value)
+ >;
variant() : var() {}
- template <typename T, typename disable_if<is_base_of<base_type, T>>::type>
+ template <typename T, class = non_self_t<T>>
explicit variant(T const& rhs)
: var(rhs) {}
- template <typename T, typename disable_if<is_base_of<base_type, T>>::type>
+ template <typename T, class = non_self_t<T>>
explicit variant(T&& rhs)
: var(std::forward<T>(rhs)) {}
@@ -161,16 +166,14 @@ namespace boost { namespace spirit { namespace x3
return *this;
}
- template <typename T>
- //typename disable_if<is_base_of<base_type, T>, variant&>::type
+ template <typename T, class = non_self_t<T>>
variant& operator=(T const& rhs)
{
var = rhs;
return *this;
}
- template <typename T>
- //typename disable_if<is_base_of<base_type, T>, variant&>::type
+ template <typename T, class = non_self_t<T>>
variant& operator=(T&& rhs)
{
var = std::forward<T>(rhs);
diff --git a/boost/spirit/home/x3/support/context.hpp b/boost/spirit/home/x3/support/context.hpp
index 93bcb24070..592ce3ff76 100644
--- a/boost/spirit/home/x3/support/context.hpp
+++ b/boost/spirit/home/x3/support/context.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_CONTEXT_JAN_4_2012_1215PM)
#define BOOST_SPIRIT_X3_CONTEXT_JAN_4_2012_1215PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/mpl/identity.hpp>
@@ -23,26 +19,13 @@ namespace boost { namespace spirit { namespace x3
context(T& val, Next const& next)
: val(val), next(next) {}
- template <typename ID_, typename Unused = void>
- struct get_result
- {
- typedef typename Next::template get_result<ID_>::type type;
- };
-
- template <typename Unused>
- struct get_result<mpl::identity<ID>, Unused>
- {
- typedef T& type;
- };
-
T& get(mpl::identity<ID>) const
{
return val;
}
template <typename ID_>
- typename Next::template get_result<ID_>::type
- get(ID_ id) const
+ decltype(auto) get(ID_ id) const
{
return next.get(id);
}
@@ -60,37 +43,22 @@ namespace boost { namespace spirit { namespace x3
context(T& val, unused_type)
: val(val) {}
- template <typename ID_, typename Unused = void>
- struct get_result
- {
- typedef unused_type type;
- };
-
- template <typename Unused>
- struct get_result<mpl::identity<ID>, Unused>
- {
- typedef T& type;
- };
-
T& get(mpl::identity<ID>) const
{
return val;
}
template <typename ID_>
- unused_type
- get(ID_) const
+ unused_type get(ID_) const
{
- return unused;
+ return {};
}
T& val;
};
template <typename Tag, typename Context>
- inline auto
- get(Context const& context)
- -> decltype(context.get(mpl::identity<Tag>()))
+ inline decltype(auto) get(Context const& context)
{
return context.get(mpl::identity<Tag>());
}
@@ -98,13 +66,13 @@ namespace boost { namespace spirit { namespace x3
template <typename ID, typename T, typename Next>
inline context<ID, T, Next> make_context(T& val, Next const& next)
{
- return context<ID, T, Next>(val, next);
+ return { val, next };
}
template <typename ID, typename T>
inline context<ID, T> make_context(T& val)
{
- return context<ID, T>(val);
+ return { val };
}
namespace detail
@@ -120,7 +88,7 @@ namespace boost { namespace spirit { namespace x3
inline context<ID, T, Next>
make_unique_context(T& val, Next const& next, unused_type)
{
- return context<ID, T, Next>(val, next);
+ return { val, next };
}
}
diff --git a/boost/spirit/home/x3/support/no_case.hpp b/boost/spirit/home/x3/support/no_case.hpp
new file mode 100644
index 0000000000..2ad3f709c6
--- /dev/null
+++ b/boost/spirit/home/x3/support/no_case.hpp
@@ -0,0 +1,102 @@
+/*=============================================================================
+ 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_SUPPORT_NO_CASE_SEPT_24_2014_1125PM)
+#define BOOST_SPIRIT_X3_SUPPORT_NO_CASE_SEPT_24_2014_1125PM
+
+#include <boost/spirit/home/x3/support/unused.hpp>
+#include <boost/spirit/home/x3/support/context.hpp>
+#include <boost/spirit/home/x3/char/char_class_tags.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ struct no_case_tag {};
+
+ template <typename Encoding>
+ struct case_compare
+ {
+ template < template <typename> class basic_charset>
+ typename Encoding::char_type
+ in_set( typename Encoding::char_type const ch
+ , basic_charset<typename Encoding::char_type> const &set)
+ {
+ return set.test(ch);
+ }
+
+ int32_t operator()(
+ typename Encoding::char_type const lc
+ , typename Encoding::char_type const rc) const
+ {
+ return lc - rc;
+ }
+
+
+ template <typename CharClassTag>
+ CharClassTag get_char_class_tag(CharClassTag tag) const
+ {
+ return tag;
+ }
+ };
+
+ template <typename Encoding>
+ struct no_case_compare
+ {
+ template < template <typename> class basic_charset>
+ typename Encoding::char_type
+ in_set( typename Encoding::char_type const ch
+ , basic_charset<typename Encoding::char_type> const &set)
+ {
+ return set.test(ch)
+ || set.test(Encoding::islower(ch) ? Encoding::toupper(ch) : Encoding::tolower(ch));
+ }
+
+ int32_t operator()(
+ typename Encoding::char_type const lc
+ , typename Encoding::char_type const rc) const
+ {
+ return Encoding::islower(rc) ? Encoding::tolower(lc) - rc : Encoding::toupper(lc) - rc;
+ }
+
+ template <typename CharClassTag>
+ CharClassTag get_char_class_tag(CharClassTag tag) const
+ {
+ return tag;
+ }
+
+ alpha_tag get_char_class_tag(lower_tag ) const
+ {
+ return {};
+ }
+
+ alpha_tag get_char_class_tag(upper_tag ) const
+ {
+ return {};
+ }
+
+ };
+
+ template <typename Encoding>
+ case_compare<Encoding> get_case_compare_impl(unused_type const&)
+ {
+ return {};
+ }
+
+ template <typename Encoding>
+ no_case_compare<Encoding> get_case_compare_impl(no_case_tag const&)
+ {
+ return {};
+ }
+
+ template <typename Encoding, typename Context>
+ inline decltype(auto) get_case_compare(Context const& context)
+ {
+ return get_case_compare_impl<Encoding>(x3::get<no_case_tag>(context));
+ }
+ auto const no_case_compare_ = no_case_tag{};
+
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp b/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp
index 73770c87d0..4ebd66f182 100644
--- a/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp
+++ b/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp
@@ -11,10 +11,6 @@
#if !defined(BOOST_SPIRIT_X3_DETAIL_EXTRACT_INT_APRIL_17_2006_0816AM)
#define BOOST_SPIRIT_X3_DETAIL_EXTRACT_INT_APRIL_17_2006_0816AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/support/traits/attribute_type.hpp>
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
diff --git a/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp b/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp
index aa80cdd6ea..621275f4c8 100644
--- a/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp
+++ b/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_EXTRACT_INT_APRIL_17_2006_0830AM)
#define BOOST_SPIRIT_X3_EXTRACT_INT_APRIL_17_2006_0830AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
#include <boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp>
#include <boost/assert.hpp>
diff --git a/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp b/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp
index fb30f02306..ea1f0df949 100644
--- a/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp
+++ b/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp
@@ -9,10 +9,6 @@
#if !defined(SPIRIT_EXTRACT_REAL_APRIL_18_2006_0901AM)
#define SPIRIT_EXTRACT_REAL_APRIL_18_2006_0901AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <cmath>
#include <boost/limits.hpp>
#include <boost/type_traits/is_same.hpp>
diff --git a/boost/spirit/home/x3/support/numeric_utils/pow10.hpp b/boost/spirit/home/x3/support/numeric_utils/pow10.hpp
index f51d29fba8..1ff3a077a1 100644
--- a/boost/spirit/home/x3/support/numeric_utils/pow10.hpp
+++ b/boost/spirit/home/x3/support/numeric_utils/pow10.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_POW10_DECEMBER_26_2008_1118AM)
#define BOOST_SPIRIT_X3_POW10_DECEMBER_26_2008_1118AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/limits.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
diff --git a/boost/spirit/home/x3/support/numeric_utils/sign.hpp b/boost/spirit/home/x3/support/numeric_utils/sign.hpp
index fe2feceeed..2ee4142de6 100644
--- a/boost/spirit/home/x3/support/numeric_utils/sign.hpp
+++ b/boost/spirit/home/x3/support/numeric_utils/sign.hpp
@@ -9,10 +9,6 @@
#if !defined(SPIRIT_SIGN_MAR_11_2009_0734PM)
#define SPIRIT_SIGN_MAR_11_2009_0734PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/sign.hpp>
diff --git a/boost/spirit/home/x3/support/subcontext.hpp b/boost/spirit/home/x3/support/subcontext.hpp
index 7614fcbcae..d4c60d084b 100644
--- a/boost/spirit/home/x3/support/subcontext.hpp
+++ b/boost/spirit/home/x3/support/subcontext.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM)
#define BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/fusion/support/pair.hpp>
#include <boost/spirit/home/x3/support/context.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
@@ -29,12 +25,6 @@ namespace boost { namespace spirit { namespace x3
subcontext(Context const& /*context*/)
{}
- template <typename ID_, typename Unused = void>
- struct get_result
- {
- typedef unused_type type;
- };
-
template <typename ID_>
unused_type
get(ID_) const
diff --git a/boost/spirit/home/x3/support/traits/attribute_category.hpp b/boost/spirit/home/x3/support/traits/attribute_category.hpp
index a003327de2..53e806c613 100644
--- a/boost/spirit/home/x3/support/traits/attribute_category.hpp
+++ b/boost/spirit/home/x3/support/traits/attribute_category.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM)
#define BOOST_SPIRIT_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/identity.hpp>
#include <boost/mpl/logical.hpp>
#include <boost/mpl/eval_if.hpp>
diff --git a/boost/spirit/home/x3/support/traits/attribute_of.hpp b/boost/spirit/home/x3/support/traits/attribute_of.hpp
index 71f70b0273..93ee79b57b 100644
--- a/boost/spirit/home/x3/support/traits/attribute_of.hpp
+++ b/boost/spirit/home/x3/support/traits/attribute_of.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_ATTRIBUTE_OF_JAN_7_2012_0914AM)
#define BOOST_SPIRIT_X3_ATTRIBUTE_OF_JAN_7_2012_0914AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/utility/enable_if.hpp>
diff --git a/boost/spirit/home/x3/support/traits/attribute_type.hpp b/boost/spirit/home/x3/support/traits/attribute_type.hpp
index 55e788b41c..f1b8d871a9 100644
--- a/boost/spirit/home/x3/support/traits/attribute_type.hpp
+++ b/boost/spirit/home/x3/support/traits/attribute_type.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_ATTRIBUTE_TYPE_JAN_5_2012_0358PM)
#define BOOST_SPIRIT_X3_ATTRIBUTE_TYPE_JAN_5_2012_0358PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/identity.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/traits/container_traits.hpp b/boost/spirit/home/x3/support/traits/container_traits.hpp
index c382b7bfaa..ed9213b68c 100644
--- a/boost/spirit/home/x3/support/traits/container_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/container_traits.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_CONTAINER_FEBRUARY_06_2007_1001AM)
#define BOOST_SPIRIT_X3_CONTAINER_FEBRUARY_06_2007_1001AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/fusion/support/category_of.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/detail/iterator.hpp>
@@ -20,8 +16,12 @@
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
+
#include <vector>
+#include <map>
#include <string>
+#include <iterator>
+#include <algorithm>
namespace boost { namespace spirit { namespace x3 { namespace traits
{
@@ -112,10 +112,22 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
template <typename Container, typename Enable = void>
struct push_back_container
{
+ template <typename Key, typename Value, typename Compare, typename Allocator, typename T>
+ static void push_back(std::map<Key, Value, Compare, Allocator>& c, T&& val)
+ {
+ c.insert(std::move(val));
+ }
+
+ template <typename Container_, typename T>
+ static void push_back(Container_& c, T&& val)
+ {
+ c.push_back(std::move(val));
+ }
+
template <typename T>
static bool call(Container& c, T&& val)
{
- c.insert(c.end(), std::move(val));
+ push_back(c, std::move(val));
return true;
}
};
@@ -154,17 +166,23 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
template <typename Container_>
static void reserve(Container_& c, std::size_t size) {}
- template <typename T>
- static void reserve(std::vector<T>& c, std::size_t size)
+ template <typename T, typename Allocator>
+ static void reserve(std::vector<T, Allocator>& c, std::size_t size)
{
c.reserve(size);
}
+
+ template <typename Container_, typename Iterator>
+ static void insert(Container_& c, Iterator first, Iterator last)
+ {
+ std::copy(first, last, std::inserter(c, c.end()));
+ }
template <typename Iterator>
static bool call(Container& c, Iterator first, Iterator last)
{
reserve(c, c.size() + std::distance(first, last));
- c.insert(c.end(), first, last);
+ insert(c, first, last);
return true;
}
};
diff --git a/boost/spirit/home/x3/support/traits/handles_container.hpp b/boost/spirit/home/x3/support/traits/handles_container.hpp
index 3fe05aef87..ad0d1f19ea 100644
--- a/boost/spirit/home/x3/support/traits/handles_container.hpp
+++ b/boost/spirit/home/x3/support/traits/handles_container.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_HANDLES_CONTAINER_DEC_18_2010_0920AM)
#define BOOST_SPIRIT_X3_HANDLES_CONTAINER_DEC_18_2010_0920AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/bool.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/traits/has_attribute.hpp b/boost/spirit/home/x3/support/traits/has_attribute.hpp
index c8b1f8a347..cf4ab00801 100644
--- a/boost/spirit/home/x3/support/traits/has_attribute.hpp
+++ b/boost/spirit/home/x3/support/traits/has_attribute.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_HAS_ATTRIBUTE_JUN_6_2012_1714PM)
#define BOOST_SPIRIT_X3_HAS_ATTRIBUTE_JUN_6_2012_1714PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
#include <boost/mpl/bool.hpp>
diff --git a/boost/spirit/home/x3/support/traits/is_parser.hpp b/boost/spirit/home/x3/support/traits/is_parser.hpp
index cfbe8f74b4..a65d984584 100644
--- a/boost/spirit/home/x3/support/traits/is_parser.hpp
+++ b/boost/spirit/home/x3/support/traits/is_parser.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_IS_PARSER_MAY_20_2013_0235PM)
#define BOOST_SPIRIT_X3_IS_PARSER_MAY_20_2013_0235PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/bool.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
diff --git a/boost/spirit/home/x3/support/traits/is_substitute.hpp b/boost/spirit/home/x3/support/traits/is_substitute.hpp
index 9e023371ce..ef1c472c7f 100644
--- a/boost/spirit/home/x3/support/traits/is_substitute.hpp
+++ b/boost/spirit/home/x3/support/traits/is_substitute.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_IS_SUBSTITUTE_JAN_9_2012_1049PM)
#define BOOST_SPIRIT_X3_IS_SUBSTITUTE_JAN_9_2012_1049PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
#include <boost/fusion/include/is_sequence.hpp>
#include <boost/fusion/include/map.hpp>
diff --git a/boost/spirit/home/x3/support/traits/is_variant.hpp b/boost/spirit/home/x3/support/traits/is_variant.hpp
index 829a673c3f..a936044a81 100644
--- a/boost/spirit/home/x3/support/traits/is_variant.hpp
+++ b/boost/spirit/home/x3/support/traits/is_variant.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_IS_VARIANT_JAN_10_2012_0823AM)
#define BOOST_SPIRIT_X3_IS_VARIANT_JAN_10_2012_0823AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/variant.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/bool.hpp>
diff --git a/boost/spirit/home/x3/support/traits/make_attribute.hpp b/boost/spirit/home/x3/support/traits/make_attribute.hpp
index cf3baeedaf..9465228c1d 100644
--- a/boost/spirit/home/x3/support/traits/make_attribute.hpp
+++ b/boost/spirit/home/x3/support/traits/make_attribute.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM)
#define BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/if.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/add_reference.hpp>
diff --git a/boost/spirit/home/x3/support/traits/move_to.hpp b/boost/spirit/home/x3/support/traits/move_to.hpp
index ecd7c6f202..fd3d59d7e2 100644
--- a/boost/spirit/home/x3/support/traits/move_to.hpp
+++ b/boost/spirit/home/x3/support/traits/move_to.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_MOVE_TO_JAN_17_2013_0859PM)
#define BOOST_SPIRIT_X3_MOVE_TO_JAN_17_2013_0859PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/attribute_category.hpp>
#include <boost/spirit/home/x3/support/traits/tuple_traits.hpp>
#include <boost/spirit/home/x3/support/traits/variant_has_substitute.hpp>
@@ -181,14 +177,14 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
template <typename T>
inline void move_to(T& src, T& dest)
{
- if (&src != &dest)
+ if (boost::addressof(src) != boost::addressof(dest))
dest = std::move(src);
}
template <typename T>
inline void move_to(T const& src, T& dest)
{
- if (&src != &dest)
+ if (boost::addressof(src) != boost::addressof(dest))
dest = std::move(src);
}
diff --git a/boost/spirit/home/x3/support/traits/numeric_traits.hpp b/boost/spirit/home/x3/support/traits/numeric_traits.hpp
index 3cdbdaec63..9f455cc627 100644
--- a/boost/spirit/home/x3/support/traits/numeric_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/numeric_traits.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_NUMERIC_TRAITS_JAN_07_2011_0722AM)
#define BOOST_SPIRIT_X3_NUMERIC_TRAITS_JAN_07_2011_0722AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/config.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/bool.hpp>
diff --git a/boost/spirit/home/x3/support/traits/optional_traits.hpp b/boost/spirit/home/x3/support/traits/optional_traits.hpp
index 65568b0265..3c5e853797 100644
--- a/boost/spirit/home/x3/support/traits/optional_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/optional_traits.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_OPTIONAL_TRAITS_FEBRUARY_06_2007_1001AM)
#define BOOST_SPIRIT_X3_OPTIONAL_TRAITS_FEBRUARY_06_2007_1001AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/optional/optional.hpp>
#include <boost/mpl/identity.hpp>
diff --git a/boost/spirit/home/x3/support/traits/print_attribute.hpp b/boost/spirit/home/x3/support/traits/print_attribute.hpp
index 47bffce1a1..cc76e02d30 100644
--- a/boost/spirit/home/x3/support/traits/print_attribute.hpp
+++ b/boost/spirit/home/x3/support/traits/print_attribute.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_PRINT_ATTRIBUTE_JANUARY_20_2013_0814AM)
#define BOOST_SPIRIT_X3_PRINT_ATTRIBUTE_JANUARY_20_2013_0814AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/variant.hpp>
#include <boost/optional/optional.hpp>
#include <boost/fusion/include/is_sequence.hpp>
diff --git a/boost/spirit/home/x3/support/traits/print_token.hpp b/boost/spirit/home/x3/support/traits/print_token.hpp
index f1429f4776..e8f4dea325 100644
--- a/boost/spirit/home/x3/support/traits/print_token.hpp
+++ b/boost/spirit/home/x3/support/traits/print_token.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_PRINT_TOKEN_JANUARY_20_2013_0814AM)
#define BOOST_SPIRIT_X3_PRINT_TOKEN_JANUARY_20_2013_0814AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/type_traits/is_convertible.hpp>
diff --git a/boost/spirit/home/x3/support/traits/string_traits.hpp b/boost/spirit/home/x3/support/traits/string_traits.hpp
index 46ee356cdc..44c8d144a8 100644
--- a/boost/spirit/home/x3/support/traits/string_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/string_traits.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_STRING_TRAITS_OCTOBER_2008_1252PM)
#define BOOST_SPIRIT_X3_STRING_TRAITS_OCTOBER_2008_1252PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <string>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
diff --git a/boost/spirit/home/x3/support/traits/transform_attribute.hpp b/boost/spirit/home/x3/support/traits/transform_attribute.hpp
index 24268520d7..98af3099e6 100644
--- a/boost/spirit/home/x3/support/traits/transform_attribute.hpp
+++ b/boost/spirit/home/x3/support/traits/transform_attribute.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_ATTRIBUTE_TRANSFORM_JAN_8_2012_0721PM)
#define BOOST_SPIRIT_X3_ATTRIBUTE_TRANSFORM_JAN_8_2012_0721PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/mpl/identity.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/traits/tuple_traits.hpp b/boost/spirit/home/x3/support/traits/tuple_traits.hpp
index 17bfd4e1cb..46e4246b74 100644
--- a/boost/spirit/home/x3/support/traits/tuple_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/tuple_traits.hpp
@@ -7,10 +7,6 @@
#if !defined(BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM)
#define BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/fusion/include/is_sequence.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/mpl/bool.hpp>
diff --git a/boost/spirit/home/x3/support/traits/value_traits.hpp b/boost/spirit/home/x3/support/traits/value_traits.hpp
index 5f004c957c..d28af74d3f 100644
--- a/boost/spirit/home/x3/support/traits/value_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/value_traits.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_VALUE_TRAITS_MAY_07_2013_0203PM)
#define BOOST_SPIRIT_X3_VALUE_TRAITS_MAY_07_2013_0203PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/utility/value_init.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp b/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp
index 4de7b7d5e3..d258d54dc5 100644
--- a/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp
+++ b/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM)
#define BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp b/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp
index d0dfb49b8d..2f8b42a834 100644
--- a/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp
+++ b/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM)
#define BOOST_SPIRIT_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/spirit/home/x3/support/traits/is_substitute.hpp>
namespace boost { namespace spirit { namespace x3 { namespace traits
diff --git a/boost/spirit/home/x3/support/unused.hpp b/boost/spirit/home/x3/support/unused.hpp
index cf42d13098..f7857e0dbd 100644
--- a/boost/spirit/home/x3/support/unused.hpp
+++ b/boost/spirit/home/x3/support/unused.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM)
#define BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <ostream>
#include <istream>
#include <boost/mpl/identity.hpp>
@@ -64,16 +60,13 @@ namespace boost { namespace spirit { namespace x3
// unused_type can also masquerade as an empty context (see context.hpp)
template <typename ID>
- struct get_result : mpl::identity<unused_type> {};
-
- template <typename ID>
unused_type get(ID) const
{
- return unused_type();
+ return {};
}
};
- unused_type const unused = unused_type();
+ auto const unused = unused_type{};
inline std::ostream& operator<<(std::ostream& out, unused_type const&)
{
diff --git a/boost/spirit/home/x3/support/utility/annotate_on_success.hpp b/boost/spirit/home/x3/support/utility/annotate_on_success.hpp
new file mode 100644
index 0000000000..8129675559
--- /dev/null
+++ b/boost/spirit/home/x3/support/utility/annotate_on_success.hpp
@@ -0,0 +1,51 @@
+/*=============================================================================
+ Copyright (c) 2001-2015 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__ANNOTATE_ON_SUCCESS_HPP)
+#define BOOST_SPIRIT_X3__ANNOTATE_ON_SUCCESS_HPP
+
+#include <boost/spirit/home/x3/support/ast/variant.hpp>
+#include <boost/spirit/home/x3/support/context.hpp>
+#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
+#include <boost/spirit/home/x3/support/utility/lambda_visitor.hpp>
+
+namespace boost { namespace spirit { namespace x3
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // The on_success handler tags the AST with the iterator position
+ // for error handling.
+ //
+ // The on_success handler also ties the AST to a vector of iterator
+ // positions for the purpose of subsequent semantic error handling
+ // when the program is being compiled. See x3::position_cache in
+ // x3/support/ast.
+ //
+ // We'll ask the X3's error_handler utility to do these.
+ ///////////////////////////////////////////////////////////////////////////
+
+ struct annotate_on_success
+ {
+ template <typename Iterator, typename Context, typename... Types>
+ inline void on_success(Iterator const& first, Iterator const& last
+ , variant<Types...>& ast, Context const& context)
+ {
+ ast.apply_visitor(x3::make_lambda_visitor<void>([&](auto& node)
+ {
+ this->on_success(first, last, node, context);
+ }));
+ }
+
+ template <typename T, typename Iterator, typename Context>
+ inline void on_success(Iterator const& first, Iterator const& last
+ , T& ast, Context const& context)
+ {
+ auto& error_handler = get<error_handler_tag>(context).get();
+ error_handler.tag(ast, first, last);
+ }
+ };
+}}}
+
+#endif
diff --git a/boost/spirit/home/x3/support/utility/error_reporting.hpp b/boost/spirit/home/x3/support/utility/error_reporting.hpp
index 9e65f2149b..51ac403728 100644
--- a/boost/spirit/home/x3/support/utility/error_reporting.hpp
+++ b/boost/spirit/home/x3/support/utility/error_reporting.hpp
@@ -7,7 +7,11 @@
#if !defined(BOOST_SPIRIT_X3_ERROR_REPORTING_MAY_19_2014_00405PM)
#define BOOST_SPIRIT_X3_ERROR_REPORTING_MAY_19_2014_00405PM
+#ifndef BOOST_SPIRIT_X3_NO_FILESYSTEM
#include <boost/filesystem/path.hpp>
+#endif
+
+#include <boost/locale/encoding_utf.hpp>
#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
#include <ostream>
@@ -15,6 +19,9 @@
namespace boost { namespace spirit { namespace x3
{
+ // tag used to get our error handler from the context
+ struct error_handler_tag;
+
template <typename Iterator>
class error_handler
{
@@ -37,11 +44,7 @@ namespace boost { namespace spirit { namespace x3
void operator()(position_tagged pos, std::string const& message) const
{
auto where = pos_cache.position_of(pos);
- (*this)(
- where.begin()
- , where.end()
- , message
- );
+ (*this)(where.begin(), where.end(), message);
}
template <typename AST>
@@ -49,20 +52,16 @@ namespace boost { namespace spirit { namespace x3
{
return pos_cache.annotate(ast, first, last);
}
-//
-// void operator()(
-// Iterator first
-// , Iterator last
-// , Iterator err_op
-// , Iterator err_first
-// , Iterator err_last
-// , std::string const& error_message
-// ) const;
+
+ boost::iterator_range<Iterator> position_of(position_tagged pos) const
+ {
+ return pos_cache.position_of(pos);
+ }
private:
void print_file_line(std::size_t line) const;
- void print_line(Iterator& line_start, Iterator last) const;
+ void print_line(Iterator line_start, Iterator last) const;
void print_indicator(Iterator& line_start, Iterator last, char ind) const;
void skip_whitespace(Iterator& err_pos, Iterator last) const;
void skip_non_whitespace(Iterator& err_pos, Iterator last) const;
@@ -78,29 +77,39 @@ namespace boost { namespace spirit { namespace x3
template <typename Iterator>
void error_handler<Iterator>::print_file_line(std::size_t line) const
{
- namespace fs = boost::filesystem;
-
if (file != "")
+ {
+#ifdef BOOST_SPIRIT_X3_NO_FILESYSTEM
+ err_out << "In file " << file << ", ";
+#else
+ namespace fs = boost::filesystem;
err_out << "In file " << fs::path(file).generic_string() << ", ";
+#endif
+ }
else
+ {
err_out << "In ";
+ }
err_out << "line " << line << ':' << std::endl;
}
template <typename Iterator>
- void error_handler<Iterator>::print_line(Iterator& start, Iterator last) const
+ void error_handler<Iterator>::print_line(Iterator start, Iterator last) const
{
- for (; start != last; ++start)
+ auto end = start;
+ while (end != last)
{
- auto c = *start;
+ auto c = *end;
if (c == '\r' || c == '\n')
break;
else
- err_out << c;
+ ++end;
}
- err_out << std::endl;
- }
+ typedef typename std::iterator_traits<Iterator>::value_type char_type;
+ std::basic_string<char_type> line{start, end};
+ err_out << locale::conv::utf_to_utf<char>(line) << std::endl;
+ }
template <typename Iterator>
void error_handler<Iterator>::print_indicator(Iterator& start, Iterator last, char ind) const
@@ -159,8 +168,25 @@ namespace boost { namespace spirit { namespace x3
template <typename Iterator>
std::size_t error_handler<Iterator>::position(Iterator i) const
{
- // $$$ asumes iterator is similar to line_pos_iterator $$$
- return i.position();
+ std::size_t line { 1 };
+ typename std::iterator_traits<Iterator>::value_type prev { 0 };
+
+ for (Iterator pos = pos_cache.first(); pos != i; ++pos) {
+ auto c = *pos;
+ switch (c) {
+ case '\n':
+ if (prev != '\r') ++line;
+ break;
+ case '\r':
+ if (prev != '\n') ++line;
+ break;
+ default:
+ break;
+ }
+ prev = c;
+ }
+
+ return line;
}
template <typename Iterator>
@@ -179,8 +205,7 @@ namespace boost { namespace spirit { namespace x3
Iterator start = get_line_start(first, err_pos);
if (start != first)
++start;
- Iterator i = start;
- print_line(i, last);
+ print_line(start, last);
print_indicator(start, err_pos, '_');
err_out << "^_" << std::endl;
}
@@ -201,40 +226,11 @@ namespace boost { namespace spirit { namespace x3
Iterator start = get_line_start(first, err_first);
if (start != first)
++start;
- Iterator i = start;
- print_line(i, last);
+ print_line(start, last);
print_indicator(start, err_first, ' ');
print_indicator(start, err_last, '~');
err_out << " <<-- Here" << std::endl;
}
-//
-// template <typename Iterator>
-// void error_handler<Iterator>::operator()(
-// Iterator first
-// , Iterator last
-// , Iterator err_op
-// , Iterator err_first
-// , Iterator err_last
-// , std::string const& error_message
-// ) const
-// {
-// // make sure err_pos does not point to white space
-// skip_whitespace(err_first, last);
-//
-// print_file_line(position(err_pos));
-// err_out << error_message << std::endl;
-//
-// Iterator start = get_line_start(first, err_first);
-// if (start != first)
-// ++start;
-// Iterator i = start;
-// print_line(i, last);
-// print_indicator(start, err_first, ' ');
-// print_indicator(start, err_op, '~');
-// err_out << '^';
-// print_indicator(++start, err_last, '~');
-// err_out << " <<-- Here" << std::endl;
-// }
}}}
diff --git a/boost/spirit/home/x3/support/utility/integer_sequence.hpp b/boost/spirit/home/x3/support/utility/integer_sequence.hpp
deleted file mode 100644
index 1f0bace72b..0000000000
--- a/boost/spirit/home/x3/support/utility/integer_sequence.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*//////////////////////////////////////////////////////////////////////////////
- Copyright (c) 2014 Jamboree
-
- 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)
-//////////////////////////////////////////////////////////////////////////////*/
-#ifndef BOOST_SPIRIT_X3_INTEGER_SEQUENCE_HPP_INCLUDED
-#define BOOST_SPIRIT_X3_INTEGER_SEQUENCE_HPP_INCLUDED
-
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-#include <cstddef>
-#include <boost/type_traits/integral_constant.hpp>
-
-// This is a standard (c++1y) compatible integer_sequence implementation,
-// it's needed for now, and it could be replaced with std::integer_sequence
-// once the new standard is available everywhere.
-
-namespace boost { namespace spirit { namespace x3
-{
- template <typename T, T... Ns>
- struct integer_sequence
- {
- typedef T value_type;
-
- static constexpr std::size_t size() noexcept
- {
- return sizeof...(Ns);
- }
- };
-}}}
-
-namespace boost { namespace spirit { namespace x3 { namespace detail
-{
- template <typename T, typename S1, typename S2, T N>
- struct accum_integer_sequence;
-
- template <typename T, T... N1, T... N2, T N>
- struct accum_integer_sequence<T, integer_sequence<T, N1...>, integer_sequence<T, N2...>, N>
- {
- typedef integer_sequence<T, N1..., (N + N2)...> type;
- };
-
- template <typename N>
- struct make_integer_sequence_impl
- {
- typedef typename N::value_type T;
- static T const n = N::value;
- static T const m = n / 2;
- typedef typename
- make_integer_sequence_impl<integral_constant<T, m>>::type
- part1;
- typedef typename
- make_integer_sequence_impl<integral_constant<T, n - m>>::type
- part2;
- typedef typename
- accum_integer_sequence<T, part1, part2, m>::type
- type;
- };
-
- template <typename T>
- struct make_integer_sequence_impl<integral_constant<T, 0>>
- {
- typedef integer_sequence<T> type;
- };
-
- template <typename T>
- struct make_integer_sequence_impl<integral_constant<T, 1>>
- {
- typedef integer_sequence<T, 0> type;
- };
-}}}}
-
-namespace boost { namespace spirit { namespace x3
-{
- template <std::size_t... Ns>
- using index_sequence = integer_sequence<std::size_t, Ns...>;
-
- template <typename T, T N>
- using make_integer_sequence = typename detail::make_integer_sequence_impl<
- integral_constant<T, N>>::type;
-
- template <std::size_t N>
- using make_index_sequence = make_integer_sequence<std::size_t, N>;
-
- template <typename... T>
- using index_sequence_for = make_index_sequence<sizeof...(T)>;
-}}}
-
-
-#endif
-
diff --git a/boost/spirit/home/x3/support/utility/is_callable.hpp b/boost/spirit/home/x3/support/utility/is_callable.hpp
index 17f86822b8..5e116de410 100644
--- a/boost/spirit/home/x3/support/utility/is_callable.hpp
+++ b/boost/spirit/home/x3/support/utility/is_callable.hpp
@@ -7,25 +7,17 @@
#ifndef BOOST_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED
#define BOOST_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-#include <boost/utility/result_of.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
-
namespace boost { namespace spirit { namespace x3 { namespace detail
{
template <typename Sig, typename Enable = void>
- struct is_callable_impl
- : mpl::false_
- {};
+ struct is_callable_impl : mpl::false_ {};
template <typename F, typename... A>
struct is_callable_impl<F(A...), typename disable_if_substitution_failure<
- typename result_of<F(A...)>::type>::type>
+ decltype(std::declval<F>()(std::declval<A>()...))>::type>
: mpl::true_
{};
}}}}
@@ -36,9 +28,7 @@ namespace boost { namespace spirit { namespace x3
struct is_callable;
template <typename F, typename... A>
- struct is_callable<F(A...)>
- : detail::is_callable_impl<F(A...)>
- {};
+ struct is_callable<F(A...)> : detail::is_callable_impl<F(A...)> {};
}}}
diff --git a/boost/spirit/home/x3/support/utility/sfinae.hpp b/boost/spirit/home/x3/support/utility/sfinae.hpp
index 6cefa95961..532ae5c54d 100644
--- a/boost/spirit/home/x3/support/utility/sfinae.hpp
+++ b/boost/spirit/home/x3/support/utility/sfinae.hpp
@@ -8,10 +8,6 @@
#if !defined(BOOST_SPIRIT_X3_SFINAE_MAY_20_2013_0840AM)
#define BOOST_SPIRIT_X3_SFINAE_MAY_20_2013_0840AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
namespace boost { namespace spirit { namespace x3
{
template <typename Expr, typename T = void>
@@ -19,6 +15,7 @@ namespace boost { namespace spirit { namespace x3
{
typedef T type;
};
+
template <typename Expr, typename T>
struct lazy_disable_if_substitution_failure
{
diff --git a/boost/spirit/home/x3/support/utility/testing.hpp b/boost/spirit/home/x3/support/utility/testing.hpp
index fced46bef8..6d38ccfed7 100644
--- a/boost/spirit/home/x3/support/utility/testing.hpp
+++ b/boost/spirit/home/x3/support/utility/testing.hpp
@@ -1,68 +1,268 @@
/*=============================================================================
- Copyright (c) 2014 Joel de Guzman
+ Copyright (c) 2001-2015 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_TESTING_JUNE_05_2014_00422PM)
-#define BOOST_SPIRIT_X3_TESTING_JUNE_05_2014_00422PM
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_X3_TEST_UTILITIES)
+#define BOOST_SPIRIT_X3_TEST_UTILITIES
+
+#include <boost/regex.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/fstream.hpp>
namespace boost { namespace spirit { namespace x3 { namespace testing
{
+ namespace fs = boost::filesystem;
+
////////////////////////////////////////////////////////////////////////////
+ // compare
//
- // Test utility
- //
- // The test function accepts a file loaded in memory. The 'test_file'
- // range param points to the data contained in the file. This file
- // contains two parts.
- //
- // 1) The source input for testing
- // 2) The expected result.
- //
- // The first part of the file is sent to the generator function
- // 'gen' which returns a string. This generated string is then compared
- // to the contents of the second (expected result) part.
- //
- // The second part is demarcated by the string parameter 'demarcation'
- // which defaults to "<**expected**>". The expected template may include
- // embedded regular expressions marked-up within re_prefix and re_suffix
- // parameter tags. For example, given the default RE markup ("<%" and
- // "%>"), this template:
- //
- // <%[0-9]+%>
- //
- // will match any integer in the source input being tested. The function
- // will return the first non-matching position. The flag full_match
- // indicates a full match. It is possible for returned pos to be
- // at the end of in (in.end()) while still returning full_match ==
- // false. In that case, we have a partial match.
- //
- // Here's an example of a test file:
- //
- // Hello World, I am Joel. This is a test.
- //
- // <**expected**>
- // Hello World, I am <%[a-zA-Z]+%>. This is a test.
- //
+ // Compares the contents of in with the template tem. The template
+ // may include embedded regular expressions marked up within re_prefix
+ // and re_suffix tags. For example, given the default RE markup, this
+ // template <%[0-9]+%> will match any integer in in. The function
+ // will return the first non-matching position. The flag full_match
+ // indicates a full match. It is possible for returned pos to be
+ // at the end of in (in.end()) while still returning full_match ==
+ // false. In that case, we have a partial match.
////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
- struct test_result
+ struct compare_result
{
+ compare_result(
+ Iterator pos
+ , bool full_match
+ ) : pos(pos), full_match(full_match) {}
+
Iterator pos;
bool full_match;
};
- template <typename Range, typename F>
- test_result<typename Range::const_iterator>
- test(
- Range test_file
- , F gen
- , char const* demarcation = "<**expected**>"
+ template <typename Range>
+ compare_result<typename Range::const_iterator>
+ compare(
+ Range const& in
+ , Range const& tem
+ , char const* re_prefix = "<%"
+ , char const* re_suffix = "%>"
+ );
+
+ ////////////////////////////////////////////////////////////////////////////
+ // compare
+ //
+ // 1) Call f, given the contents of input_path loaded in a string.
+ // The result of calling f is the output string.
+ // 2) Compare the result of calling f with expected template
+ // file (expect_path) using the low-level compare utility
+ // abive
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename F>
+ bool compare(
+ fs::path input_path, fs::path expect_path
+ , F f
, char const* re_prefix = "<%"
, char const* re_suffix = "%>"
- );
+ );
+
+ ////////////////////////////////////////////////////////////////////////////
+ // for_each_file
+ //
+ // For each *.input and *.expect file in a given directory,
+ // call the function f, passing in the *.input and *.expect paths.
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename F>
+ int for_each_file(fs::path p, F f);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // load_file
+ //
+ // Load file into a string.
+ ////////////////////////////////////////////////////////////////////////////
+ std::string load(fs::path p);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Implementation
+ ////////////////////////////////////////////////////////////////////////////
+
+ template <typename Iterator>
+ inline bool is_regex(
+ Iterator& first
+ , Iterator last
+ , std::string& re
+ , char const* re_prefix
+ , char const* re_suffix
+ )
+ {
+ boost::regex e(re_prefix + std::string("(.*?)") + re_suffix);
+ boost::match_results<Iterator> what;
+ if (boost::regex_search(
+ first, last, what, e
+ , boost::match_default | boost::match_continuous))
+ {
+ re = what[1].str();
+ first = what[0].second;
+ return true;
+ }
+ return false;
+ }
+
+ template <typename Range>
+ inline compare_result<typename Range::const_iterator>
+ compare(
+ Range const& in
+ , Range const& tem
+ , char const* re_prefix
+ , char const* re_suffix
+ )
+ {
+ typedef typename Range::const_iterator iter_t;
+ typedef compare_result<iter_t> compare_result_t;
+
+ iter_t in_first = in.begin();
+ iter_t in_last = in.end();
+ iter_t tem_first = tem.begin();
+ iter_t tem_last = tem.end();
+ std::string re;
+
+ while (in_first != in_last && tem_first != tem_last)
+ {
+ if (is_regex(tem_first, tem_last, re, re_prefix, re_suffix))
+ {
+ boost::match_results<iter_t> what;
+ boost::regex e(re);
+ if (!boost::regex_search(
+ in_first, in_last, what, e
+ , boost::match_default | boost::match_continuous))
+ {
+ // RE mismatch: exit now.
+ return compare_result_t(in_first, false);
+ }
+ else
+ {
+ // RE match: gobble the matching string.
+ in_first = what[0].second;
+ }
+ }
+ else
+ {
+ // Char by char comparison. Exit if we have a mismatch.
+ if (*in_first++ != *tem_first++)
+ return compare_result_t(in_first, false);
+ }
+ }
+
+ // Ignore trailing spaces in template
+ bool has_trailing_nonspaces = false;
+ while (tem_first != tem_last)
+ {
+ if (!std::isspace(*tem_first++))
+ {
+ has_trailing_nonspaces = true;
+ break;
+ }
+ }
+ while (in_first != in_last)
+ {
+ if (!std::isspace(*in_first++))
+ {
+ has_trailing_nonspaces = true;
+ break;
+ }
+ }
+ // return a full match only if the template is fully matched and if there
+ // are no more characters to match in the source
+ return compare_result_t(in_first, !has_trailing_nonspaces);
+ }
+
+ template <typename F>
+ inline int for_each_file(fs::path p, F f)
+ {
+ try
+ {
+ if (fs::exists(p) && fs::is_directory(p))
+ {
+ for (auto i = fs::directory_iterator(p); i != fs::directory_iterator(); ++i)
+ {
+ auto ext = fs::extension(i->path());
+ if (ext == ".input")
+ {
+ auto input_path = i->path();
+ auto expect_path = input_path;
+ expect_path.replace_extension(".expect");
+ f(input_path, expect_path);
+ }
+ }
+ }
+ else
+ {
+ std::cerr << "Directory: " << fs::absolute(p) << " does not exist." << std::endl;
+ return 1;
+ }
+ }
+
+ catch (const fs::filesystem_error& ex)
+ {
+ std::cerr << ex.what() << '\n';
+ return 1;
+ }
+ return 0;
+ }
+
+ inline std::string load(fs::path p)
+ {
+ boost::filesystem::ifstream file(p);
+ if (!file)
+ return "";
+ std::string contents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
+ return contents;
+ }
+
+ template <typename F>
+ inline bool compare(
+ fs::path input_path, fs::path expect_path
+ , F f
+ , char const* re_prefix
+ , char const* re_suffix
+ )
+ {
+ std::string output = f(load(input_path), input_path);
+ std::string expected = load(expect_path);
+
+ auto result = compare(output, expected);
+ if (!result.full_match)
+ {
+ std::cout << "=============================================" << std::endl;
+ std::cout << "==== Mismatch Found:" << std::endl;
+ int line = 1;
+ int col = 1;
+ for (auto i = output.begin(); i != result.pos; ++i)
+ {
+ if (*i == '\n')
+ {
+ line++;
+ col = 0;
+ }
+ ++col;
+ }
+
+ std::cerr
+ << "==== File: " << expect_path
+ << ", Line: " << line
+ << ", Column: " << col
+ << std::endl;
+ std::cerr << "=============================================" << std::endl;
+
+ // Print output
+ std::cerr << output;
+ std::cerr << "=============================================" << std::endl;
+ std::cerr << "==== End" << std::endl;
+ std::cerr << "=============================================" << std::endl;
+ return false;
+ }
+ return true;
+ }
}}}}
diff --git a/boost/spirit/home/x3/support/utility/unrefcv.hpp b/boost/spirit/home/x3/support/utility/unrefcv.hpp
index fa4d448178..b12620b591 100644
--- a/boost/spirit/home/x3/support/utility/unrefcv.hpp
+++ b/boost/spirit/home/x3/support/utility/unrefcv.hpp
@@ -7,10 +7,6 @@
#ifndef BOOST_SPIRIT_X3_UNREFCV_HPP_INCLUDED
#define BOOST_SPIRIT_X3_UNREFCV_HPP_INCLUDED
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
diff --git a/boost/spirit/home/x3/support/utility/utf8.hpp b/boost/spirit/home/x3/support/utility/utf8.hpp
index 93b5a22077..b141cce6d2 100644
--- a/boost/spirit/home/x3/support/utility/utf8.hpp
+++ b/boost/spirit/home/x3/support/utility/utf8.hpp
@@ -7,12 +7,7 @@
#if !defined(BOOST_SPIRIT_X3_UC_TYPES_NOVEMBER_23_2008_0840PM)
#define BOOST_SPIRIT_X3_UC_TYPES_NOVEMBER_23_2008_0840PM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/cstdint.hpp>
-#include <boost/foreach.hpp>
#include <boost/regex/pending/unicode_iterator.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <string>
@@ -61,7 +56,7 @@ namespace boost { namespace spirit { namespace x3
insert_iter out_iter(result);
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
typedef typename make_unsigned<Char>::type UChar;
- BOOST_FOREACH(Char ch, str)
+ for (Char ch : str)
{
*utf8_iter++ = (UChar)ch;
}
diff --git a/boost/spirit/home/x3/version.hpp b/boost/spirit/home/x3/version.hpp
new file mode 100644
index 0000000000..3add2f4149
--- /dev/null
+++ b/boost/spirit/home/x3/version.hpp
@@ -0,0 +1,19 @@
+/*=============================================================================
+ 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)
+=============================================================================*/
+#if !defined(SPIRIT_X3_VERSION_INCLUDED)
+#define SPIRIT_X3_VERSION_INCLUDED
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This is the version of the current Spirit X3 distribution
+//
+///////////////////////////////////////////////////////////////////////////////
+#define SPIRIT_X3_VERSION 0x3000
+
+#endif