|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76386 - in branches/release: . boost boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/karma/binary boost/spirit/home/karma/detail boost/spirit/home/karma/directive boost/spirit/home/karma/nonterminal boost/spirit/home/karma/operator boost/spirit/home/lex/lexer/lexertl boost/spirit/home/lex/qi boost/spirit/home/qi/binary boost/spirit/home/support boost/spirit/home/support/detail/endian boost/spirit/home/support/detail/lexer boost/spirit/home/support/detail/lexer/parser boost/spirit/home/support/iterators boost/spirit/home/support/iterators/detail boost/spirit/repository/home/karma/nonterminal libs libs/spirit libs/spirit/doc libs/spirit/doc/karma libs/spirit/doc/qi libs/spirit/repository/doc libs/spirit/repository/doc/qi libs/spirit/repository/example/karma libs/spirit/repository/example/qi libs/spirit/test libs/spirit/test/karma libs/spirit/test/lex libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2012-01-09 09:36:50
Author: hkaiser
Date: 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
New Revision: 76386
URL: http://svn.boost.org/trac/boost/changeset/76386
Log:
Spirit: merging from trunk
Added:
branches/release/libs/spirit/repository/doc/what_s_new.qbk
- copied unchanged from r75321, /trunk/libs/spirit/repository/doc/what_s_new.qbk
branches/release/libs/spirit/test/karma/regression_center_alignment.cpp
- copied unchanged from r76385, /trunk/libs/spirit/test/karma/regression_center_alignment.cpp
branches/release/libs/spirit/test/lex/regression_static_wide_6253.cpp
- copied unchanged from r75910, /trunk/libs/spirit/test/lex/regression_static_wide_6253.cpp
Properties modified:
branches/release/ (props changed)
branches/release/boost/ (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (contents, props changed)
branches/release/libs/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/test/ (props changed)
Text files modified:
branches/release/boost/spirit/home/karma/binary/binary.hpp | 119 ++++++++++++++++++----
branches/release/boost/spirit/home/karma/detail/extract_from.hpp | 34 +++---
branches/release/boost/spirit/home/karma/detail/pass_container.hpp | 56 +++++-----
branches/release/boost/spirit/home/karma/directive/center_alignment.hpp | 32 +++---
branches/release/boost/spirit/home/karma/directive/duplicate.hpp | 32 +++---
branches/release/boost/spirit/home/karma/nonterminal/rule.hpp | 2
branches/release/boost/spirit/home/karma/operator/alternative.hpp | 5
branches/release/boost/spirit/home/karma/operator/sequence.hpp | 43 ++++---
branches/release/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp | 209 ++++++++++++++++++++++++++-------------
branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 110 ++++++++++----------
branches/release/boost/spirit/home/lex/qi/plain_raw_token.hpp | 18 +-
branches/release/boost/spirit/home/lex/qi/plain_token.hpp | 109 +++++++++++++++++++-
branches/release/boost/spirit/home/lex/qi/plain_tokenid.hpp | 114 +++++++++++++++++++--
branches/release/boost/spirit/home/lex/qi/plain_tokenid_mask.hpp | 20 ++-
branches/release/boost/spirit/home/qi/binary/binary.hpp | 129 +++++++++++++++++++----
branches/release/boost/spirit/home/support/attributes.hpp | 5
branches/release/boost/spirit/home/support/common_terminals.hpp | 6 +
branches/release/boost/spirit/home/support/detail/endian/endian.hpp | 154 +++++++++++++++++++++++++++-
branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp | 2
branches/release/boost/spirit/home/support/detail/lexer/rules.hpp | 20 +++
branches/release/boost/spirit/home/support/extended_variant.hpp | 31 +++++
branches/release/boost/spirit/home/support/iterators/detail/combine_policies.hpp | 162 ++++++++++++++++++++----------
branches/release/boost/spirit/home/support/iterators/multi_pass.hpp | 22 ++--
branches/release/boost/spirit/repository/home/karma/nonterminal/subrule.hpp | 10
branches/release/libs/spirit/doc/index.idx | 20 +++
branches/release/libs/spirit/doc/karma/binary.qbk | 172 +++++++++++++++++++++++++-------
branches/release/libs/spirit/doc/qi/binary.qbk | 88 +++++++++++++---
branches/release/libs/spirit/doc/qi/error_handling.qbk | 2
branches/release/libs/spirit/doc/qi/quick_reference.qbk | 4
branches/release/libs/spirit/doc/spirit2.qbk | 4
branches/release/libs/spirit/doc/what_s_new.qbk | 44 ++++++--
branches/release/libs/spirit/repository/doc/qi/seek.qbk | 32 ++---
branches/release/libs/spirit/repository/doc/spirit2_repository.qbk | 3
branches/release/libs/spirit/repository/example/karma/calc2_ast.hpp | 27 +++-
branches/release/libs/spirit/repository/example/qi/seek.cpp | 46 +++-----
branches/release/libs/spirit/test/Jamfile | 27 ++--
branches/release/libs/spirit/test/karma/binary1.cpp | 20 +++
branches/release/libs/spirit/test/karma/binary2.cpp | 26 ++++
branches/release/libs/spirit/test/karma/binary3.cpp | 40 +++++++
branches/release/libs/spirit/test/qi/binary.cpp | 38 +++++++
branches/release/libs/spirit/test/qi/symbols1.cpp | 10 +
branches/release/libs/spirit/test/qi/test.hpp | 52 +++++++++
42 files changed, 1560 insertions(+), 539 deletions(-)
Modified: branches/release/boost/spirit/home/karma/binary/binary.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/binary/binary.hpp (original)
+++ branches/release/boost/spirit/home/karma/binary/binary.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -27,6 +27,7 @@
#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>
///////////////////////////////////////////////////////////////////////////////
@@ -45,6 +46,19 @@
\
/***/
+#define BOOST_SPIRIT_ENABLE_BINARY_IEEE754(name) \
+ template<> \
+ struct use_terminal<karma::domain, tag::name>: mpl::true_ {}; \
+ \
+ template<typename A0> \
+ struct use_terminal<karma::domain, terminal_ex<tag::name, \
+ fusion::vector1<A0> > >: is_floating_point<A0> {}; \
+ \
+ template<> \
+ struct use_lazy_terminal<karma::domain, tag::name, 1> : mpl::true_ {}; \
+ \
+/***/
+
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
@@ -63,10 +77,16 @@
BOOST_SPIRIT_ENABLE_BINARY(big_qword) // enables big_qword
BOOST_SPIRIT_ENABLE_BINARY(little_qword) // enables little_qword
#endif
-
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(big_bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(little_bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(bin_double)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(big_bin_double)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(little_bin_double)
}}
#undef BOOST_SPIRIT_ENABLE_BINARY
+#undef BOOST_SPIRIT_ENABLE_BINARY_IEEE754
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace karma
@@ -84,6 +104,12 @@
using boost::spirit::big_qword;
using boost::spirit::little_qword;
#endif
+ using boost::spirit::bin_float;
+ using boost::spirit::big_bin_float;
+ using boost::spirit::little_bin_float;
+ using boost::spirit::bin_double;
+ using boost::spirit::big_bin_double;
+ using boost::spirit::little_bin_double;
#endif
using boost::spirit::byte_type;
@@ -98,6 +124,12 @@
using boost::spirit::big_qword_type;
using boost::spirit::little_qword_type;
#endif
+ using boost::spirit::bin_float_type;
+ using boost::spirit::big_bin_float_type;
+ using boost::spirit::little_bin_float_type;
+ using boost::spirit::bin_double_type;
+ using boost::spirit::big_bin_double_type;
+ using boost::spirit::little_bin_double_type;
namespace detail
{
@@ -141,6 +173,26 @@
};
#endif
+ template <int bits>
+ struct floating_point
+ {
+ BOOST_SPIRIT_ASSERT_MSG(
+ bits == 32 || bits == 64,
+ not_supported_binary_size, ());
+ };
+
+ template <>
+ struct floating_point<32>
+ {
+ typedef float type;
+ };
+
+ template <>
+ struct floating_point<64>
+ {
+ typedef double type;
+ };
+
///////////////////////////////////////////////////////////////////////
template <BOOST_SCOPED_ENUM(boost::endian::endianness) bits>
struct what;
@@ -174,14 +226,12 @@
}
///////////////////////////////////////////////////////////////////////////
- template <BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
+ template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct any_binary_generator
- : primitive_generator<any_binary_generator<endian, bits> >
+ : primitive_generator<any_binary_generator<T, endian, bits> >
{
template <typename Context, typename Unused = unused_type>
- struct attribute
- : karma::detail::integer<bits>
- {};
+ struct attribute: T {};
template <
typename OutputIterator, typename Context, typename Delimiter
@@ -195,16 +245,14 @@
// Even if the endian types are not pod's (at least not in the
// definition of C++03) it seems to be safe to assume they are.
// This allows us to treat them as a sequence of consecutive bytes.
- boost::endian::endian<
- endian, typename karma::detail::integer<bits>::type, bits
- > p;
+ boost::endian::endian<endian, typename T::type, bits> p;
#if defined(BOOST_MSVC)
// warning C4244: 'argument' : conversion from 'const int' to 'foo', possible loss of data
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
- typedef typename karma::detail::integer<bits>::type attribute_type;
+ typedef typename T::type attribute_type;
p = traits::extract_from<attribute_type>(attr, context);
#if defined(BOOST_MSVC)
#pragma warning(pop)
@@ -245,9 +293,9 @@
};
///////////////////////////////////////////////////////////////////////////
- template <BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
+ template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct literal_binary_generator
- : primitive_generator<literal_binary_generator<endian, bits> >
+ : primitive_generator<literal_binary_generator<T, endian, bits> >
{
template <typename Context, typename Unused>
struct attribute
@@ -255,15 +303,15 @@
typedef unused_type type;
};
- template <typename T>
- literal_binary_generator(T const& t)
+ template <typename V>
+ literal_binary_generator(V const& v)
{
#if defined(BOOST_MSVC)
// warning C4244: 'argument' : conversion from 'const int' to 'foo', possible loss of data
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
- data_ = t;
+ data_ = v;
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
@@ -296,9 +344,8 @@
return karma::detail::what<endian>::is();
}
- typedef boost::endian::endian<
- endian, typename karma::detail::integer<bits>::type, bits
- > data_type;
+ typedef boost::endian::endian<endian, typename T::type,
+ bits> data_type;
data_type data_;
};
@@ -308,11 +355,11 @@
///////////////////////////////////////////////////////////////////////////
namespace detail
{
- template <BOOST_SCOPED_ENUM(boost::endian::endianness) endian
+ template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian
, int bits>
struct basic_binary
{
- typedef any_binary_generator<endian, bits> result_type;
+ typedef any_binary_generator<T, endian, bits> result_type;
result_type operator()(unused_type, unused_type) const
{
@@ -320,11 +367,11 @@
}
};
- template <typename Modifiers
+ template <typename Modifiers, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct basic_binary_literal
{
- typedef literal_binary_generator<endian, bits> result_type;
+ typedef literal_binary_generator<T, endian, bits> result_type;
template <typename Terminal>
result_type operator()(Terminal const& term, unused_type) const
@@ -337,12 +384,13 @@
#define BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(name, endiantype, bits) \
template <typename Modifiers> \
struct make_primitive<tag::name, Modifiers> \
- : detail::basic_binary<boost::endian::endianness::endiantype, bits> {}; \
+ : detail::basic_binary<detail::integer<bits>, \
+ boost::endian::endianness::endiantype, bits> {}; \
\
template <typename Modifiers, typename A0> \
struct make_primitive<terminal_ex<tag::name, fusion::vector1<A0> > \
, Modifiers> \
- : detail::basic_binary_literal<Modifiers \
+ : detail::basic_binary_literal<Modifiers, detail::integer<bits> \
, boost::endian::endianness::endiantype, bits> {}; \
\
/***/
@@ -362,6 +410,29 @@
#undef BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE
+#define BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(name, endiantype, bits) \
+ template <typename Modifiers> \
+ struct make_primitive<tag::name, Modifiers> \
+ : detail::basic_binary<detail::floating_point<bits>, \
+ boost::endian::endianness::endiantype, bits> {}; \
+ \
+ template <typename Modifiers, typename A0> \
+ struct make_primitive<terminal_ex<tag::name, fusion::vector1<A0> > \
+ , Modifiers> \
+ : detail::basic_binary_literal<Modifiers, detail::floating_point<bits> \
+ , boost::endian::endianness::endiantype, bits> {}; \
+ \
+ /***/
+
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(bin_float, native, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(big_bin_float, big, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(little_bin_float, little, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(bin_double, native, 64)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(big_bin_double, big, 64)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(little_bin_double, little, 64)
+
+#undef BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE
+
}}}
#endif
Modified: branches/release/boost/spirit/home/karma/detail/extract_from.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/extract_from.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/extract_from.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -23,8 +23,8 @@
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
- // This file contains attribute extraction utilities. The utilities
- // provided also accept spirit's unused_type; all no-ops. Compiler
+ // This file contains attribute extraction utilities. The utilities
+ // provided also accept spirit's unused_type; all no-ops. Compiler
// optimization will easily strip these away.
///////////////////////////////////////////////////////////////////////////
@@ -33,13 +33,13 @@
///////////////////////////////////////////////////////////////////////
// extract first and second element of a fusion sequence
template <typename T>
- struct add_const_ref
- : add_reference<typename add_const<T>::type>
+ struct add_const_ref
+ : add_reference<typename add_const<T>::type>
{};
template <typename T, int N>
- struct value_at_c
- : add_const_ref<typename fusion::result_of::value_at_c<T, N>::type>
+ struct value_at_c
+ : add_const_ref<typename fusion::result_of::value_at_c<T, N>::type>
{};
}
@@ -47,7 +47,7 @@
template <typename Attribute, typename Exposed, typename Enable/*= void*/>
struct extract_from_attribute
{
- typedef typename traits::one_element_sequence<Attribute>::type
+ typedef typename traits::one_element_sequence<Attribute>::type
is_one_element_sequence;
typedef typename mpl::eval_if<
@@ -63,7 +63,7 @@
}
// This handles the case where the attribute is a single element fusion
- // sequence. We silently extract the only element and treat it as the
+ // sequence. We silently extract the only element and treat it as the
// attribute to generate output from.
template <typename Context>
static type call(Attribute const& attr, Context& ctx, mpl::true_)
@@ -78,7 +78,7 @@
}
};
- // This handles optional attributes.
+ // This handles optional attributes.
template <typename Attribute, typename Exposed>
struct extract_from_attribute<boost::optional<Attribute>, Exposed>
{
@@ -103,7 +103,7 @@
}
};
- // This handles attributes wrapped inside a boost::ref().
+ // This handles attributes wrapped inside a boost::ref().
template <typename Attribute, typename Exposed>
struct extract_from_attribute<reference_wrapper<Attribute>, Exposed>
{
@@ -120,14 +120,14 @@
template <typename Attribute, typename Exposed, typename Enable>
struct extract_from_container
{
- typedef typename traits::container_value<Attribute const>::type
+ typedef typename traits::container_value<Attribute const>::type
value_type;
- typedef typename is_convertible<value_type, Exposed>::type
+ typedef typename is_convertible<value_type, Exposed>::type
is_convertible_to_value_type;
typedef typename mpl::if_<
mpl::or_<
- is_same<value_type, Exposed>, is_same<Attribute, Exposed> >
+ is_same<value_type, Exposed>, is_same<Attribute, Exposed> >
, Exposed const&, Exposed
>::type type;
@@ -137,7 +137,7 @@
static type call(Attribute const& attr, Context&, mpl::true_, Pred)
{
// return first element from container
- typedef typename traits::container_iterator<Attribute const>::type
+ typedef typename traits::container_iterator<Attribute const>::type
iterator_type;
iterator_type it = traits::begin(attr);
@@ -176,7 +176,7 @@
static type call(Attribute const& attr, Context& ctx)
{
typedef typename mpl::and_<
- traits::is_string<Exposed>, traits::is_string<Attribute>
+ traits::is_string<Exposed>, traits::is_string<Attribute>
>::type handle_strings;
// return first element from container
@@ -208,7 +208,7 @@
return extract_from_attribute<Attribute, Exposed>::call(attr, ctx);
}
- // overload for containers (but not for variants or optionals
+ // overload for containers (but not for variants or optionals
// holding containers)
template <typename Exposed, typename Attribute, typename Context>
inline typename spirit::result_of::extract_from<Exposed, Attribute>::type
@@ -230,7 +230,7 @@
typedef typename mpl::and_<
traits::is_container<Attribute>
, traits::not_is_variant<Attribute>
- , traits::not_is_optional<Attribute>
+ , traits::not_is_optional<Attribute>
>::type is_not_wrapped_container;
return detail::extract_from<Exposed>(attr, ctx
Modified: branches/release/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/pass_container.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -38,17 +38,17 @@
Sequence
, typename traits::is_weak_substitute<Attribute, ValueType>::type
, typename mpl::not_<
- traits::is_weak_substitute<Attribute, ValueType>
+ traits::is_weak_substitute<Attribute, ValueType>
>::type>
{};
- // pass_through_container: utility to check decide whether a provided
- // container attribute needs to be passed through to the current component
+ // pass_through_container: utility to check decide whether a provided
+ // container attribute needs to be passed through to the current component
// or of we need to split the container by passing along instances of its
// value type
- // if the expected attribute of the current component is neither a Fusion
- // sequence nor a container, we will pass through the provided container
+ // if the expected attribute of the current component is neither a Fusion
+ // sequence nor a container, we will pass through the provided container
// only if its value type is not compatible with the component
template <typename Container, typename ValueType, typename Attribute
, typename Sequence, typename Enable = void>
@@ -58,9 +58,9 @@
// Specialization for fusion sequences, in this case we check whether all
// the types in the sequence are convertible to the lhs attribute.
- //
+ //
// We return false if the rhs attribute itself is a fusion sequence, which
- // is compatible with the LHS sequence (we want to pass through this
+ // is compatible with the LHS sequence (we want to pass through this
// attribute without it being split apart).
template <typename Container, typename ValueType, typename Attribute
, typename Sequence = mpl::true_>
@@ -71,7 +71,7 @@
{};
// If the value type of the container is not a Fusion sequence, we pass
- // through the container if each of the elements of the Attribute
+ // through the container if each of the elements of the Attribute
// sequence is compatible with either the container or its value type.
template <typename Container, typename ValueType, typename Attribute
, typename Sequence
@@ -87,7 +87,7 @@
};
// If both, the Attribute and the value type of the provided container
- // are Fusion sequences, we pass the container only if the two
+ // are Fusion sequences, we pass the container only if the two
// sequences are not compatible.
template <typename Container, typename ValueType, typename Attribute
, typename Sequence>
@@ -115,14 +115,14 @@
// Specialization for containers
//
// If the value type of the attribute of the current component is not
- // a Fusion sequence, we have to pass through the provided container if
+ // a Fusion sequence, we have to pass through the provided container if
// both are compatible.
template <typename Container, typename ValueType, typename Attribute
, typename Sequence, typename AttributeValueType
, bool IsSequence = fusion::traits::is_sequence<AttributeValueType>::value>
struct pass_through_container_container
: mpl::or_<
- traits::is_weak_substitute<Container, Attribute>
+ traits::is_weak_substitute<Container, Attribute>
, traits::is_weak_substitute<Container, AttributeValueType> >
{};
@@ -148,16 +148,16 @@
// Specialization for exposed optional attributes
//
- // If the type embedded in the exposed optional is not a Fusion
+ // If the type embedded in the exposed optional is not a Fusion
// sequence we pass through the container attribute if it is compatible
- // either to the optionals embedded type or to the containers value
+ // either to the optionals embedded type or to the containers value
// type.
template <typename Container, typename ValueType, typename Attribute
, typename Sequence
, bool IsSequence = fusion::traits::is_sequence<Attribute>::value>
struct pass_through_container_optional
: mpl::or_<
- traits::is_weak_substitute<Container, Attribute>
+ traits::is_weak_substitute<Container, Attribute>
, traits::is_weak_substitute<ValueType, Attribute> >
{};
@@ -175,7 +175,7 @@
template <typename Container, typename ValueType, typename Attribute
, typename Sequence>
struct pass_through_container
- : pass_through_container_base<Container, ValueType, Attribute, Sequence>
+ : pass_through_container_base<Container, ValueType, Attribute, Sequence>
{};
// Handle optional attributes
@@ -184,7 +184,7 @@
struct pass_through_container<
Container, ValueType, boost::optional<Attribute>, Sequence>
: pass_through_container_optional<
- Container, ValueType, Attribute, Sequence>
+ Container, ValueType, Attribute, Sequence>
{};
// If both, the containers value type and the exposed attribute type are
@@ -199,8 +199,8 @@
{};
// Specialization for exposed variant attributes
- //
- // We pass through the container attribute if at least one of the embedded
+ //
+ // We pass through the container attribute if at least one of the embedded
// types in the variant requires to pass through the attribute
#define BOOST_SPIRIT_PASS_THROUGH_CONTAINER(z, N, _) \
@@ -252,7 +252,7 @@
typedef typename F::context_type context_type;
pass_container(F const& f, Iterator begin, Iterator end)
- : f(f), iter(begin), end(end)
+ : f(f), iter(begin), end(end)
{}
bool is_at_end() const
@@ -271,7 +271,7 @@
bool dispatch_container(Component const& component, mpl::false_) const
{
// get the next value to generate from container
- if (!is_at_end() && !f(component, traits::deref(iter)))
+ if (!is_at_end() && !f(component, traits::deref(iter)))
{
// needs to return false as long as everything is ok
traits::next(iter);
@@ -282,8 +282,8 @@
return true;
}
- // this is for the case when the current element is able to handle an
- // attribute which is a container itself, this element will push its
+ // this is for the case when the current element is able to handle an
+ // attribute which is a container itself, this element will push its
// data directly into the attribute container
template <typename Component>
bool dispatch_container(Component const& component, mpl::true_) const
@@ -292,7 +292,7 @@
}
///////////////////////////////////////////////////////////////////////
- // this is for the case when the current element doesn't expect an
+ // this is for the case when the current element doesn't expect an
// attribute
template <typename Component>
bool dispatch_attribute(Component const& component, mpl::false_) const
@@ -305,15 +305,15 @@
bool dispatch_attribute(Component const& component, mpl::true_) const
{
typedef typename traits::container_value<Attr>::type value_type;
- typedef typename
+ typedef typename
traits::attribute_of<Component, context_type>::type
lhs_attribute;
// this predicate detects, whether the value type of the container
- // attribute is a substitute for the attribute of the current
- // element
+ // attribute is a substitute for the attribute of the current
+ // element
typedef mpl::and_<
- traits::handles_container<Component, Attr, context_type>
+ traits::handles_container<Component, Attr, context_type>
, traits::pass_through_container<
Attr, value_type, lhs_attribute, Sequence, karma::domain>
> predicate;
@@ -328,7 +328,7 @@
{
// we need to dispatch depending on the type of the attribute
// of the current element (component). If this is has no attribute
- // we shouldn't use an element of the container but unused_type
+ // we shouldn't use an element of the container but unused_type
// instead
typedef traits::not_is_unused<
typename traits::attribute_of<Component, context_type>::type
Modified: branches/release/boost/spirit/home/karma/directive/center_alignment.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/center_alignment.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/center_alignment.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -53,20 +53,20 @@
// enables *lazy* center(d)[g], where d provides a generator
template <>
- struct use_lazy_directive<karma::domain, tag::center, 1>
+ struct use_lazy_directive<karma::domain, tag::center, 1>
: mpl::true_ {};
- // enables center(w, d)[g], where d is a generator and w is a maximum
+ // enables center(w, d)[g], where d is a generator and w is a maximum
// width
template <typename Width, typename Padding>
struct use_directive<karma::domain
, terminal_ex<tag::center, fusion::vector2<Width, Padding> > >
: spirit::traits::matches<karma::domain, Padding> {};
- // enables *lazy* center(w, d)[g], where d provides a generator and w is
+ // enables *lazy* center(w, d)[g], where d provides a generator and w is
// a maximum width
template <>
- struct use_lazy_directive<karma::domain, tag::center, 2>
+ struct use_lazy_directive<karma::domain, tag::center, 2>
: mpl::true_ {};
}}
@@ -82,15 +82,15 @@
namespace detail
{
///////////////////////////////////////////////////////////////////////
- // The center_generate template function is used for all the
- // different flavors of the center[] directive.
+ // The center_generate template function is used for all the
+ // different flavors of the center[] directive.
///////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Context, typename Delimiter,
+ template <typename OutputIterator, typename Context, typename Delimiter,
typename Attribute, typename Embedded, typename Padding>
- inline static bool
- center_generate(OutputIterator& sink, Context& ctx,
- Delimiter const& d, Attribute const& attr, Embedded const& e,
- unsigned int const width, Padding const& p)
+ inline static bool
+ center_generate(OutputIterator& sink, Context& ctx,
+ Delimiter const& d, Attribute const& attr, Embedded const& e,
+ unsigned int const width, Padding const& p)
{
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
e; // suppresses warning: C4100: 'e' : unreferenced formal parameter
@@ -99,7 +99,7 @@
detail::enable_buffering<OutputIterator> buffering(sink, width);
bool r = false;
- // first generate the embedded output
+ // first generate the embedded output
{
detail::disable_counting<OutputIterator> nocounting(sink);
r = e.generate(sink, ctx, d, attr);
@@ -111,7 +111,7 @@
detail::enable_counting<OutputIterator> counting(sink);
std::size_t const pre = width - (buffering.buffer_size() + width)/2;
- while (r && counting.count() < pre)
+ while (r && counting.count() < pre)
r = p.generate(sink, ctx, unused, unused);
if (r) {
@@ -119,7 +119,7 @@
buffering.buffer_copy();
// generate the right padding
- while (r && counting.count() < width)
+ while (r && counting.count() < width)
r = p.generate(sink, ctx, unused, unused);
}
return r;
@@ -185,12 +185,12 @@
typedef mpl::int_<
generator_properties::countingbuffer |
- subject_type::properties::value | padding_type::properties::value
+ subject_type::properties::value | padding_type::properties::value
> properties;
template <typename Context, typename Iterator>
struct attribute
- : traits::attribute_of<Subject, Context, Iterator>::type
+ : traits::attribute_of<Subject, Context, Iterator>
{};
padding_center_alignment(Subject const& subject, Padding const& padding
Modified: branches/release/boost/spirit/home/karma/directive/duplicate.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/directive/duplicate.hpp (original)
+++ branches/release/boost/spirit/home/karma/directive/duplicate.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -51,29 +51,29 @@
template <typename T
, bool IsSequence = fusion::traits::is_sequence<T>::value>
struct attribute_count
- : fusion::result_of::size<T>
+ : fusion::result_of::size<T>
{};
template <>
- struct attribute_count<unused_type, false>
- : mpl::int_<0>
+ struct attribute_count<unused_type, false>
+ : mpl::int_<0>
{};
template <typename T>
- struct attribute_count<T, false>
- : mpl::int_<1>
+ struct attribute_count<T, false>
+ : mpl::int_<1>
{};
///////////////////////////////////////////////////////////////////////
template <typename T
, bool IsSequence = fusion::traits::is_sequence<T>::value>
- struct first_attribute_of_subject
- : fusion::result_of::at_c<T, 0>
+ struct first_attribute_of_subject
+ : fusion::result_of::at_c<T, 0>
{};
template <typename T>
- struct first_attribute_of_subject<T, false>
- : mpl::identity<T>
+ struct first_attribute_of_subject<T, false>
+ : mpl::identity<T>
{};
template <typename T, typename Context, typename Iterator>
@@ -93,20 +93,20 @@
static type call(T const& t)
{
- return fusion::make_cons(cref(t)
+ return fusion::make_cons(boost::cref(t)
, duplicate_sequence_attribute<Attribute, T, N-1>::call(t));
}
};
template <typename Attribute, typename T>
- struct duplicate_sequence_attribute<Attribute, T, 1>
+ struct duplicate_sequence_attribute<Attribute, T, 1>
{
typedef typename fusion::result_of::make_cons<
reference_wrapper<T const> >::type type;
static type call(T const& t)
{
- return fusion::make_cons(cref(t));
+ return fusion::make_cons(boost::cref(t));
}
};
@@ -130,7 +130,7 @@
};
template <typename Attribute, typename T>
- struct duplicate_attribute<Attribute, T, 0, false>
+ struct duplicate_attribute<Attribute, T, 0, false>
{
typedef unused_type type;
@@ -155,12 +155,12 @@
template <typename Attribute, typename T>
inline typename detail::duplicate_attribute<Attribute, T>::type
duplicate_attribute(T const& t)
- {
+ {
return detail::duplicate_attribute<Attribute, T>::call(t);
}
///////////////////////////////////////////////////////////////////////////
- // duplicate_directive duplicate its attribute for all elements of the
+ // duplicate_directive duplicate its attribute for all elements of the
// subject generator without generating anything itself
///////////////////////////////////////////////////////////////////////////
template <typename Subject>
@@ -182,7 +182,7 @@
bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
, Attribute const& attr) const
{
- typedef typename traits::attribute_of<Subject, Context>::type
+ typedef typename traits::attribute_of<Subject, Context>::type
subject_attr_type;
return subject.generate(sink, ctx, d
, duplicate_attribute<subject_attr_type>(attr));
Modified: branches/release/boost/spirit/home/karma/nonterminal/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/rule.hpp (original)
+++ branches/release/boost/spirit/home/karma/nonterminal/rule.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -436,7 +436,7 @@
typename attribute_of<
karma::rule<IteratorA, T1, T2, T3, T4>
, Context, IteratorB
- >::type, Attribute>
+ >::type, Attribute>
{};
}}}
Modified: branches/release/boost/spirit/home/karma/operator/alternative.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/alternative.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/alternative.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -26,6 +26,7 @@
#include <boost/fusion/include/for_each.hpp>
#include <boost/mpl/accumulate.hpp>
#include <boost/mpl/bitor.hpp>
+#include <boost/config.hpp>
namespace boost { namespace spirit
{
@@ -61,9 +62,11 @@
};
// never called, but needed for decltype-based result_of (C++0x)
+#ifndef BOOST_NO_RVALUE_REFERENCES
template <typename Element>
typename result<element_properties(Element)>::type
- operator()(Element&) const;
+ operator()(Element&&) const;
+#endif
};
typedef typename mpl::accumulate<
Modified: branches/release/boost/spirit/home/karma/operator/sequence.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/operator/sequence.hpp (original)
+++ branches/release/boost/spirit/home/karma/operator/sequence.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -37,6 +37,7 @@
#include <boost/mpl/not.hpp>
#include <boost/fusion/include/transform.hpp>
#include <boost/mpl/accumulate.hpp>
+#include <boost/config.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit
@@ -72,9 +73,11 @@
};
// never called, but needed for decltype-based result_of (C++0x)
+#ifndef BOOST_NO_RVALUE_REFERENCES
template <typename Element>
typename result<element_properties(Element)>::type
- operator()(Element&) const;
+ operator()(Element&&) const;
+#endif
};
typedef typename mpl::accumulate<
@@ -135,14 +138,14 @@
OutputIterator, Context, Delimiter> fail_function;
typedef traits::attribute_not_unused<Context> predicate;
- // wrap the attribute in a tuple if it is not a tuple or if the
+ // wrap the attribute in a tuple if it is not a tuple or if the
// attribute of this sequence is a single element tuple
typedef typename attribute<Context>::type_ attr_type_;
typename traits::wrap_if_not_tuple<Attribute
, typename mpl::and_<
traits::one_element_sequence<attr_type_>
, mpl::not_<traits::one_element_sequence<Attribute> >
- >::type
+ >::type
>::type attr(attr_);
// return false if *any* of the generators fail
@@ -152,12 +155,12 @@
typedef typename traits::attribute_size<Attribute>::type size_type;
// fail generating if sequences have not the same (logical) length
- return !r && (!Strict::value ||
- // This ignores container element count (which is not good),
- // but allows valid attributes to succeed. This will lead to
+ return !r && (!Strict::value ||
+ // This ignores container element count (which is not good),
+ // but allows valid attributes to succeed. This will lead to
// false positives (failing generators, even if they shouldn't)
- // if the embedded component is restricting the number of
- // container elements it consumes (i.e. repeat). This solution
+ // if the embedded component is restricting the number of
+ // container elements it consumes (i.e. repeat). This solution
// is not optimal but much better than letting _all_ repetitive
// components fail.
Pred1::value ||
@@ -181,17 +184,17 @@
typename add_const<Attribute>::type
>::type iterator_type;
- typedef
- typename traits::make_indirect_iterator<iterator_type>::type
+ typedef
+ typename traits::make_indirect_iterator<iterator_type>::type
indirect_iterator_type;
typedef detail::pass_container<
- fail_function, Attribute, indirect_iterator_type, mpl::true_>
+ fail_function, Attribute, indirect_iterator_type, mpl::true_>
pass_container;
iterator_type begin = traits::begin(attr_);
iterator_type end = traits::end(attr_);
- pass_container pass(fail_function(sink, ctx, d),
+ pass_container pass(fail_function(sink, ctx, d),
indirect_iterator_type(begin), indirect_iterator_type(end));
bool r = fusion::any(elements, pass);
@@ -207,11 +210,11 @@
bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
, Attribute const& attr) const
{
- typedef typename traits::is_container<Attribute>::type
+ typedef typename traits::is_container<Attribute>::type
is_container;
typedef typename attribute<Context>::type_ attr_type_;
- typedef typename traits::one_element_sequence<attr_type_>::type
+ typedef typename traits::one_element_sequence<attr_type_>::type
is_one_element_sequence;
return generate_impl(sink, ctx, d, attr, is_container()
@@ -231,7 +234,7 @@
};
template <typename Elements>
- struct sequence
+ struct sequence
: base_sequence<Elements, mpl::false_, sequence<Elements> >
{
typedef base_sequence<Elements, mpl::false_, sequence> base_sequence_;
@@ -241,10 +244,10 @@
};
template <typename Elements>
- struct strict_sequence
+ struct strict_sequence
: base_sequence<Elements, mpl::true_, strict_sequence<Elements> >
{
- typedef base_sequence<Elements, mpl::true_, strict_sequence>
+ typedef base_sequence<Elements, mpl::true_, strict_sequence>
base_sequence_;
strict_sequence(Elements const& subject)
@@ -257,12 +260,12 @@
namespace detail
{
template <typename Elements, bool strict_mode = false>
- struct make_sequence
+ struct make_sequence
: make_nary_composite<Elements, sequence>
{};
template <typename Elements>
- struct make_sequence<Elements, true>
+ struct make_sequence<Elements, true>
: make_nary_composite<Elements, strict_sequence>
{};
}
@@ -280,7 +283,7 @@
{
typedef iterator_range<detail::indirect_iterator<Iterator> > type;
};
-}}}
+}}}
namespace boost { namespace spirit { namespace traits
{
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,7 +1,7 @@
// Copyright (c) 2008-2009 Ben Hanson
// Copyright (c) 2008-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_LEXERTL_GENERATE_CPP_FEB_10_2008_0855PM)
@@ -22,33 +22,83 @@
#include <boost/lexical_cast.hpp>
///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace lex { namespace lexertl
+namespace boost { namespace spirit { namespace lex { namespace lexertl
{
namespace detail
{
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename CharT>
+ struct string_lit;
+
+ template <>
+ struct string_lit<char>
+ {
+ static char get(char c) { return c; }
+ static std::string get(char const* str = "") { return str; }
+ };
+
+ template <>
+ struct string_lit<wchar_t>
+ {
+ static wchar_t get(char c)
+ {
+ typedef std::ctype<wchar_t> ctype_t;
+ return std::use_facet<ctype_t>(std::locale()).widen(c);
+ }
+ static std::basic_string<wchar_t> get(char const* source = "")
+ {
+ using namespace std; // some systems have size_t in ns std
+ size_t len = strlen(source);
+ std::auto_ptr<wchar_t> result (new wchar_t[len+1]);
+ result.get()[len] = '\0';
+
+ // working with wide character streams is supported only if the
+ // platform provides the std::ctype<wchar_t> facet
+ BOOST_ASSERT(std::has_facet<std::ctype<wchar_t> >(std::locale()));
+
+ std::use_facet<std::ctype<wchar_t> >(std::locale())
+ .widen(source, source + len, result.get());
+ return result.get();
+ }
+ };
+
+ template <typename Char>
+ inline Char L(char c)
+ {
+ return string_lit<Char>::get(c);
+ }
+
+ template <typename Char>
+ inline std::basic_string<Char> L(char const* c = "")
+ {
+ return string_lit<Char>::get(c);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
inline bool
- generate_delimiter(std::ostream &os_)
+ generate_delimiter(std::basic_ostream<Char> &os_)
{
- os_ << std::string(80, '/') << "\n";
+ os_ << std::basic_string<Char>(80, '/') << "\n";
return os_.good();
}
///////////////////////////////////////////////////////////////////////////
- // Generate a table of the names of the used lexer states, which is a bit
- // tricky, because the table stored with the rules is sorted based on the
+ // Generate a table of the names of the used lexer states, which is a bit
+ // tricky, because the table stored with the rules is sorted based on the
// names, but we need it sorted using the state ids.
template <typename Char>
- inline bool
+ inline bool
generate_cpp_state_info (boost::lexer::basic_rules<Char> const& rules_
- , std::ostream &os_, char const* name_suffix)
+ , std::basic_ostream<Char> &os_, Char const* name_suffix)
{
- // we need to re-sort the state names in ascending order of the state
+ // we need to re-sort the state names in ascending order of the state
// ids, filling possible gaps in between later
- typedef typename
+ typedef typename
boost::lexer::basic_rules<Char>::string_size_t_map::const_iterator
state_iterator;
- typedef std::map<std::size_t, char const*> reverse_state_map_type;
+ typedef std::map<std::size_t, Char const*> reverse_state_map_type;
reverse_state_map_type reverse_state_map;
state_iterator send = rules_.statemap().end();
@@ -60,7 +110,8 @@
generate_delimiter(os_);
os_ << "// this table defines the names of the lexer states\n";
- os_ << "char const* const lexer_state_names"
+ os_ << boost::lexer::detail::strings<Char>::char_name()
+ << " const* const lexer_state_names"
<< (name_suffix[0] ? "_" : "") << name_suffix
<< "[" << rules_.statemap().size() << "] = \n{\n";
@@ -73,7 +124,9 @@
{
os_ << " 0, // \"<undefined state>\"\n";
}
- os_ << " \"" << (*rit).second << "\"";
+ os_ << " "
+ << boost::lexer::detail::strings<Char>::char_prefix()
+ << "\"" << (*rit).second << "\"";
if (++rit != rend)
os_ << ",\n";
else
@@ -83,17 +136,18 @@
generate_delimiter(os_);
os_ << "// this variable defines the number of lexer states\n";
- os_ << "std::size_t const lexer_state_count"
+ os_ << "std::size_t const lexer_state_count"
<< (name_suffix[0] ? "_" : "") << name_suffix
<< " = " << rules_.statemap().size() << ";\n\n";
return os_.good();
}
- inline bool
- generate_cpp_state_table (std::ostream &os_, char const* name_suffix
- , bool bol, bool eol)
+ template <typename Char>
+ inline bool
+ generate_cpp_state_table (std::basic_ostream<Char> &os_
+ , Char const* name_suffix, bool bol, bool eol)
{
- std::string suffix(name_suffix[0] ? "_" : "");
+ std::basic_string<Char> suffix(L<Char>(name_suffix[0] ? "_" : ""));
suffix += name_suffix;
generate_delimiter(os_);
@@ -102,7 +156,8 @@
os_ << " // version number and feature-set of compatible static lexer engine\n";
os_ << " enum\n";
os_ << " {\n static_version = "
- << boost::lexical_cast<std::string>(SPIRIT_STATIC_LEXER_VERSION) << ",\n";
+ << boost::lexical_cast<std::basic_string<Char> >(SPIRIT_STATIC_LEXER_VERSION)
+ << ",\n";
os_ << " supports_bol = " << std::boolalpha << bol << ",\n";
os_ << " supports_eol = " << std::boolalpha << eol << "\n";
os_ << " };\n\n";
@@ -110,13 +165,14 @@
os_ << " static std::size_t state_count()\n";
os_ << " {\n return lexer_state_count" << suffix << "; \n }\n\n";
os_ << " // return the name of the lexer state as given by 'idx'\n";
- os_ << " static char const* state_name(std::size_t idx)\n";
+ os_ << " static " << boost::lexer::detail::strings<Char>::char_name()
+ << " const* state_name(std::size_t idx)\n";
os_ << " {\n return lexer_state_names" << suffix << "[idx]; \n }\n\n";
os_ << " // return the next matched token\n";
os_ << " template<typename Iterator>\n";
os_ << " static std::size_t next(std::size_t &start_state_, bool& bol_\n";
os_ << " , Iterator &start_token_, Iterator const& end_, std::size_t& unique_id_)\n";
- os_ << " {\n return next_token" << suffix
+ os_ << " {\n return next_token" << suffix
<< "(start_state_, bol_, start_token_, end_, unique_id_);\n }\n";
os_ << "};\n\n";
return os_.good();
@@ -125,8 +181,8 @@
///////////////////////////////////////////////////////////////////////////
// generate function body based on traversing the DFA tables
template <typename Char>
- bool generate_function_body_dfa(std::ostream & os_
- , boost::lexer::basic_state_machine<Char> const &sm_)
+ bool generate_function_body_dfa(std::basic_ostream<Char>& os_
+ , boost::lexer::basic_state_machine<Char> const &sm_)
{
std::size_t const dfas_ = sm_.data()._dfa->size();
std::size_t const lookups_ = sm_.data()._lookup->front()->size();
@@ -147,7 +203,7 @@
std::size_t const* lookup_ = &sm_.data()._lookup[state_]->front();
std::size_t const* dfa_ = &sm_.data()._dfa[state_]->front();
- os_ << " static std::size_t const lookup" << state_
+ os_ << " static std::size_t const lookup" << state_
<< "_[" << lookups_ << "] = {\n ";
for (/**/; i_ < count_; ++i_)
{
@@ -203,7 +259,7 @@
std::size_t count_ = sm_.data()._dfa_alphabet.size();
std::size_t i_ = 1;
- os_ << " static std::size_t const* lookup_arr_[" << count_
+ os_ << " static std::size_t const* lookup_arr_[" << count_
<< "] = { lookup0_";
for (i_ = 1; i_ < count_; ++i_)
{
@@ -211,7 +267,7 @@
}
os_ << " };\n";
- os_ << " static std::size_t const dfa_alphabet_arr_["
+ os_ << " static std::size_t const dfa_alphabet_arr_["
<< count_ << "] = { ";
os_ << sm_.data()._dfa_alphabet.front ();
for (i_ = 1; i_ < count_; ++i_)
@@ -220,7 +276,7 @@
}
os_ << " };\n";
- os_ << " static std::size_t const* dfa_arr_[" << count_
+ os_ << " static std::size_t const* dfa_arr_[" << count_
<< "] = { ";
os_ << "dfa0_";
for (i_ = 1; i_ < count_; ++i_)
@@ -255,9 +311,9 @@
}
os_ << " };\n";
- os_ << " static std::size_t const dfa_alphabet_ = "
+ os_ << " static std::size_t const dfa_alphabet_ = "
<< sm_.data()._dfa_alphabet.front () << ";\n";
- os_ << " static std::size_t const dfa_["
+ os_ << " static std::size_t const dfa_["
<< sm_.data()._dfa[0]->size () << "] = {\n ";
count_ = sm_.data()._dfa[0]->size () / 8;
for (i_ = 0; i_ < count_; ++i_)
@@ -534,10 +590,10 @@
///////////////////////////////////////////////////////////////////////////
template <typename Char>
- inline std::string get_charlit(Char ch)
+ inline std::basic_string<Char> get_charlit(Char ch)
{
std::basic_string<Char> result;
- boost::lexer::basic_string_token<Char>::escape_char (ch, result);
+ boost::lexer::basic_string_token<Char>::escape_char(ch, result);
return result;
}
@@ -573,8 +629,8 @@
///////////////////////////////////////////////////////////////////////////
template <typename Char>
- bool generate_function_body_switch(std::ostream & os_
- , boost::lexer::basic_state_machine<Char> const &sm_)
+ bool generate_function_body_switch(std::basic_ostream<Char> & os_
+ , boost::lexer::basic_state_machine<Char> const &sm_)
{
typedef typename boost::lexer::basic_state_machine<Char>::iterator
iterator_type;
@@ -622,7 +678,7 @@
os_ << " Iterator end_token_ = start_token_;\n";
os_ << '\n';
- os_ << " " << ((lookups_ == 256) ? "char" : "wchar_t")
+ os_ << " " << ((lookups_ == 256) ? "char" : "wchar_t")
<< " ch_ = 0;\n\n";
if (dfas_ > 1)
@@ -679,7 +735,7 @@
if (transitions_) os_ << '\n';
}
- if (t_ < transitions_ ||
+ if (t_ < transitions_ ||
iter_->bol_index != boost::lexer::npos ||
iter_->eol_index != boost::lexer::npos)
{
@@ -687,12 +743,12 @@
os_ << " ch_ = *curr_;\n";
if (iter_->bol_index != boost::lexer::npos)
{
- os_ << "\n if (bol) goto state" << dfa_ << '_'
+ os_ << "\n if (bol) goto state" << dfa_ << '_'
<< iter_->bol_index << ";\n";
}
if (iter_->eol_index != boost::lexer::npos)
{
- os_ << "\n if (ch_ == '\n') goto state" << dfa_
+ os_ << "\n if (ch_ == '\n') goto state" << dfa_
<< '_' << iter_->eol_index << ";\n";
}
os_ << " ++curr_;\n";
@@ -700,10 +756,10 @@
for (/**/; t_ < transitions_; ++t_)
{
- char const *ptr_ = iter_->token._charset.c_str();
- char const *end_ = ptr_ + iter_->token._charset.size();
- char start_char_ = 0;
- char curr_char_ = 0;
+ Char const *ptr_ = iter_->token._charset.c_str();
+ Char const *end_ = ptr_ + iter_->token._charset.size();
+ Char start_char_ = 0;
+ Char curr_char_ = 0;
bool range_ = false;
bool first_char_ = true;
@@ -727,7 +783,7 @@
{
os_ << ((iter_->token._negated) ? " && " : " || ");
}
- else
+ else
{
first_char_ = false;
}
@@ -738,20 +794,20 @@
os_ << "!";
}
os_ << "(ch_ >= '" << get_charlit(start_char_)
- << "' && ch_ <= '"
+ << "' && ch_ <= '"
<< get_charlit(curr_char_) << "')";
range_ = false;
}
else
{
- os_ << "ch_ "
+ os_ << "ch_ "
<< ((iter_->token._negated) ? "!=" : "==")
<< " '" << get_charlit(curr_char_) << "'";
}
}
}
- os_ << ") goto state" << dfa_ << '_' << iter_->goto_state
+ os_ << ") goto state" << dfa_ << '_' << iter_->goto_state
<< ";\n";
++iter_;
}
@@ -818,10 +874,11 @@
///////////////////////////////////////////////////////////////////////////
// Generate a tokenizer for the given state machine.
template <typename Char, typename F>
- inline bool
+ inline bool
generate_cpp (boost::lexer::basic_state_machine<Char> const& sm_
, boost::lexer::basic_rules<Char> const& rules_
- , std::ostream &os_, char const* name_suffix, F generate_function_body)
+ , std::basic_ostream<Char> &os_, Char const* name_suffix
+ , F generate_function_body)
{
if (sm_.data()._lookup->empty())
return false;
@@ -838,14 +895,15 @@
"http://www.boost.org/LICENSE_1_0.txt)\n\n";
os_ << "// Auto-generated by boost::lexer, do not edit\n\n";
- std::string guard(name_suffix);
- guard += name_suffix[0] ? "_" : "";
- guard += __DATE__ "_" __TIME__;
- std::string::size_type p = guard.find_first_of(": ");
- while (std::string::npos != p)
+ std::basic_string<Char> guard(name_suffix);
+ guard += L<Char>(name_suffix[0] ? "_" : "");
+ guard += L<Char>(__DATE__ "_" __TIME__);
+ typename std::basic_string<Char>::size_type p =
+ guard.find_first_of(L<Char>(": "));
+ while (std::string::npos != p)
{
- guard.replace(p, 1, "_");
- p = guard.find_first_of(": ", p);
+ guard.replace(p, 1, L<Char>("_"));
+ p = guard.find_first_of(L<Char>(": "), p);
}
boost::to_upper(guard);
@@ -868,14 +926,14 @@
generate_delimiter(os_);
os_ << "// this function returns the next matched token\n";
os_ << "template<typename Iterator>\n";
- os_ << "std::size_t next_token" << (name_suffix[0] ? "_" : "")
+ os_ << "std::size_t next_token" << (name_suffix[0] ? "_" : "")
<< name_suffix << " (";
if (dfas_ > 1)
{
os_ << "std::size_t& start_state_, ";
}
- else
+ else
{
os_ << "std::size_t& /*start_state_*/, ";
}
@@ -883,7 +941,7 @@
{
os_ << "bool& bol_, ";
}
- else
+ else
{
os_ << "bool& /*bol_*/, ";
}
@@ -896,7 +954,7 @@
return false;
os_ << "}\n\n";
- if (!generate_cpp_state_table(os_, name_suffix
+ if (!generate_cpp_state_table<Char>(os_, name_suffix
, sm_.data()._seen_BOL_assertion, sm_.data()._seen_EOL_assertion))
{
return false;
@@ -913,9 +971,10 @@
///////////////////////////////////////////////////////////////////////////
template <typename Lexer, typename F>
- inline bool
- generate_static(Lexer const& lexer, std::ostream& os
- , char const* name_suffix, F f)
+ inline bool
+ generate_static(Lexer const& lexer
+ , std::basic_ostream<typename Lexer::char_type>& os
+ , typename Lexer::char_type const* name_suffix, F f)
{
if (!lexer.init_dfa(true)) // always minimize DFA for static lexers
return false;
@@ -924,12 +983,14 @@
}
///////////////////////////////////////////////////////////////////////////
- // deprecated function, will be removed in the future (this has been
+ // deprecated function, will be removed in the future (this has been
// replaced by the function generate_static_dfa - see below).
template <typename Lexer>
- inline bool
- generate_static(Lexer const& lexer, std::ostream& os
- , char const* name_suffix = "")
+ inline bool
+ generate_static(Lexer const& lexer
+ , std::basic_ostream<typename Lexer::char_type>& os
+ , typename Lexer::char_type const* name_suffix =
+ detail::L<typename Lexer::char_type>())
{
return generate_static(lexer, os, name_suffix
, &detail::generate_function_body_dfa<typename Lexer::char_type>);
@@ -937,9 +998,11 @@
///////////////////////////////////////////////////////////////////////////
template <typename Lexer>
- inline bool
- generate_static_dfa(Lexer const& lexer, std::ostream& os
- , char const* name_suffix = "")
+ inline bool
+ generate_static_dfa(Lexer const& lexer
+ , std::basic_ostream<typename Lexer::char_type>& os
+ , typename Lexer::char_type const* name_suffix =
+ detail::L<typename Lexer::char_type>())
{
return generate_static(lexer, os, name_suffix
, &detail::generate_function_body_dfa<typename Lexer::char_type>);
@@ -947,9 +1010,11 @@
///////////////////////////////////////////////////////////////////////////
template <typename Lexer>
- inline bool
- generate_static_switch(Lexer const& lexer, std::ostream& os
- , char const* name_suffix = "")
+ inline bool
+ generate_static_switch(Lexer const& lexer
+ , std::basic_ostream<typename Lexer::char_type>& os
+ , typename Lexer::char_type const* name_suffix =
+ detail::L<typename Lexer::char_type>())
{
return generate_static(lexer, os, name_suffix
, &detail::generate_function_body_switch<typename Lexer::char_type>);
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_LEXER_MAR_17_2007_0139PM)
@@ -28,13 +28,13 @@
#include <boost/foreach.hpp>
namespace boost { namespace spirit { namespace lex { namespace lexertl
-{
+{
///////////////////////////////////////////////////////////////////////////
namespace detail
{
///////////////////////////////////////////////////////////////////////
// The must_escape function checks if the given character value needs
- // to be preceded by a backslash character to disable its special
+ // to be preceded by a backslash character to disable its special
// meaning in the context of a regular expression
///////////////////////////////////////////////////////////////////////
template <typename Char>
@@ -60,15 +60,15 @@
}
///////////////////////////////////////////////////////////////////////
- // The escape function returns the string representation of the given
- // character value, possibly escaped with a backslash character, to
+ // The escape function returns the string representation of the given
+ // character value, possibly escaped with a backslash character, to
// allow it being safely used in a regular expression definition.
///////////////////////////////////////////////////////////////////////
template <typename Char>
- inline std::basic_string<Char> escape(Char ch)
- {
+ inline std::basic_string<Char> escape(Char ch)
+ {
std::basic_string<Char> result(1, ch);
- if (detail::must_escape(ch))
+ if (detail::must_escape(ch))
{
typedef typename std::basic_string<Char>::size_type size_type;
result.insert((size_type)0, 1, '\\');
@@ -77,7 +77,7 @@
}
///////////////////////////////////////////////////////////////////////
- //
+ //
///////////////////////////////////////////////////////////////////////
inline boost::lexer::regex_flags map_flags(unsigned int flags)
{
@@ -93,31 +93,33 @@
///////////////////////////////////////////////////////////////////////////
template <typename Lexer, typename F>
- bool generate_static(Lexer const&, std::ostream&, char const*, F);
+ bool generate_static(Lexer const&
+ , std::basic_ostream<typename Lexer::char_type>&
+ , typename Lexer::char_type const*, F);
///////////////////////////////////////////////////////////////////////////
//
- // Every lexer type to be used as a lexer for Spirit has to conform to
+ // Every lexer type to be used as a lexer for Spirit has to conform to
// the following public interface:
//
- // typedefs:
+ // typedefs:
// iterator_type The type of the iterator exposed by this lexer.
- // token_type The type of the tokens returned from the exposed
+ // token_type The type of the tokens returned from the exposed
// iterators.
//
// functions:
// default constructor
- // Since lexers are instantiated as base classes
- // only it might be a good idea to make this
+ // Since lexers are instantiated as base classes
+ // only it might be a good idea to make this
// constructor protected.
// begin, end Return a pair of iterators, when dereferenced
- // returning the sequence of tokens recognized in
- // the input stream given as the parameters to the
+ // returning the sequence of tokens recognized in
+ // the input stream given as the parameters to the
// begin() function.
- // add_token Should add the definition of a token to be
+ // add_token Should add the definition of a token to be
// recognized by this lexer.
// clear Should delete all current token definitions
- // associated with the given state of this lexer
+ // associated with the given state of this lexer
// object.
//
// template parameters:
@@ -126,25 +128,25 @@
// Token The type of the tokens to be returned from the
// exposed token iterator.
// Functor The type of the InputPolicy to use to instantiate
- // the multi_pass iterator type to be used as the
+ // the multi_pass iterator type to be used as the
// token iterator (returned from begin()/end()).
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
- // The lexer class is a implementation of a Spirit.Lex lexer on
- // top of Ben Hanson's lexertl library as outlined above (For more
+ // The lexer class is a implementation of a Spirit.Lex lexer on
+ // top of Ben Hanson's lexertl library as outlined above (For more
// information about lexertl go here: http://www.benhanson.net/lexertl.html).
//
- // This class is supposed to be used as the first and only template
+ // This class is supposed to be used as the first and only template
// parameter while instantiating instances of a lex::lexer class.
//
///////////////////////////////////////////////////////////////////////////
template <typename Token = token<>
, typename Iterator = typename Token::iterator_type
, typename Functor = functor<Token, lexertl::detail::data, Iterator> >
- class lexer
+ class lexer
{
private:
struct dummy { void true_() {} };
@@ -156,13 +158,13 @@
operator safe_bool() const
{ return initialized_dfa_ ? &dummy::true_ : 0; }
- typedef typename boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef std::basic_string<char_type> string_type;
typedef boost::lexer::basic_rules<char_type> basic_rules_type;
- // Every lexer type to be used as a lexer for Spirit has to conform to
+ // Every lexer type to be used as a lexer for Spirit has to conform to
// a public interface .
typedef Token token_type;
typedef typename Token::id_type id_type;
@@ -170,7 +172,7 @@
private:
// this type is purely used for the iterator_type construction below
- struct iterator_data_type
+ struct iterator_data_type
{
typedef typename Functor::semantic_actions_type semantic_actions_type;
@@ -195,7 +197,7 @@
// tokens.
iterator_type begin(Iterator& first, Iterator const& last
, char_type const* initial_state = 0) const
- {
+ {
if (!init_dfa()) // never minimize DFA for dynamic lexers
return iterator_type();
@@ -203,16 +205,16 @@
return iterator_type(iterator_data, first, last, initial_state);
}
- // Return the end iterator usable to stop iterating over the generated
+ // Return the end iterator usable to stop iterating over the generated
// tokens.
iterator_type end() const
- {
- return iterator_type();
+ {
+ return iterator_type();
}
protected:
// Lexer instances can be created by means of a derived class only.
- lexer(unsigned int flags)
+ lexer(unsigned int flags)
: flags_(detail::map_flags(flags))
, rules_(flags_)
, initialized_dfa_(false)
@@ -220,7 +222,7 @@
public:
// interface for token definition management
- std::size_t add_token(char_type const* state, char_type tokendef,
+ std::size_t add_token(char_type const* state, char_type tokendef,
std::size_t token_id, char_type const* targetstate)
{
add_state(state);
@@ -234,7 +236,7 @@
add_state(targetstate);
return rules_.add(state, detail::escape(tokendef), token_id, targetstate);
}
- std::size_t add_token(char_type const* state, string_type const& tokendef,
+ std::size_t add_token(char_type const* state, string_type const& tokendef,
std::size_t token_id, char_type const* targetstate)
{
add_state(state);
@@ -269,7 +271,7 @@
}
std::size_t add_state(char_type const* state)
{
- if (state == all_states())
+ if (state == all_states())
return all_states_id;
std::size_t stateid = rules_.state(state);
@@ -279,12 +281,12 @@
}
return stateid;
}
- string_type initial_state() const
- {
+ string_type initial_state() const
+ {
return string_type(rules_.initial());
}
- string_type all_states() const
- {
+ string_type all_states() const
+ {
return string_type(rules_.all_states());
}
@@ -293,14 +295,14 @@
void add_action(std::size_t unique_id, std::size_t state, F act)
{
// If you see an error here stating add_action is not a member of
- // fusion::unused_type then you are probably having semantic actions
+ // fusion::unused_type then you are probably having semantic actions
// attached to at least one token in the lexer definition without
// using the lex::lexertl::actor_lexer<> as its base class.
typedef typename Functor::wrap_action_type wrapper_type;
if (state == all_states_id) {
// add the action to all known states
- typedef typename
- basic_rules_type::string_size_t_map::value_type
+ typedef typename
+ basic_rules_type::string_size_t_map::value_type
state_type;
std::size_t states = rules_.statemap().size();
@@ -320,8 +322,8 @@
// actions_.add_action(unique_id, add_state(state), wrapper_type::call(act));
// }
- // We do not minimize the state machine by default anymore because
- // Ben said: "If you can afford to generate a lexer at runtime, there
+ // We do not minimize the state machine by default anymore because
+ // Ben said: "If you can afford to generate a lexer at runtime, there
// is little point in calling minimise."
// Go figure.
bool init_dfa(bool minimize = false) const
@@ -356,26 +358,28 @@
mutable bool initialized_dfa_;
// generator functions must be able to access members directly
- template <typename Lexer, typename F>
- friend bool generate_static(Lexer const&, std::ostream&, char const*, F);
+ template <typename Lexer, typename F>
+ friend bool generate_static(Lexer const&
+ , std::basic_ostream<typename Lexer::char_type>&
+ , typename Lexer::char_type const*, F);
};
///////////////////////////////////////////////////////////////////////////
//
- // The actor_lexer class is another implementation of a Spirit.Lex
- // lexer on top of Ben Hanson's lexertl library as outlined above (For
- // more information about lexertl go here:
+ // The actor_lexer class is another implementation of a Spirit.Lex
+ // lexer on top of Ben Hanson's lexertl library as outlined above (For
+ // more information about lexertl go here:
// http://www.benhanson.net/lexertl.html).
//
// The only difference to the lexer class above is that token_def
- // definitions may have semantic (lexer) actions attached while being
+ // definitions may have semantic (lexer) actions attached while being
// defined:
//
// int w;
// token_def word = "[^ \t\n]+";
// self = word[++ref(w)]; // see example: word_count_lexer
//
- // This class is supposed to be used as the first and only template
+ // This class is supposed to be used as the first and only template
// parameter while instantiating instances of a lex::lexer class.
//
///////////////////////////////////////////////////////////////////////////
@@ -386,7 +390,7 @@
{
protected:
// Lexer instances can be created by means of a derived class only.
- actor_lexer(unsigned int flags)
+ actor_lexer(unsigned int flags)
: lexer<Token, Iterator, Functor>(flags) {}
};
Modified: branches/release/boost/spirit/home/lex/qi/plain_raw_token.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/qi/plain_raw_token.hpp (original)
+++ branches/release/boost/spirit/home/lex/qi/plain_raw_token.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_PLAIN_RAW_TOKEN_JUN_03_2011_0853PM)
@@ -25,6 +25,7 @@
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
+#include <boost/lexical_cast.hpp>
namespace boost { namespace spirit
{
@@ -59,7 +60,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename TokenId>
- struct plain_raw_token
+ struct plain_raw_token
: primitive_parser<plain_raw_token<TokenId> >
{
template <typename Context, typename Iterator>
@@ -80,16 +81,16 @@
qi::skip_over(first, last, skipper); // always do a pre-skip
if (first != last) {
- // simply match the token id with the id this component has
+ // simply match the token id with the id this component has
// been initialized with
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if (std::size_t(~0) == id || id_type(id) == t.id()) {
+ if (id_type(~0) == id_type(id) || id_type(id) == t.id()) {
spirit::traits::assign_to(t, attr);
++first;
return true;
@@ -101,7 +102,8 @@
template <typename Context>
info what(Context& /*context*/) const
{
- return info("token");
+ return info("raw_token",
+ "raw_token(" + boost::lexical_cast<utf8_string>(id) + ")");
}
TokenId id;
Modified: branches/release/boost/spirit/home/lex/qi/plain_token.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/qi/plain_token.hpp (original)
+++ branches/release/boost/spirit/home/lex/qi/plain_token.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_PLAIN_TOKEN_NOV_11_2007_0451PM)
@@ -23,8 +23,10 @@
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/mpl/or.hpp>
+#include <boost/mpl/and.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
+#include <boost/lexical_cast.hpp>
namespace boost { namespace spirit
{
@@ -43,12 +45,26 @@
, terminal_ex<tag::token, fusion::vector1<A0> >
> : mpl::or_<is_integral<A0>, is_enum<A0> > {};
+ // enables token(idmin, idmax)
+ template <typename A0, typename A1>
+ struct use_terminal<qi::domain
+ , terminal_ex<tag::token, fusion::vector2<A0, A1> >
+ > : mpl::and_<
+ mpl::or_<is_integral<A0>, is_enum<A0> >
+ , mpl::or_<is_integral<A1>, is_enum<A1> >
+ > {};
+
// enables *lazy* token(id)
template <>
struct use_lazy_terminal<
qi::domain, tag::token, 1
> : mpl::true_ {};
+ // enables *lazy* token(idmin, idmax)
+ template <>
+ struct use_lazy_terminal<
+ qi::domain, tag::token, 2
+ > : mpl::true_ {};
}}
namespace boost { namespace spirit { namespace qi
@@ -60,7 +76,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename TokenId>
- struct plain_token
+ struct plain_token
: primitive_parser<plain_token<TokenId> >
{
template <typename Context, typename Iterator>
@@ -82,16 +98,16 @@
qi::skip_over(first, last, skipper); // always do a pre-skip
if (first != last) {
- // simply match the token id with the id this component has
+ // simply match the token id with the id this component has
// been initialized with
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if (std::size_t(~0) == id || id_type(id) == t.id()) {
+ if (id_type(~0) == id_type(id) || id_type(id) == t.id()) {
spirit::traits::assign_to(t, attr);
++first;
return true;
@@ -103,13 +119,71 @@
template <typename Context>
info what(Context& /*context*/) const
{
- return info("token");
+ return info("token",
+ "token(" + boost::lexical_cast<utf8_string>(id) + ")");
}
TokenId id;
};
///////////////////////////////////////////////////////////////////////////
+ template <typename TokenId>
+ struct plain_token_range
+ : primitive_parser<plain_token_range<TokenId> >
+ {
+ template <typename Context, typename Iterator>
+ struct attribute
+ {
+ typedef typename Iterator::base_iterator_type iterator_type;
+ typedef iterator_range<iterator_type> type;
+ };
+
+ plain_token_range(TokenId const& idmin, TokenId const& idmax)
+ : idmin(idmin), idmax(idmax) {}
+
+ template <typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& /*context*/, Skipper const& skipper
+ , Attribute& attr) const
+ {
+ qi::skip_over(first, last, skipper); // always do a pre-skip
+
+ if (first != last) {
+ // simply match the token id with the id this component has
+ // been initialized with
+
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
+ token_type;
+ typedef typename token_type::id_type id_type;
+
+ token_type const& t = *first;
+ if (id_type(idmin) >= t.id() && id_type(idmin) <= t.id())
+ {
+ spirit::traits::assign_to(t, attr);
+ ++first;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <typename Context>
+ info what(Context& /*context*/) const
+ {
+ return info("token_range"
+ , "token(" +
+ boost::lexical_cast<utf8_string>(idmin) + ", " +
+ boost::lexical_cast<utf8_string>(idmax) + ")"
+ );
+ return info("token_range");
+ }
+
+ TokenId idmin, idmax;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers>
@@ -135,6 +209,20 @@
return result_type(fusion::at_c<0>(term.args));
}
};
+
+ template <typename Modifiers, typename TokenId>
+ struct make_primitive<terminal_ex<tag::token, fusion::vector2<TokenId, TokenId> >
+ , Modifiers>
+ {
+ typedef plain_token_range<TokenId> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args)
+ , fusion::at_c<1>(term.args));
+ }
+ };
}}}
namespace boost { namespace spirit { namespace traits
@@ -144,6 +232,11 @@
struct handles_container<qi::plain_token<Idtype>, Attr, Context, Iterator>
: mpl::true_
{};
+
+ template<typename Idtype, typename Attr, typename Context, typename Iterator>
+ struct handles_container<qi::plain_token_range<Idtype>, Attr, Context, Iterator>
+ : mpl::true_
+ {};
}}}
#endif
Modified: branches/release/boost/spirit/home/lex/qi/plain_tokenid.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/qi/plain_tokenid.hpp (original)
+++ branches/release/boost/spirit/home/lex/qi/plain_tokenid.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_PLAIN_TOKENID_NOV_26_2010_0944AM)
@@ -23,8 +23,10 @@
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/mpl/or.hpp>
+#include <boost/mpl/and.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
+#include <boost/lexical_cast.hpp>
namespace boost { namespace spirit
{
@@ -43,11 +45,26 @@
, terminal_ex<tag::tokenid, fusion::vector1<A0> >
> : mpl::or_<is_integral<A0>, is_enum<A0> > {};
+ // enables tokenid(idmin, idmax)
+ template <typename A0, typename A1>
+ struct use_terminal<qi::domain
+ , terminal_ex<tag::tokenid, fusion::vector2<A0, A1> >
+ > : mpl::and_<
+ mpl::or_<is_integral<A0>, is_enum<A0> >
+ , mpl::or_<is_integral<A1>, is_enum<A1> >
+ > {};
+
// enables *lazy* tokenid(id)
template <>
struct use_lazy_terminal<
qi::domain, tag::tokenid, 1
> : mpl::true_ {};
+
+ // enables *lazy* tokenid(idmin, idmax)
+ template <>
+ struct use_lazy_terminal<
+ qi::domain, tag::tokenid, 2
+ > : mpl::true_ {};
}}
namespace boost { namespace spirit { namespace qi
@@ -58,11 +75,11 @@
using spirit::tokenid_type;
///////////////////////////////////////////////////////////////////////////
- // The plain_tokenid represents a simple token defined by the lexer inside
- // a Qi grammar. The difference to plain_token is that it exposes the
+ // The plain_tokenid represents a simple token defined by the lexer inside
+ // a Qi grammar. The difference to plain_token is that it exposes the
// matched token id instead of the iterator_range of the matched input.
template <typename TokenId>
- struct plain_tokenid
+ struct plain_tokenid
: primitive_parser<plain_tokenid<TokenId> >
{
template <typename Context, typename Iterator>
@@ -83,16 +100,16 @@
qi::skip_over(first, last, skipper); // always do a pre-skip
if (first != last) {
- // simply match the token id with the id this component has
+ // simply match the token id with the id this component has
// been initialized with
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if (std::size_t(~0) == id || id_type(id) == t.id()) {
+ if (id_type(~0) == id_type(id) || id_type(id) == t.id()) {
spirit::traits::assign_to(id, attr);
++first;
return true;
@@ -104,17 +121,73 @@
template <typename Context>
info what(Context& /*context*/) const
{
- return info("tokenid");
+ return info("tokenid",
+ "tokenid(" + boost::lexical_cast<utf8_string>(id) + ")");
}
TokenId id;
};
///////////////////////////////////////////////////////////////////////////
+ template <typename TokenId>
+ struct plain_tokenid_range
+ : primitive_parser<plain_tokenid_range<TokenId> >
+ {
+ template <typename Context, typename Iterator>
+ struct attribute
+ {
+ typedef TokenId type;
+ };
+
+ plain_tokenid_range(TokenId const& idmin, TokenId const& idmax)
+ : idmin(idmin), idmax(idmax) {}
+
+ template <typename Iterator, typename Context
+ , typename Skipper, typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& /*context*/, Skipper const& skipper
+ , Attribute& attr) const
+ {
+ qi::skip_over(first, last, skipper); // always do a pre-skip
+
+ if (first != last) {
+ // simply match the token id with the id this component has
+ // been initialized with
+
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
+ token_type;
+ typedef typename token_type::id_type id_type;
+
+ token_type const& t = *first;
+ if (id_type(idmin) >= t.id() && id_type(idmin) <= t.id())
+ {
+ spirit::traits::assign_to(t.id(), attr);
+ ++first;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <typename Context>
+ info what(Context& /*context*/) const
+ {
+ return info("tokenid_range"
+ , "token(" +
+ boost::lexical_cast<utf8_string>(idmin) + ", " +
+ boost::lexical_cast<utf8_string>(idmax) + ")"
+ );
+ }
+
+ TokenId idmin, idmax;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template <typename Modifiers>
- struct make_primitive<tag::tokenid, Modifiers>
+ struct make_primitive<tag::tokenid, Modifiers>
{
typedef plain_tokenid<std::size_t> result_type;
@@ -136,6 +209,20 @@
return result_type(fusion::at_c<0>(term.args));
}
};
+
+ template <typename Modifiers, typename TokenId>
+ struct make_primitive<terminal_ex<tag::tokenid, fusion::vector2<TokenId, TokenId> >
+ , Modifiers>
+ {
+ typedef plain_tokenid_range<TokenId> result_type;
+
+ template <typename Terminal>
+ result_type operator()(Terminal const& term, unused_type) const
+ {
+ return result_type(fusion::at_c<0>(term.args)
+ , fusion::at_c<1>(term.args));
+ }
+ };
}}}
namespace boost { namespace spirit { namespace traits
@@ -145,6 +232,11 @@
struct handles_container<qi::plain_tokenid<Idtype>, Attr, Context, Iterator>
: mpl::true_
{};
+
+ template<typename Idtype, typename Attr, typename Context, typename Iterator>
+ struct handles_container<qi::plain_tokenid_range<Idtype>, Attr, Context, Iterator>
+ : mpl::true_
+ {};
}}}
#endif
Modified: branches/release/boost/spirit/home/lex/qi/plain_tokenid_mask.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/qi/plain_tokenid_mask.hpp (original)
+++ branches/release/boost/spirit/home/lex/qi/plain_tokenid_mask.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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_LEX_PLAIN_TOKENID_MASK_JUN_03_2011_0929PM)
@@ -25,6 +25,7 @@
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
+#include <boost/lexical_cast.hpp>
namespace boost { namespace spirit
{
@@ -53,8 +54,8 @@
using spirit::tokenid_mask_type;
///////////////////////////////////////////////////////////////////////////
- // The plain_tokenid represents a simple token defined by the lexer inside
- // a Qi grammar. The difference to plain_token is that it exposes the
+ // The plain_tokenid represents a simple token defined by the lexer inside
+ // a Qi grammar. The difference to plain_token is that it exposes the
// matched token id instead of the iterator_range of the matched input.
// Additionally it applies the given mask to the matched token id.
template <typename Mask>
@@ -79,16 +80,16 @@
qi::skip_over(first, last, skipper); // always do a pre-skip
if (first != last) {
- // simply match the token id with the mask this component has
+ // simply match the token id with the mask this component has
// been initialized with
- typedef typename
- boost::detail::iterator_traits<Iterator>::value_type
+ typedef typename
+ boost::detail::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
token_type const& t = *first;
- if ((t.id() & mask) == id_type(mask))
+ if ((t.id() & mask) == id_type(mask))
{
spirit::traits::assign_to(t.id(), attr);
++first;
@@ -101,7 +102,8 @@
template <typename Context>
info what(Context& /*context*/) const
{
- return info("tokenid_mask");
+ return info("tokenid_mask",
+ "tokenid_mask(" + boost::lexical_cast<utf8_string>(mask) + ")");
}
Mask mask;
Modified: branches/release/boost/spirit/home/qi/binary/binary.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/binary/binary.hpp (original)
+++ branches/release/boost/spirit/home/qi/binary/binary.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -25,6 +25,7 @@
#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>
#define BOOST_SPIRIT_ENABLE_BINARY(name) \
@@ -42,6 +43,19 @@
\
/***/
+#define BOOST_SPIRIT_ENABLE_BINARY_IEEE754(name) \
+ template<> \
+ struct use_terminal<qi::domain, tag::name>: mpl::true_ {}; \
+ \
+ template<typename A0> \
+ struct use_terminal<qi::domain, terminal_ex<tag::name, \
+ fusion::vector1<A0> > >: is_floating_point<A0> {}; \
+ \
+ template<> \
+ struct use_lazy_terminal<qi::domain, tag::name, 1>: mpl::true_ {}; \
+ \
+/***/
+
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
@@ -59,9 +73,16 @@
BOOST_SPIRIT_ENABLE_BINARY(big_qword) // enables big_qword
BOOST_SPIRIT_ENABLE_BINARY(little_qword) // enables little_qword
#endif
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(big_bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(little_bin_float)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(bin_double)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(big_bin_double)
+ BOOST_SPIRIT_ENABLE_BINARY_IEEE754(little_bin_double)
}}
#undef BOOST_SPIRIT_ENABLE_BINARY
+#undef BOOST_SPIRIT_ENABLE_BINARY_IEEE754
namespace boost { namespace spirit { namespace qi
{
@@ -78,6 +99,12 @@
using boost::spirit::big_qword;
using boost::spirit::little_qword;
#endif
+ using boost::spirit::bin_float;
+ using boost::spirit::big_bin_float;
+ using boost::spirit::little_bin_float;
+ using boost::spirit::bin_double;
+ using boost::spirit::big_bin_double;
+ using boost::spirit::little_bin_double;
#endif
using boost::spirit::byte_type;
@@ -92,6 +119,12 @@
using boost::spirit::big_qword_type;
using boost::spirit::little_qword_type;
#endif
+ using boost::spirit::bin_float_type;
+ using boost::spirit::big_bin_float_type;
+ using boost::spirit::little_bin_float_type;
+ using boost::spirit::bin_double_type;
+ using boost::spirit::big_bin_double_type;
+ using boost::spirit::little_bin_double_type;
namespace detail
{
@@ -139,6 +172,28 @@
};
#endif
+ template <int bits>
+ struct floating_point
+ {
+ BOOST_SPIRIT_ASSERT_MSG(
+ bits == 32 || bits == 64,
+ not_supported_binary_size, ());
+ };
+
+ template <>
+ struct floating_point<32>
+ {
+ enum { size = 4 };
+ typedef float type;
+ };
+
+ template <>
+ struct floating_point<64>
+ {
+ enum { size = 8 };
+ typedef double type;
+ };
+
///////////////////////////////////////////////////////////////////////
template <BOOST_SCOPED_ENUM(boost::endian::endianness) bits>
struct what;
@@ -172,15 +227,14 @@
}
///////////////////////////////////////////////////////////////////////////
- template <BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
- struct any_binary_parser : primitive_parser<any_binary_parser<endian, bits> >
+ template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
+ struct any_binary_parser : primitive_parser<any_binary_parser<T, endian, bits> >
{
template <typename Context, typename Iterator>
struct attribute
{
- typedef boost::endian::endian<
- endian, typename qi::detail::integer<bits>::type, bits
- > type;
+ typedef boost::endian::endian<endian, typename T::type,
+ bits> type;
};
template <typename Iterator, typename Context
@@ -215,10 +269,10 @@
};
///////////////////////////////////////////////////////////////////////////
- template <typename Int
+ template <typename V, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct binary_lit_parser
- : primitive_parser<binary_lit_parser<Int, endian, bits> >
+ : primitive_parser<binary_lit_parser<V, T, endian, bits> >
{
template <typename Context, typename Iterator>
struct attribute
@@ -226,7 +280,7 @@
typedef unused_type type;
};
- binary_lit_parser(Int n)
+ binary_lit_parser(V n)
: n(n) {}
template <typename Iterator, typename Context
@@ -241,8 +295,7 @@
// definition of C++03) it seems to be safe to assume they are
// (but in C++0x the endian types _are_ PODs).
// This allows us to treat them as a sequence of consecutive bytes.
- boost::endian::endian<
- endian, typename qi::detail::integer<bits>::type, bits> attr_;
+ boost::endian::endian<endian, typename T::type, bits> attr_;
#if defined(BOOST_MSVC)
// warning C4244: 'argument' : conversion from 'const int' to 'foo', possible loss of data
@@ -274,27 +327,27 @@
return info(qi::detail::what<endian>::is());
}
- Int n;
+ V n;
};
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
- template <BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
+ template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct make_binary_parser
{
- typedef any_binary_parser<endian, bits> result_type;
+ typedef any_binary_parser<T, endian, bits> result_type;
result_type operator()(unused_type, unused_type) const
{
return result_type();
}
};
- template <typename Int
+ template <typename V, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
struct make_binary_lit_parser
{
- typedef binary_lit_parser<Int, endian, bits> result_type;
+ typedef binary_lit_parser<V, T, endian, bits> result_type;
template <typename Terminal>
result_type operator()(Terminal const& term, unused_type) const
{
@@ -302,16 +355,18 @@
}
};
-#define BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(name, endiantype, bits) \
- template <typename Modifiers> \
- struct make_primitive<tag::name, Modifiers> \
- : make_binary_parser<boost::endian::endianness::endiantype, bits> {}; \
- \
- template <typename Modifiers, typename A0> \
- struct make_primitive< \
- terminal_ex<tag::name, fusion::vector1<A0> > , Modifiers> \
- : make_binary_lit_parser<A0, boost::endian::endianness::endiantype, bits> {};\
- \
+#define BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(name, endiantype, bits) \
+ template <typename Modifiers> \
+ struct make_primitive<tag::name, Modifiers> \
+ : make_binary_parser<detail::integer<bits>, \
+ boost::endian::endianness::endiantype, bits> {}; \
+ \
+ template <typename Modifiers, typename A0> \
+ struct make_primitive< \
+ terminal_ex<tag::name, fusion::vector1<A0> > , Modifiers> \
+ : make_binary_lit_parser<A0, detail::integer<bits>, \
+ boost::endian::endianness::endiantype, bits> {}; \
+ \
/***/
BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE(byte_, native, 8)
@@ -329,6 +384,30 @@
#undef BOOST_SPIRIT_MAKE_BINARY_PRIMITIVE
+#define BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(name, endiantype, bits) \
+ template<typename Modifiers> \
+ struct make_primitive<tag::name, Modifiers> \
+ : make_binary_parser<detail::floating_point<bits>, \
+ boost::endian::endianness::endiantype, bits> {}; \
+ \
+ template<typename Modifiers, typename A0> \
+ struct make_primitive< \
+ terminal_ex<tag::name, fusion::vector1<A0> >, Modifiers> \
+ : make_binary_lit_parser<A0, detail::floating_point<bits>, \
+ boost::endian::endianness::endiantype, \
+ bits> {}; \
+ \
+ /***/
+
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(bin_float, native, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(big_bin_float, big, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(little_bin_float, little, 32)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(bin_double, native, 64)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(big_bin_double, big, 64)
+ BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE(little_bin_double, little, 64)
+
+#undef BOOST_SPIRIT_MAKE_BINARY_IEEE754_PRIMITIVE
+
}}}
#endif
Modified: branches/release/boost/spirit/home/support/attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -45,6 +45,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/variant.hpp>
#include <boost/range/iterator_range.hpp>
+#include <boost/config.hpp>
#include <vector>
#include <utility>
#include <ios>
@@ -747,9 +748,11 @@
};
// never called, but needed for decltype-based result_of (C++0x)
+#ifndef BOOST_NO_RVALUE_REFERENCES
template <typename Element>
typename result<element_attribute(Element)>::type
- operator()(Element&) const;
+ operator()(Element&&) const;
+#endif
};
// Compute the list of attributes of all sub-components
Modified: branches/release/boost/spirit/home/support/common_terminals.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/common_terminals.hpp (original)
+++ branches/release/boost/spirit/home/support/common_terminals.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -116,6 +116,12 @@
( qword, qword_type )
( big_qword, big_qword_type )
( little_qword, little_qword_type )
+ ( bin_float, bin_float_type )
+ ( big_bin_float, big_bin_float_type )
+ ( little_bin_float, little_bin_float_type )
+ ( bin_double, bin_double_type )
+ ( big_bin_double, big_bin_double_type )
+ ( little_bin_double, little_bin_double_type )
( skip, skip_type )
( delimit, delimit_type )
( stream, stream_type )
Modified: branches/release/boost/spirit/home/support/detail/endian/endian.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/endian/endian.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/endian/endian.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -122,6 +122,44 @@
(static_cast<const unsigned char*>(bytes) + n_bytes);
}
+ template <>
+ inline
+ float load_big_endian<float, 4>(const void* bytes)
+ {
+ const unsigned char *b = reinterpret_cast<const unsigned char *>(
+ bytes);
+ b += 3;
+
+ float value;
+ unsigned char *v = reinterpret_cast<unsigned char *>(&value);
+
+ for(std::size_t i = 0; i < 4; ++i)
+ {
+ *v++ = *b--;
+ }
+
+ return value;
+ }
+
+ template <>
+ inline
+ double load_big_endian<double, 8>(const void* bytes)
+ {
+ const unsigned char *b = reinterpret_cast<const unsigned char *>(
+ bytes);
+ b += 7;
+
+ double value;
+ unsigned char *v = reinterpret_cast<unsigned char *>(&value);
+
+ for(std::size_t i = 0; i < 8; ++i)
+ {
+ *v++ = *b--;
+ }
+
+ return value;
+ }
+
template <typename T, std::size_t n_bytes>
inline
T load_little_endian(const void* bytes)
@@ -130,6 +168,42 @@
(static_cast<const unsigned char*>(bytes));
}
+ template <>
+ inline
+ float load_little_endian<float, 4>(const void* bytes)
+ {
+ const unsigned char *b = reinterpret_cast<const unsigned char *>(
+ bytes);
+
+ float value;
+ unsigned char *v = reinterpret_cast<unsigned char *>(&value);
+
+ for(std::size_t i = 0; i < 4; ++i)
+ {
+ *v++ = *b++;
+ }
+
+ return value;
+ }
+
+ template <>
+ inline
+ double load_little_endian<double, 8>(const void* bytes)
+ {
+ const unsigned char *b = reinterpret_cast<const unsigned char *>(
+ bytes);
+
+ double value;
+ unsigned char *v = reinterpret_cast<unsigned char *>(&value);
+
+ for(std::size_t i = 0; i < 8; ++i)
+ {
+ *v++ = *b++;
+ }
+
+ return value;
+ }
+
template <typename T, std::size_t n_bytes>
inline
void store_big_endian(void* bytes, T value)
@@ -138,6 +212,38 @@
(static_cast<char*>(bytes) + n_bytes, value);
}
+ template <>
+ inline
+ void store_big_endian<float, 4>(void* bytes, float value)
+ {
+ unsigned char *b = reinterpret_cast<unsigned char *>(bytes);
+ b += 3;
+
+ const unsigned char *v = reinterpret_cast<const unsigned char *>(
+ &value);
+
+ for(std::size_t i = 0; i < 4; ++i)
+ {
+ *b-- = *v++;
+ }
+ }
+
+ template <>
+ inline
+ void store_big_endian<double, 8>(void* bytes, double value)
+ {
+ unsigned char *b = reinterpret_cast<unsigned char *>(bytes);
+ b += 7;
+
+ const unsigned char *v = reinterpret_cast<const unsigned char *>(
+ &value);
+
+ for(std::size_t i = 0; i < 8; ++i)
+ {
+ *b-- = *v++;
+ }
+ }
+
template <typename T, std::size_t n_bytes>
inline
void store_little_endian(void* bytes, T value)
@@ -146,6 +252,36 @@
(static_cast<char*>(bytes), value);
}
+ template <>
+ inline
+ void store_little_endian<float, 4>(void* bytes, float value)
+ {
+ unsigned char *b = reinterpret_cast<unsigned char *>(bytes);
+
+ const unsigned char *v = reinterpret_cast<const unsigned char *>(
+ &value);
+
+ for(std::size_t i = 0; i < 4; ++i)
+ {
+ *b++ = *v++;
+ }
+ }
+
+ template <>
+ inline
+ void store_little_endian<double, 8>(void* bytes, double value)
+ {
+ unsigned char *b = reinterpret_cast<unsigned char *>(bytes);
+
+ const unsigned char *v = reinterpret_cast<const unsigned char *>(
+ &value);
+
+ for(std::size_t i = 0; i < 8; ++i)
+ {
+ *b++ = *v++;
+ }
+ }
+
} // namespace detail
namespace endian
@@ -181,7 +317,7 @@
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian(T val)
- {
+ {
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
@@ -191,7 +327,7 @@
# endif
endian & operator=(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); return *this; }
operator T() const
- {
+ {
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "big, unaligned, " << n_bits << "-bits, convert(" << detail::load_big_endian<T, n_bits/8>(m_value) << ")\n";
@@ -213,7 +349,7 @@
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian(T val)
- {
+ {
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
@@ -223,7 +359,7 @@
# endif
endian & operator=(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
operator T() const
- {
+ {
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "little, unaligned, " << n_bits << "-bits, convert(" << detail::load_little_endian<T, n_bits/8>(m_value) << ")\n";
@@ -250,7 +386,7 @@
explicit endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
# endif
# endif
-# ifdef BOOST_BIG_ENDIAN
+# ifdef BOOST_BIG_ENDIAN
endian & operator=(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); return *this; }
operator T() const { return detail::load_big_endian<T, n_bits/8>(m_value); }
# else
@@ -281,13 +417,13 @@
explicit endian(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); }
# endif
# endif
-# ifdef BOOST_BIG_ENDIAN
+# ifdef BOOST_BIG_ENDIAN
endian & operator=(T val) { m_value = val; return *this; }
operator T() const { return m_value; }
-# else
+# else
endian & operator=(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); return *this; }
operator T() const { return detail::load_big_endian<T, sizeof(T)>(&m_value); }
-# endif
+# endif
private:
T m_value;
};
@@ -385,7 +521,7 @@
#define BOOST_HAS_INT16_T
#define BOOST_HAS_INT32_T
#define BOOST_HAS_INT64_T
-
+
// These types only present if platform has exact size integers:
// aligned big endian signed integer types
// aligned big endian unsigned integer types
Modified: branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -87,7 +87,7 @@
default:
std::ostringstream ss_;
- ss_ << "A syntax error occurred: '" <<
+ ss_ << "A syntax error occured: '" <<
lhs_token_.precedence_string () <<
"' against '" << rhs_token_.precedence_string () <<
"' at index " << state_.index () << ".";
Modified: branches/release/boost/spirit/home/support/detail/lexer/rules.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/lexer/rules.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/lexer/rules.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -44,6 +44,16 @@
{
return "*";
}
+
+ static const char *char_name ()
+ {
+ return "char";
+ }
+
+ static const char *char_prefix ()
+ {
+ return "";
+ }
};
template <>
@@ -63,6 +73,16 @@
{
return L"*";
}
+
+ static const char *char_name ()
+ {
+ return "wchar_t";
+ }
+
+ static const char *char_prefix ()
+ {
+ return "L";
+ }
};
}
Modified: branches/release/boost/spirit/home/support/extended_variant.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/extended_variant.hpp (original)
+++ branches/release/boost/spirit/home/support/extended_variant.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -81,4 +81,35 @@
};
}}
+namespace boost
+{
+ template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ inline T const&
+ get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& x)
+ {
+ return boost::get<T>(x.get());
+ }
+
+ template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ inline T&
+ get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)>& x)
+ {
+ return boost::get<T>(x.get());
+ }
+
+ template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ inline T const*
+ get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)> const* x)
+ {
+ return boost::get<T>(&x->get());
+ }
+
+ template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ inline T*
+ get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)>* x)
+ {
+ return boost::get<T>(&x->get());
+ }
+}
+
#endif
Modified: branches/release/boost/spirit/home/support/iterators/detail/combine_policies.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/iterators/detail/combine_policies.hpp (original)
+++ branches/release/boost/spirit/home/support/iterators/detail/combine_policies.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,5 +1,5 @@
-// Copyright (c) 2001-2011 Hartmut Kaiser
-//
+// Copyright (c) 2001-2012 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)
@@ -12,21 +12,21 @@
namespace boost { namespace spirit { namespace iterator_policies
{
///////////////////////////////////////////////////////////////////////////
- // The purpose of the multi_pass_unique template is to eliminate
- // empty policy classes (policies not containing any data items) from the
- // multiple inheritance chain. This is necessary since some compilers
- // fail to apply the empty base optimization if multiple inheritance is
+ // The purpose of the multi_pass_unique template is to eliminate
+ // empty policy classes (policies not containing any data items) from the
+ // multiple inheritance chain. This is necessary since some compilers
+ // fail to apply the empty base optimization if multiple inheritance is
// involved.
- // Additionally this can be used to combine separate policies into one
+ // Additionally this can be used to combine separate policies into one
// single multi_pass_policy as required by the multi_pass template
///////////////////////////////////////////////////////////////////////////
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
- // without partial template specialization there is nothing much to do in
+ // without partial template specialization there is nothing much to do in
// terms of empty base optimization anyways...
- template <typename T, typename Ownership, typename Checking,
+ template <typename T, typename Ownership, typename Checking,
typename Input, typename Storage>
- struct multi_pass_unique
+ struct multi_pass_unique
: Ownership, Checking, Input, Storage
{
multi_pass_unique() {}
@@ -41,13 +41,21 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Ownership::swap(x);
this->Checking::swap(x);
this->Input::swap(x);
this->Storage::swap(x);
}
+
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
};
#else
///////////////////////////////////////////////////////////////////////////
@@ -78,15 +86,23 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Ownership::swap(x);
this->Checking::swap(x);
this->Input::swap(x);
this->Storage::swap(x);
}
+
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
};
-
+
///////////////////////////////////////////////////////////////////////////
template <typename T, typename Ownership, typename Checking
, typename Input, typename Storage>
@@ -105,13 +121,21 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Ownership::swap(x);
this->Checking::swap(x);
this->Storage::swap(x);
}
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+
// implement input policy functions by forwarding to the Input type
template <typename MultiPass>
inline static void advance_input(MultiPass& mp)
@@ -148,21 +172,25 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Ownership::swap(x);
this->Input::swap(x);
this->Storage::swap(x);
}
- // checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void docheck(MultiPass const& mp)
- { Checking::docheck(mp); }
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+ // checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void clear_queue(MultiPass& mp)
- { Checking::clear_queue(mp); }
+ inline static void docheck(MultiPass const& mp)
+ { Checking::docheck(mp); }
};
///////////////////////////////////////////////////////////////////////////
@@ -182,12 +210,20 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Ownership::swap(x);
this->Storage::swap(x);
}
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+
// implement input policy functions by forwarding to the Input type
template <typename MultiPass>
inline static void advance_input(MultiPass& mp)
@@ -207,12 +243,8 @@
// checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void docheck(MultiPass const& mp)
+ inline static void docheck(MultiPass const& mp)
{ Checking::docheck(mp); }
-
- template <typename MultiPass>
- inline static void clear_queue(MultiPass& mp)
- { Checking::clear_queue(mp); }
};
///////////////////////////////////////////////////////////////////////////
@@ -233,16 +265,24 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Checking::swap(x);
this->Input::swap(x);
this->Storage::swap(x);
}
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+
// ownership policy functions are forwarded to the Ownership type
template <typename MultiPass>
- inline static void clone(MultiPass& mp)
+ inline static void clone(MultiPass& mp)
{ Ownership::clone(mp); }
template <typename MultiPass>
@@ -271,12 +311,20 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Checking::swap(x);
this->Storage::swap(x);
}
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+
// implement input policy functions by forwarding to the Input type
template <typename MultiPass>
inline static void advance_input(MultiPass& mp)
@@ -296,7 +344,7 @@
// ownership policy functions are forwarded to the Ownership type
template <typename MultiPass>
- inline static void clone(MultiPass& mp)
+ inline static void clone(MultiPass& mp)
{ Ownership::clone(mp); }
template <typename MultiPass>
@@ -325,24 +373,28 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Input::swap(x);
this->Storage::swap(x);
}
- // checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void docheck(MultiPass const& mp)
- { Checking::docheck(mp); }
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+ // checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void clear_queue(MultiPass& mp)
- { Checking::clear_queue(mp); }
+ inline static void docheck(MultiPass const& mp)
+ { Checking::docheck(mp); }
// ownership policy functions are forwarded to the Ownership type
template <typename MultiPass>
- inline static void clone(MultiPass& mp)
+ inline static void clone(MultiPass& mp)
{ Ownership::clone(mp); }
template <typename MultiPass>
@@ -370,11 +422,19 @@
Input::destroy(mp);
Storage::destroy(mp);
}
- void swap(multi_pass_unique& x)
+
+ void swap(multi_pass_unique& x)
{
this->Storage::swap(x);
}
+ template <typename MultiPass>
+ inline static void clear_queue(MultiPass& mp)
+ {
+ Checking::clear_queue(mp);
+ Storage::clear_queue(mp);
+ }
+
// implement input policy functions by forwarding to the Input type
template <typename MultiPass>
inline static void advance_input(MultiPass& mp)
@@ -394,16 +454,12 @@
// checking policy functions are forwarded to the Checking type
template <typename MultiPass>
- inline static void docheck(MultiPass const& mp)
+ inline static void docheck(MultiPass const& mp)
{ Checking::docheck(mp); }
- template <typename MultiPass>
- inline static void clear_queue(MultiPass& mp)
- { Checking::clear_queue(mp); }
-
// ownership policy functions are forwarded to the Ownership type
template <typename MultiPass>
- inline static void clone(MultiPass& mp)
+ inline static void clone(MultiPass& mp)
{ Ownership::clone(mp); }
template <typename MultiPass>
@@ -417,7 +473,7 @@
#endif
///////////////////////////////////////////////////////////////////////////
- // the multi_pass_shared structure is used to combine the shared data items
+ // the multi_pass_shared structure is used to combine the shared data items
// of all policies into one single structure
///////////////////////////////////////////////////////////////////////////
template<typename T, typename Ownership, typename Checking, typename Input
@@ -451,7 +507,7 @@
{
typedef typename Ownership::unique ownership_policy;
typedef typename Checking::unique checking_policy;
- typedef typename Input::BOOST_NESTED_TEMPLATE unique<T>
+ typedef typename Input::BOOST_NESTED_TEMPLATE unique<T>
input_policy;
typedef typename Storage::BOOST_NESTED_TEMPLATE unique<
typename input_policy::value_type> storage_policy;
@@ -470,26 +526,26 @@
, typename Ownership::shared, typename Checking::shared
, typename Input::BOOST_NESTED_TEMPLATE shared<T>
, typename Storage::BOOST_NESTED_TEMPLATE shared<
- typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type> >
+ typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type> >
{
typedef typename Ownership::shared ownership_policy;
typedef typename Checking::shared checking_policy;
- typedef typename Input::BOOST_NESTED_TEMPLATE shared<T>
+ typedef typename Input::BOOST_NESTED_TEMPLATE shared<T>
input_policy;
typedef typename Storage::BOOST_NESTED_TEMPLATE shared<
- typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type>
+ typename Input::BOOST_NESTED_TEMPLATE unique<T>::value_type>
storage_policy;
typedef multi_pass_shared<T, ownership_policy, checking_policy
, input_policy, storage_policy> shared_base_type;
- explicit shared(T& input)
+ explicit shared(T& input)
: shared_base_type(input), inhibit_clear_queue_(false) {}
- explicit shared(T const& input)
+ explicit shared(T const& input)
: shared_base_type(input), inhibit_clear_queue_(false) {}
- // This is needed for the correct implementation of expectation
- // points. Normally expectation points flush any multi_pass
+ // This is needed for the correct implementation of expectation
+ // points. Normally expectation points flush any multi_pass
// iterator they may act on, but if the corresponding error handler
// is of type 'retry' no flushing of the internal buffers should be
// executed (even if explicitly requested).
Modified: branches/release/boost/spirit/home/support/iterators/multi_pass.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/iterators/multi_pass.hpp (original)
+++ branches/release/boost/spirit/home/support/iterators/multi_pass.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,7 +1,7 @@
// Copyright (c) 2001, Daniel C. Nuffer
// 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)
@@ -16,13 +16,13 @@
#include <boost/detail/workaround.hpp>
#include <boost/utility/base_from_member.hpp>
-namespace boost { namespace spirit
+namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
// The default multi_pass instantiation uses a ref-counted std_deque scheme.
///////////////////////////////////////////////////////////////////////////
template<typename T, typename Policies>
- class multi_pass
+ class multi_pass
: private boost::base_from_member<
typename Policies::BOOST_NESTED_TEMPLATE shared<T>*>
, public Policies::BOOST_NESTED_TEMPLATE unique<T>
@@ -32,14 +32,14 @@
{
private:
// unique and shared data types
- typedef typename Policies::BOOST_NESTED_TEMPLATE unique<T>
+ typedef typename Policies::BOOST_NESTED_TEMPLATE unique<T>
policies_base_type;
- typedef typename Policies::BOOST_NESTED_TEMPLATE shared<T>
+ typedef typename Policies::BOOST_NESTED_TEMPLATE shared<T>
shared_data_type;
typedef boost::base_from_member<shared_data_type*> member_base;
- // define the types the standard embedded iterator typedefs are taken
+ // define the types the standard embedded iterator typedefs are taken
// from
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
typedef typename iterator_base_creator<Input, T>::type iterator_type;
@@ -56,7 +56,7 @@
typedef typename iterator_type::reference reference;
typedef typename iterator_type::pointer pointer;
- multi_pass() : member_base((shared_data_type*)0) {}
+ multi_pass() : member_base(static_cast<shared_data_type*>(0)) {}
explicit multi_pass(T& input)
: member_base(new shared_data_type(input)), policies_base_type(input) {}
@@ -77,7 +77,7 @@
// checking code that isn't required by the standard.
// The workaround is to provide an additional constructor that
// ignores its int argument and behaves like the default constructor.
- multi_pass(int) : member_base((shared_data_type*)0) {}
+ multi_pass(int) : member_base(static_cast<shared_data_type*>(0)) {}
#endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514)
~multi_pass()
@@ -126,7 +126,7 @@
return tmp;
}
- void clear_queue(BOOST_SCOPED_ENUM(traits::clear_mode) mode =
+ void clear_queue(BOOST_SCOPED_ENUM(traits::clear_mode) mode =
traits::clear_mode::clear_if_enabled)
{
if (mode == traits::clear_mode::clear_always || !inhibit_clear_queue())
@@ -214,7 +214,7 @@
///////////////////////////////////////////////////////////////////////////
template <typename T, typename Policies>
- inline void
+ inline void
swap(multi_pass<T, Policies> &x, multi_pass<T, Policies> &y)
{
x.swap(y);
@@ -247,6 +247,6 @@
}} // namespace boost::spirit
-#endif
+#endif
Modified: branches/release/boost/spirit/repository/home/karma/nonterminal/subrule.hpp
==============================================================================
--- branches/release/boost/spirit/repository/home/karma/nonterminal/subrule.hpp (original)
+++ branches/release/boost/spirit/repository/home/karma/nonterminal/subrule.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
// Copyright (c) 2009 Francois Barel
// Copyright (c) 2001-2011 Joel de Guzman
-// Copyright (c) 2001-2011 Hartmut Kaiser
+// Copyright (c) 2001-2012 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)
@@ -207,8 +207,8 @@
// trying to use a subrule which has inherited attributes,
// without passing values for them.
context_type context(*this
- , traits::pre_transform<subrule_attr_type>(
- make_attribute::call(attr)));
+ , traits::pre_transform<karma::domain, subrule_attr_type>(
+ make_attribute::call(attr)));
return def.binder(sink, context, delimiter);
}
@@ -242,8 +242,8 @@
// trying to use a subrule which has inherited attributes,
// passing values of incompatible types for them.
context_type context(*this
- , traits::pre_transform<subrule_attr_type>(
- make_attribute::call(attr)), params, caller_context);
+ , traits::pre_transform<karma::domain, subrule_attr_type>(
+ make_attribute::call(attr)), params, caller_context);
return def.binder(sink, context, delimiter);
}
Modified: branches/release/libs/spirit/doc/index.idx
==============================================================================
--- branches/release/libs/spirit/doc/index.idx (original)
+++ branches/release/libs/spirit/doc/index.idx 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -6,8 +6,8 @@
# http://www.boost.org/LICENSE_1_0.txt)
#==============================================================================
-#!scan-path "../../../boost/spirit/home/qi" ".*hpp" true
-#!scan-path "../../../boost/spirit/home/karma" ".*hpp" true
+#!scan-path "../../../boost/spirit/home/qi" ".*hpp" true
+#!scan-path "../../../boost/spirit/home/karma" ".*hpp" true
###############################################################################
# Qi API
@@ -41,7 +41,7 @@
auto_ "" ".*karma.reference.auto.*" karma_index
# auxiliary parsers/generators
-attr "" ".*qi.reference.auxiliary.attr\..*" qi_index
+attr "" ".*qi.reference.auxiliary.attr" qi_index
attr_cast "" ".*qi.reference.auxiliary.attr_cast.*" qi_index
eol "" ".*qi.reference.auxiliary.eol.*" qi_index
eoi "" ".*qi.reference.auxiliary.eoi.*" qi_index
@@ -59,23 +59,35 @@
word "" ".*qi.reference.binary.binary_native.*" qi_index
dword "" ".*qi.reference.binary.binary_native.*" qi_index
qword "" ".*qi.reference.binary.binary_native.*" qi_index
+bin_float "" ".*qi.reference.binary.binary_native.*" qi_index
+bin_double "" ".*qi.reference.binary.binary_native.*" qi_index
little_word "" ".*qi.reference.binary.binary_little.*" qi_index
little_dword "" ".*qi.reference.binary.binary_little.*" qi_index
little_qword "" ".*qi.reference.binary.binary_little.*" qi_index
+little_bin_float "" ".*qi.reference.binary.binary_little.*" qi_index
+little_bin_double "" ".*qi.reference.binary.binary_little.*" qi_index
big_word "" ".*qi.reference.binary.binary_big.*" qi_index
big_dword "" ".*qi.reference.binary.binary_big.*" qi_index
big_qword "" ".*qi.reference.binary.binary_big.*" qi_index
+big_bin_float "" ".*qi.reference.binary.binary_big.*" qi_index
+big_bin_double "" ".*qi.reference.binary.binary_big.*" qi_index
byte_ "" ".*karma.reference.binary.binary_native.*" karma_index
word "" ".*karma.reference.binary.binary_native.*" karma_index
dword "" ".*karma.reference.binary.binary_native.*" karma_index
qword "" ".*karma.reference.binary.binary_native.*" karma_index
+bin_float "" ".*karma.reference.binary.binary_native.*" karma_index
+bin_double "" ".*karma.reference.binary.binary_native.*" karma_index
little_word "" ".*karma.reference.binary.binary_little.*" karma_index
little_dword "" ".*karma.reference.binary.binary_little.*" karma_index
little_qword "" ".*karma.reference.binary.binary_little.*" karma_index
+little_bin_float "" ".*karma.reference.binary.binary_little.*" karma_index
+little_bin_double "" ".*karma.reference.binary.binary_little.*" karma_index
big_word "" ".*karma.reference.binary.binary_big.*" karma_index
big_dword "" ".*karma.reference.binary.binary_big.*" karma_index
big_qword "" ".*karma.reference.binary.binary_big.*" karma_index
+big_bin_float "" ".*karma.reference.binary.binary_big.*" karma_index
+big_bin_double "" ".*karma.reference.binary.binary_big.*" karma_index
# char parsers/generators
char_ "" ".*qi.reference.char\..*" qi_index
@@ -269,7 +281,7 @@
_pass "" ".*karma.quick_reference.phoenix.*" karma_index
###############################################################################
-#!exclude N
+#!exclude N
#!exclude type iterator Auto call where: f info derived_type subject_type
#!exclude if floatfield precision trailing_zeros force_sign in pointer
#!exclude result_type value_type difference_type assign clear
Modified: branches/release/libs/spirit/doc/karma/binary.qbk
==============================================================================
--- branches/release/libs/spirit/doc/karma/binary.qbk (original)
+++ branches/release/libs/spirit/doc/karma/binary.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -44,6 +44,8 @@
[[`boost::spirit::word // alias: boost::spirit::karma::word` ]]
[[`boost::spirit::dword // alias: boost::spirit::karma::dword` ]]
[[`boost::spirit::qword // alias: boost::spirit::karma::qword` ]]
+ [[`boost::spirit::bin_float // alias: boost::spirit::karma::bin_float` ]]
+ [[`boost::spirit::bin_double // alias: boost::spirit::karma::bin_double` ]]
]
[note The generators `qword` and `qword(qw)` are only available on
@@ -67,6 +69,12 @@
[[`qw`] [A 64 bit binary value or a __karma_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
interpreted using native endianness.]]
+ [[`f`] [A float binary value or a __karma_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ interpreted using native endianness.]]
+ [[`d`] [A double binary value or a __karma_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ interpreted using native endianness.]]
]
[heading Expression Semantics]
@@ -95,6 +103,14 @@
in native endian representation. This generator
never fails (unless the underlying output stream
reports an error).]]
+ [[`bin_float`] [Output the binary representation of the mandatory
+ float attribute in native endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`bin_double`] [Output the binary representation of the mandatory
+ double attribute in native endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
[[`byte_(b)`] [Output the binary representation of the least
significant byte of the immediate parameter. This
generator never fails (unless the underlying
@@ -114,6 +130,14 @@
in native endian representation. This generator
never fails (unless the underlying output stream
reports an error).]]
+ [[`bin_float(f)`] [Output the binary representation of the immediate
+ float parameter in native endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`bin_double(d)`] [Output the binary representation of the immediate
+ double parameter in native endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
]
[heading Attributes]
@@ -128,10 +152,16 @@
(otherwise compilation will fail)]]
[[`qword`] [`boost::uint_least64_t`, attribute is mandatory
(otherwise compilation will fail)]]
+ [[`bin_float`] [`float`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`bin_double`] [`double`, attribute is mandatory
+ (otherwise compilation will fail)]]
[[`byte_(b)`] [__unused__]]
[[`word(w)`] [__unused__]]
[[`dword(dw)`] [__unused__]]
[[`qword(qw)`] [__unused__]]
+ [[`bin_float(f)`] [__unused__]]
+ [[`bin_double(d)`] [__unused__]]
]
[note In addition to their usual attribute of type `Attrib` all listed generators
@@ -192,6 +222,8 @@
[[`boost::spirit::little_word // alias: boost::spirit::karma::little_word` ]]
[[`boost::spirit::little_dword // alias: boost::spirit::karma::little_dword` ]]
[[`boost::spirit::little_qword // alias: boost::spirit::karma::little_qword` ]]
+ [[`boost::spirit::little_bin_float // alias: boost::spirit::karma::little_bin_float` ]]
+ [[`boost::spirit::little_bin_double // alias: boost::spirit::karma::little_bin_double` ]]
]
[note The generators `little_qword` and `little_qword(qw)` are only available on
@@ -213,6 +245,12 @@
[[`qw`] [A 64 bit binary value or a __karma_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
interpreted using native endianness.]]
+ [[`f`] [A float binary value or a __karma_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ interpreted using native endianness.]]
+ [[`d`] [A double binary value or a __karma_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ interpreted using native endianness.]]
]
[heading Expression Semantics]
@@ -221,52 +259,74 @@
not defined in __primitive_generator_concept__.
[table
- [[Expression] [Description]]
- [[`little_word`] [Output the binary representation of the least
- significant 16 bits of the mandatory attribute
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
- [[`little_dword`] [Output the binary representation of the least
- significant 32 bits of the mandatory attribute
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
- [[`little_qword`] [Output the binary representation of the least
- significant 64 bits of the mandatory attribute
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
- [[`little_word(w)`] [Output the binary representation of the least
- significant 16 bits of the immediate parameter
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
- [[`little_dword(dw)`] [Output the binary representation of the least
- significant 32 bits of the immediate parameter
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
- [[`little_qword(qw)`] [Output the binary representation of the least
- significant 64 bits of the immediate parameter
- in little endian representation. This generator
- never fails (unless the underlying output stream
- reports an error).]]
+ [[Expression] [Description]]
+ [[`little_word`] [Output the binary representation of the least
+ significant 16 bits of the mandatory attribute
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_dword`] [Output the binary representation of the least
+ significant 32 bits of the mandatory attribute
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_qword`] [Output the binary representation of the least
+ significant 64 bits of the mandatory attribute
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_bin_float`] [Output the binary representation of the mandatory
+ float attribute in little endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`little_bin_double`] [Output the binary representation of the mandatory
+ double attribute in little endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`little_word(w)`] [Output the binary representation of the least
+ significant 16 bits of the immediate parameter
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_dword(dw)`] [Output the binary representation of the least
+ significant 32 bits of the immediate parameter
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_qword(qw)`] [Output the binary representation of the least
+ significant 64 bits of the immediate parameter
+ in little endian representation. This generator
+ never fails (unless the underlying output stream
+ reports an error).]]
+ [[`little_bin_float(f)`] [Output the binary representation of the immediate
+ float parameter in little endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`little_bin_double(d)`] [Output the binary representation of the immediate
+ double parameter in little endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
]
[heading Attributes]
[table
- [[Expression] [Attribute]]
- [[`little_word`] [`boost::uint_least16_t`, attribute is mandatory
- (otherwise compilation will fail)]]
- [[`little_dword`] [`boost::uint_least32_t`, attribute is mandatory
- (otherwise compilation will fail)]]
- [[`little_qword`] [`boost::uint_least64_t`, attribute is mandatory
- (otherwise compilation will fail)]]
- [[`little_word(w)`] [__unused__]]
- [[`little_dword(dw)`] [__unused__]]
- [[`little_qword(qw)`] [__unused__]]
+ [[Expression] [Attribute]]
+ [[`little_word`] [`boost::uint_least16_t`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`little_dword`] [`boost::uint_least32_t`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`little_qword`] [`boost::uint_least64_t`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`little_bin_float`] [`float`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`little_bin_double`] [`double`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`little_word(w)`] [__unused__]]
+ [[`little_dword(dw)`] [__unused__]]
+ [[`little_qword(qw)`] [__unused__]]
+ [[`little_bin_float(f)`] [__unused__]]
+ [[`little_bin_double(d)`] [__unused__]]
]
[heading Complexity]
@@ -315,6 +375,8 @@
[[`boost::spirit::big_word // alias: boost::spirit::karma::big_word` ]]
[[`boost::spirit::big_dword // alias: boost::spirit::karma::big_dword` ]]
[[`boost::spirit::big_qword // alias: boost::spirit::karma::big_qword` ]]
+ [[`boost::spirit::big_bin_float // alias: boost::spirit::karma::big_bin_float` ]]
+ [[`boost::spirit::big_bin_double // alias: boost::spirit::karma::big_bin_double` ]]
]
[note The generators `big_qword` and `big_qword(qw)` are only available on
@@ -336,6 +398,12 @@
[[`qw`] [A 64 bit binary value or a __karma_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
interpreted using native endianness.]]
+ [[`f`] [A float binary value or a __karma_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ interpreted using native endianness.]]
+ [[`d`] [A double binary value or a __karma_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ interpreted using native endianness.]]
]
[heading Expression Semantics]
@@ -360,6 +428,14 @@
in big endian representation. This generator
never fails (unless the underlying output stream
reports an error).]]
+ [[`big_bin_float`] [Output the binary representation of the mandatory
+ float attribute in big endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`big_bin_double`] [Output the binary representation of the mandatory
+ double attribute in big endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
[[`big_word(w)`] [Output the binary representation of the least
significant 16 bits of the immediate parameter
in big endian representation. This generator
@@ -375,6 +451,14 @@
in big endian representation. This generator
never fails (unless the underlying output stream
reports an error).]]
+ [[`big_bin_float(f)`] [Output the binary representation of the immediate
+ float parameter in big endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
+ [[`big_bin_double(d)`] [Output the binary representation of the immediate
+ double parameter in big endian representation.
+ This generator never fails (unless the underlying
+ output stream reports an error).]]
]
[heading Attributes]
@@ -387,9 +471,15 @@
(otherwise compilation will fail)]]
[[`big_qword`] [`boost::uint_least64_t`, attribute is mandatory
(otherwise compilation will fail)]]
+ [[`big_bin_float`] [`float`, attribute is mandatory
+ (otherwise compilation will fail)]]
+ [[`big_bin_double`] [`double`, attribute is mandatory
+ (otherwise compilation will fail)]]
[[`big_word(w)`] [__unused__]]
[[`big_dword(dw)`] [__unused__]]
[[`big_qword(qw)`] [__unused__]]
+ [[`big_bin_float(f)`] [__unused__]]
+ [[`big_bin_double(d)`] [__unused__]]
]
[heading Complexity]
Modified: branches/release/libs/spirit/doc/qi/binary.qbk
==============================================================================
--- branches/release/libs/spirit/doc/qi/binary.qbk (original)
+++ branches/release/libs/spirit/doc/qi/binary.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -43,6 +43,8 @@
[[`boost::spirit::word // alias: boost::spirit::qi::word`]]
[[`boost::spirit::dword // alias: boost::spirit::qi::dword`]]
[[`boost::spirit::qword // alias: boost::spirit::qi::qword`]]
+ [[`boost::spirit::bin_float // alias: boost::spirit::qi::bin_float`]]
+ [[`boost::spirit::bin_double // alias: boost::spirit::qi::bin_double`]]
]
[note `qword` is only available on platforms where the preprocessor
@@ -66,6 +68,12 @@
[[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
in native endian.]]
+ [[`f`] [A float binary value or a __qi_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ in native endian.]]
+ [[`d`] [A double binary value or a __qi_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ in native endian.]]
]
[heading Expression Semantics]
@@ -79,10 +87,14 @@
[[`word`] [Matches any 16 bit native endian binary.]]
[[`dword`] [Matches any 32 bit native endian binary.]]
[[`qword`] [Matches any 64 bit native endian binary.]]
+ [[`bin_float`] [Matches any float native endian binary.]]
+ [[`bin_double`] [Matches any double native endian binary.]]
[[`byte_(b)`] [Matches an exact 8 bit native endian binary.]]
[[`word(w)`] [Matches an exact 16 bit native endian binary.]]
[[`dword(dw)`] [Matches an exact 32 bit native endian binary.]]
[[`qword(qw)`] [Matches an exact 64 bit native endian binary.]]
+ [[`bin_float(f)`] [Matches an exact float native endian binary.]]
+ [[`bin_double(d)`] [Matches an exact double native endian binary.]]
]
[heading Attributes]
@@ -93,10 +105,14 @@
[[`word`] [`boost::uint_least16_t`]]
[[`dword`] [`boost::uint_least32_t`]]
[[`qword`] [`boost::uint_least64_t`]]
+ [[`bin_float`] [`float`]]
+ [[`bin_double`] [`double`]]
[[`byte_(b)`] [__unused__]]
[[`word(w)`] [__unused__]]
[[`dword(dw)`] [__unused__]]
[[`qword(qw)`] [__unused__]]
+ [[`bin_float(f)`] [__unused__]]
+ [[`bin_double(d)`] [__unused__]]
]
[heading Complexity]
@@ -131,9 +147,11 @@
[table
[[Name]]
- [[`boost::spirit::little_word // alias: boost::spirit::qi::little_word` ]]
- [[`boost::spirit::little_dword // alias: boost::spirit::qi::little_dword` ]]
- [[`boost::spirit::little_qword // alias: boost::spirit::qi::little_qword` ]]
+ [[`boost::spirit::little_word // alias: boost::spirit::qi::little_word` ]]
+ [[`boost::spirit::little_dword // alias: boost::spirit::qi::little_dword` ]]
+ [[`boost::spirit::little_qword // alias: boost::spirit::qi::little_qword` ]]
+ [[`boost::spirit::little_bin_float // alias: boost::spirit::qi::little_bin_float` ]]
+ [[`boost::spirit::little_bin_double // alias: boost::spirit::qi::little_bin_double` ]]
]
[note `little_qword` is only available on platforms where the
@@ -155,6 +173,12 @@
[[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
in native endian.]]
+ [[`f`] [A float binary value or a __qi_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ in native endian.]]
+ [[`d`] [A double binary value or a __qi_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ in native endian.]]
]
[heading Expression Semantics]
@@ -163,25 +187,33 @@
not defined in __primitive_parser_concept__.
[table
- [[Expression] [Description]]
- [[`little_word`] [Matches any 16 bit little endian binary.]]
- [[`little_dword`] [Matches any 32 bit little endian binary.]]
- [[`little_qword`] [Matches any 64 bit little endian binary.]]
- [[`little_word(w)`] [Matches an exact 16 bit little endian binary.]]
- [[`little_dword(dw)`] [Matches an exact 32 bit little endian binary.]]
- [[`little_qword(qw)`] [Matches an exact 32 bit little endian binary.]]
+ [[Expression] [Description]]
+ [[`little_word`] [Matches any 16 bit little endian binary.]]
+ [[`little_dword`] [Matches any 32 bit little endian binary.]]
+ [[`little_qword`] [Matches any 64 bit little endian binary.]]
+ [[`little_bin_float`] [Matches any float little endian binary.]]
+ [[`little_bin_double`] [Matches any double little endian binary.]]
+ [[`little_word(w)`] [Matches an exact 16 bit little endian binary.]]
+ [[`little_dword(dw)`] [Matches an exact 32 bit little endian binary.]]
+ [[`little_qword(qw)`] [Matches an exact 32 bit little endian binary.]]
+ [[`little_bin_float(f)`] [Matches an exact float little endian binary.]]
+ [[`little_bin_double(d)`] [Matches an exact double little endian binary.]]
]
[heading Attributes]
[table
- [[Expression] [Attribute]]
- [[`little_word`] [`boost::uint_least16_t`]]
- [[`little_dword`] [`boost::uint_least32_t`]]
- [[`little_qword`] [`boost::uint_least64_t`]]
- [[`little_word(w)`] [__unused__]]
- [[`little_dword(dw)`] [__unused__]]
- [[`little_qword(qw)`] [__unused__]]
+ [[Expression] [Attribute]]
+ [[`little_word`] [`boost::uint_least16_t`]]
+ [[`little_dword`] [`boost::uint_least32_t`]]
+ [[`little_qword`] [`boost::uint_least64_t`]]
+ [[`little_bin_float`] [`float`]]
+ [[`little_bin_double`] [`double`]]
+ [[`little_word(w)`] [__unused__]]
+ [[`little_dword(dw)`] [__unused__]]
+ [[`little_qword(qw)`] [__unused__]]
+ [[`little_bin_float(f)`] [__unused__]]
+ [[`little_bin_double(d)`] [__unused__]]
]
[heading Complexity]
@@ -216,9 +248,11 @@
[table
[[Name]]
- [[`boost::spirit::big_word // alias: boost::spirit::qi::big_word` ]]
- [[`boost::spirit::big_dword // alias: boost::spirit::qi::big_dword` ]]
- [[`boost::spirit::big_qword // alias: boost::spirit::qi::big_qword` ]]
+ [[`boost::spirit::big_word // alias: boost::spirit::qi::big_word` ]]
+ [[`boost::spirit::big_dword // alias: boost::spirit::qi::big_dword` ]]
+ [[`boost::spirit::big_qword // alias: boost::spirit::qi::big_qword` ]]
+ [[`boost::spirit::big_bin_float // alias: boost::spirit::qi::big_bin_float` ]]
+ [[`boost::spirit::big_bin_double // alias: boost::spirit::qi::big_bin_double` ]]
]
[note `big_qword` is only available on platforms where the
@@ -240,6 +274,12 @@
[[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
evaluates to a 64 bit binary value. This value is always
in native endian.]]
+ [[`f`] [A float binary value or a __qi_lazy_argument__ that
+ evaluates to a float binary value. This value is always
+ in native endian.]]
+ [[`d`] [A double binary value or a __qi_lazy_argument__ that
+ evaluates to a double binary value. This value is always
+ in native endian.]]
]
[heading Expression Semantics]
@@ -252,9 +292,13 @@
[[`big_word`] [Matches any 16 bit big endian binary.]]
[[`big_dword`] [Matches any 32 bit big endian binary.]]
[[`big_qword`] [Matches any 64 bit big endian binary.]]
+ [[`big_bin_float`] [Matches any float big endian binary.]]
+ [[`big_bin_double`] [Matches any double big endian binary.]]
[[`big_word(w)`] [Matches an exact 16 bit big endian binary.]]
[[`big_dword(dw)`] [Matches an exact 32 bit big endian binary.]]
[[`big_qword(qw)`] [Matches an exact 32 bit big endian binary.]]
+ [[`big_bin_float(f)`] [Matches an exact float big endian binary.]]
+ [[`big_bin_double(d)`] [Matches an exact double big endian binary.]]
]
[heading Attributes]
@@ -264,9 +308,13 @@
[[`big_word`] [`boost::uint_least16_t`]]
[[`big_dword`] [`boost::uint_least32_t`]]
[[`big_qword`] [`boost::uint_least64_t`]]
+ [[`big_bin_float`] [`float`]]
+ [[`big_bin_double`] [`double`]]
[[`big_word(w)`] [__unused__]]
[[`big_dword(dw)`] [__unused__]]
[[`big_qword(qw)`] [__unused__]]
+ [[`big_bin_float(f)`] [__unused__]]
+ [[`big_bin_double(d)`] [__unused__]]
]
[heading Complexity]
Modified: branches/release/libs/spirit/doc/qi/error_handling.qbk
==============================================================================
--- branches/release/libs/spirit/doc/qi/error_handling.qbk (original)
+++ branches/release/libs/spirit/doc/qi/error_handling.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -80,7 +80,7 @@
[[Arg] [Description]]
[[first] [The position of the iterator when the rule with the handler was entered.]]
[[last] [The end of input.]]
- [[error-pos] [The actual position of the iterator where the error occurred.]]
+ [[error-pos] [The actual position of the iterator where the error occured.]]
[[what] [What failed: a string describing the failure.]]
]
Modified: branches/release/libs/spirit/doc/qi/quick_reference.qbk
==============================================================================
--- branches/release/libs/spirit/doc/qi/quick_reference.qbk (original)
+++ branches/release/libs/spirit/doc/qi/quick_reference.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -93,10 +93,10 @@
[[[qi_real_number `float_(num)`]] [`float`] [Parse a floating point number into a `float`,
a number is matched only if it's `num`]]
[[[qi_real_number `double_`]] [`double`] [Parse a floating point number into a `double`]]
- [[[qi_real_number `double_`]] [`double`] [Parse a floating point number into a `double`,
+ [[[qi_real_number `double_(num)`]] [`double`] [Parse a floating point number into a `double`,
a number is matched only if it's `num`]]
[[[qi_real_number `long_double`]] [`long double`] [Parse a floating point number into a `long double`]]
- [[[qi_real_number `long_double`]] [`long double`] [Parse a floating point number into a `long double`,
+ [[[qi_real_number `long_double(num)`]] [`long double`] [Parse a floating point number into a `long double`,
a number is matched only if it's `num`]]
[[[qi_unsigned_int `bin`]] [`unsigned`] [Parse a binary integer into an `unsigned`]]
Modified: branches/release/libs/spirit/doc/spirit2.qbk
==============================================================================
--- branches/release/libs/spirit/doc/spirit2.qbk (original)
+++ branches/release/libs/spirit/doc/spirit2.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -8,7 +8,7 @@
[article Spirit
[quickbook 1.5]
- [version 2.5.1]
+ [version 2.5.2]
[authors [de Guzman, Joel], [Kaiser, Hartmut]]
[copyright 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 Joel de Guzman, Hartmut Kaiser]
[/ purpose Parser and Generator Library]
@@ -23,7 +23,7 @@
[/ Some links ]
-[def __version__ V2.5.1]
+[def __version__ V2.5.2]
[def __spirit__ [@http://boost-spirit.com Spirit]]
[def __spirit_list__ [@http://www.nabble.com/The-Spirit-Parser-Library-f3430.html Spirit General List]]
Modified: branches/release/libs/spirit/doc/what_s_new.qbk
==============================================================================
--- branches/release/libs/spirit/doc/what_s_new.qbk (original)
+++ branches/release/libs/spirit/doc/what_s_new.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -9,25 +9,47 @@
[section What's New]
[/////////////////////////////////////////////////////////////////////////////]
+[section:spirit_2_5_2 Spirit V2.5.2]
+
+[heading What's changed from V2.5.1 (Boost V1.48.0) to V2.5.2 (Boost V1.49.0)]
+
+* Integrated Vitaly Budovski's patch to add binary floating point parsers and
+ generators.
+* Fixed #6253: `lex::lexertl::generate_static_dfa` compiler errors if lexer has
+ wchar_t as underlying stream type.
+* Added the possibility to match a token range when parsing with a lexer by
+ using `qi::token(min, max)`, or `qi::tokenid(min, max)`. Both parsers match
+ any token with a token id in the range [min, max].
+* Fixed a problem in [karma_align `center`]`(num)[a]` and
+ [karma_align `center`]`(num, g)[a]` if used inside a compound generator (such
+ as sequences, Kleene, list, or plus.
+* Fixed `karma::subrule` from the [@../../repository/doc/html/index.html repository]
+ (thanks to Lee Clagett for submitting a patch).
+* Fixed __karma__ examples (thanks to Lee Clagett for submitting a patch).
+* Fixed #6368: [multi_pass] clear_queue isn't forwarded to the storage policy.
+
+[endsect]
+
+[/////////////////////////////////////////////////////////////////////////////]
[section:spirit_2_5_1 Spirit V2.5.1]
[heading What's changed from V2.5 (Boost V1.47.0) to V2.5.1 (Boost V1.48.0)]
-* The `spirit::istream_iterator` (see __multi_pass__) now checks at
+* The `spirit::istream_iterator` (see __multi_pass__) now checks at
construction time whether the underlying stream has reached eof (end of file).
-* __qi__ now properly collapses attributes generated from optionals embedded
+* __qi__ now properly collapses attributes generated from optionals embedded
inside another optional parser (i.e. `-('(' > -int_ >> ')'). That means that
- attributes like `boost::optiona<boost::optional<int> >` will be collapsed
- to `boost::optional<int>`. Thanks to Peter Schueller for reporting that
+ attributes like `boost::optional<boost::optional<int> >` will be collapsed
+ to `boost::optional<int>`. Thanks to Peter Schueller for reporting that
problem.
-* Actions attached to binary parsers now properly propagate the parser's
+* Actions attached to binary parsers now properly propagate the parser's
attribute. Thanks to Mathias Born for reporting this issue.
[heading Bug Fixes in Lex]
-* Fixed Boost ticket #5701: lexertl token_value_type returns const unused for
+* Fixed Boost ticket #5701: lexertl token_value_type returns const unused for
nonconst ref.
-* Fixed a problem in the lexer (position_token) causing problems with enabled
+* Fixed a problem in the lexer (position_token) causing problems with enabled
parser debugging (MSVC2010).
[endsect]
@@ -79,7 +101,7 @@
This change unifies the handling of the `_val` placeholder allowing to use it
everywhere, not only in semantic actions attached to the right hand sides of
a rule.
-* Added support for __karma__ [unsigned_int unsigned numeric generators] with
+* Added support for __karma__ [unsigned_int unsigned numeric generators] with
arbitrary radix values in the (inclusive) range from `2` .. `36`.
[heading Bug Fixes in Qi or Karma]
@@ -122,14 +144,14 @@
using `lex::char_` and `lex::string`. Both primitives now accept a second
parameter which will be interpreted as the requested token id for any token
generated from this definition.
-* Added a new token type `lex::lexertl::position_token<>`, which is essentially
+* Added a new token type `lex::lexertl::position_token<>`, which is essentially
plup-in compatible with the existing `lex::lexertl::token<>` class. However
- it additionally stores the pair of iterators pointing to the underlying
+ it additionally stores the pair of iterators pointing to the underlying
matched input sequence as an iterator_range.
[heading Bug Fixes in Lex]
-* Fixed a problem with associating token definitions with all states (using
+* Fixed a problem with associating token definitions with all states (using
`"*"` as the state name) when actions were attached to them.
[heading Making Stuff Work]
Modified: branches/release/libs/spirit/repository/doc/qi/seek.qbk
==============================================================================
--- branches/release/libs/spirit/repository/doc/qi/seek.qbk (original)
+++ branches/release/libs/spirit/repository/doc/qi/seek.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -59,21 +59,31 @@
[heading Complexity]
-[:The complexity is defined by the complexity of the subject parser, `a`]
+[:The overall complexity is defined by the complexity of its subject
+parser. The complexity of `seek` itself is O(N), where N is the number
+of unsuccessful matches.]
+
+[note *seeking sequence with skipping*
+
+Using `seek[a >> b]` with skipping is inefficient, because when sequence fails, the backtracked position is non-skipped.
+The solution is to ensure the input will always be pre-skipped, for example:
+``
+ seek[lexeme[skip[a >> b]]]
+``
+does the trick.]
[heading Example]
[import ../../example/qi/seek.cpp]
-The following example shows a simple use case of the `seek[]` directive, seeking
-all the ints preceding by `'#'`.
+The following example shows a simple use case of the `seek[]` directive, parsing C-style comment.
(For the full source of the example, see [@../../example/qi/seek.cpp seek.cpp])
Some namespace aliases:
[reference_qi_seek_namespace]
-The input iterators and the attribute to store the result:
+The input string and its iterators:
[reference_qi_seek_vars]
@@ -81,18 +91,4 @@
[reference_qi_seek_parse]
-Input:
-
-[pre
-1 will not be outputted while #2, ##3 and # 4 will.
-]
-
-Output:
-
-[pre
---------------------------------
-Parsing succeeded, got: \[ 2, 3, 4 \]
----------------------------------
-]
-
[endsect]
Modified: branches/release/libs/spirit/repository/doc/spirit2_repository.qbk
==============================================================================
--- branches/release/libs/spirit/repository/doc/spirit2_repository.qbk (original)
+++ branches/release/libs/spirit/repository/doc/spirit2_repository.qbk 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -44,6 +44,7 @@
[def __qi_confix__ [link spirit_repository.qi_components.directives.confix `confix`]]
[def __qi_keywords__ [link spirit_repository.qi_components.operators.keyword_list keyword_list]]
[def __qi_keywords_list__ [link spirit_repository.qi_components.directives.kwd `kwd()[]`]]
+[def __qi_seek__ [link spirit_repository.qi_components.directives.seek `seek[]`]]
[def __karma_subrule__ [link spirit_repository.karma_components.nonterminal.subrule `subrule`]]
@@ -104,6 +105,8 @@
[include preface.qbk]
+[include what_s_new.qbk]
+
[include qi.qbk]
[include karma.qbk]
Modified: branches/release/libs/spirit/repository/example/karma/calc2_ast.hpp
==============================================================================
--- branches/release/libs/spirit/repository/example/karma/calc2_ast.hpp (original)
+++ branches/release/libs/spirit/repository/example/karma/calc2_ast.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2010 Joel de Guzman
- Copyright (c) 2001-2010 Hartmut Kaiser
+ Copyright (c) 2001-2012 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)
@@ -19,10 +19,11 @@
#define SPIRIT_EXAMPLE_CALC2_AST_APR_30_2008_1011AM
#include <boost/variant.hpp>
-#include <boost/variant/get.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
+#include <boost/spirit/home/karma/domain.hpp>
+#include <boost/spirit/include/support_attributes_fwd.hpp>
///////////////////////////////////////////////////////////////////////////////
// Our AST
@@ -42,7 +43,7 @@
>
type;
- // expose variant types
+ // expose variant types
typedef type::types types;
// expose variant functionality
@@ -82,16 +83,26 @@
return boost::get<T>(expr.expr);
}
- // the specialization below tells Spirit to handle expression_ast as if it
+ // the specialization below tells Spirit to handle expression_ast as if it
// where a 'real' variant
namespace spirit { namespace traits
{
- template <typename T>
- struct not_is_variant;
-
+ // the specialization below tells Spirit to handle expression_ast as
+ // if it where a 'real' variant (if used with Spirit.Karma)
template <>
- struct not_is_variant<expression_ast>
+ struct not_is_variant<expression_ast, karma::domain>
: mpl::false_ {};
+
+ // the specialization of variant_which allows to generically extract
+ // the current type stored in the given variant like type
+ template <>
+ struct variant_which<expression_ast>
+ {
+ static int call(expression_ast const& v)
+ {
+ return v.which();
+ }
+ };
}}
}
Modified: branches/release/libs/spirit/repository/example/qi/seek.cpp
==============================================================================
--- branches/release/libs/spirit/repository/example/qi/seek.cpp (original)
+++ branches/release/libs/spirit/repository/example/qi/seek.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -5,15 +5,13 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//////////////////////////////////////////////////////////////////////////////*/
-// [ Jamboree May 3, 2011 ] first ver.
-// [ Jamboree Aug 13, 2011 ] minor change.
+// [ Jamboree Oct 27, 2011 ] new example.
#include <cstdlib>
#include <iostream>
#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/repository/include/qi_seek.hpp>
@@ -21,36 +19,30 @@
{
//[reference_qi_seek_namespace
namespace qi = boost::spirit::qi;
- namespace ka = boost::spirit::karma;
namespace repo = boost::spirit::repository;
//]
-
- std::string line;
+
typedef std::string::const_iterator iterator;
- while (std::cout << ">>> ", std::getline(std::cin, line))
+ //[reference_qi_seek_vars
+ std::string str("/*C-style comment*/");
+ iterator it = str.begin();
+ iterator end = str.end();
+ //]
+
+ //[reference_qi_seek_parse
+ if (qi::parse(it, end, "/*" >> repo::qi::seek["*/"]))
{
- //[reference_qi_seek_vars
- iterator it = line.begin();
- iterator end = line.end();
- std::vector<int> val;
- //]
-
- //[reference_qi_seek_parse
- if (qi::phrase_parse(it, end, +repo::qi::seek["#" >> qi::int_], qi::space, val))
- {
- std::cout << "-------------------------------- \n";
- std::cout << "Parsing succeeded, got: "
- << ka::format("[ " << ka::int_ % ", " << " ]\n", val);
- std::cout << "---------------------------------\n";
- }//]
- else
- {
- std::cout << "-------------------------------- \n";
- std::cout << "Parsing failed, rest: " << std::string(it, end) << "\n";
- std::cout << "-------------------------------- \n";
- }
+ std::cout << "-------------------------------- \n";
+ std::cout << "Parsing succeeded.\n";
+ std::cout << "---------------------------------\n";
}
+ else
+ {
+ std::cout << "-------------------------------- \n";
+ std::cout << "Unterminated /* comment.\n";
+ std::cout << "-------------------------------- \n";
+ }//]
return EXIT_SUCCESS;
}
Modified: branches/release/libs/spirit/test/Jamfile
==============================================================================
--- branches/release/libs/spirit/test/Jamfile (original)
+++ branches/release/libs/spirit/test/Jamfile 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -1,6 +1,6 @@
#==============================================================================
# Copyright (c) 2001-2011 Joel de Guzman
-# Copyright (c) 2001-2011 Hartmut Kaiser
+# Copyright (c) 2001-2012 Hartmut Kaiser
# Copyright (c) 2011 Bryce Lelbach
#
# Use, modification and distribution is subject to the Boost Software
@@ -15,9 +15,9 @@
###############################################################################
# new feature definition allowing to switch between Phoenix V2 and V3 tests
-feature.feature phoenix_v3
+feature.feature phoenix_v3
: off on
- : composite propagated
+ : composite propagated
;
feature.compose <phoenix_v3>on
@@ -33,10 +33,10 @@
:
:
;
-
+
v2_tests = ;
v3_tests = ;
-
+
rule run ( sources + : args * : input-files * : requirements * : target-name ? : default-build * )
{
target-name ?= $(sources[1]:D=:S=) ;
@@ -57,7 +57,7 @@
v2_tests += [ testing.compile-fail $(sources) : $(requirements) : $(target-name)-p2 ] ;
v3_tests += [ testing.compile-fail $(sources) : $(requirements) <phoenix_v3>on : $(target-name)-p3 ] ;
}
-
+
###############################################################################
path-constant LEX_DIR : $(BOOST_ROOT)/libs/spirit/test/lex ;
@@ -249,6 +249,7 @@
[ run karma/regression_optional_double.cpp : : : : karma_regression_optional_double ]
[ run karma/regression_semantic_action_attribute.cpp : : : : karma_regression_semantic_action_attribute ]
[ run karma/regression_real_scientific.cpp : : : : karma_regression_real_scientific ]
+ [ run karma/regression_center_alignment.cpp : : : : karma_regression_center_alignment ]
;
@@ -282,13 +283,13 @@
[ run lex/regression_basic_lexer.cpp : : : : lex_regression_basic_lexer ]
[ run lex/regression_matlib_dynamic.cpp : : : : lex_regression_matlib_dynamic ]
[ run lex/regression_matlib_generate.cpp : $(LEX_DIR)/matlib_static.h : : : lex_regression_matlib_generate ]
- [ run lex/regression_matlib_static.cpp : : :
+ [ run lex/regression_matlib_static.cpp : : :
<phoenix_v3>on:<dependency>.//lex_regression_matlib_generate-p3
<phoenix_v3>off:<dependency>.//lex_regression_matlib_generate-p2
: lex_regression_matlib_static ]
[ run lex/regression_matlib_generate_switch.cpp : $(LEX_DIR)/matlib_static_switch.h : : : lex_regression_matlib_generate_switch ]
- [ run lex/regression_matlib_switch.cpp : : :
- <phoenix_v3>on:<dependency>.//lex_regression_matlib_generate_switch-p3
+ [ run lex/regression_matlib_switch.cpp : : :
+ <phoenix_v3>on:<dependency>.//lex_regression_matlib_generate_switch-p3
<phoenix_v3>off:<dependency>.//lex_regression_matlib_generate_switch-p2
: lex_regression_matlib_switch ]
[ run lex/regression_word_count.cpp : : : : lex_regression_word_count ]
@@ -298,6 +299,7 @@
[ run lex/regression_file_iterator2.cpp : : : : lex_regression_file_iterator2 ]
[ run lex/regression_file_iterator3.cpp : : : : lex_regression_file_iterator3 ]
[ run lex/regression_file_iterator4.cpp : : : : lex_regression_file_iterator4 ]
+ [ run lex/regression_static_wide_6253.cpp : : : : regression_static_wide_6253 ]
;
@@ -330,8 +332,9 @@
# while running the regerssion tests.
#
# If you want to avoid running tests for both Phoenix V2 and V3 by default
-# then simply uncomment the following 'explicit' command. If no target is
+# then simply uncomment the following 'explicit' command. If no target is
# specified, only the V2 tests will be run.
-#
-# explicit test_using_phoenix_v2 test_using_phoenix_v3 ;
+#
+
+explicit test_using_phoenix_v2 test_using_phoenix_v3 ;
Modified: branches/release/libs/spirit/test/karma/binary1.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/binary1.cpp (original)
+++ branches/release/libs/spirit/test/karma/binary1.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -39,6 +39,9 @@
BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, qword,
0x0807060504030281LL));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float, 1.0f));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double, 1.0));
BOOST_TEST(binary_test_delimited("\x01\x00\x00\x00", 4, byte_, 0x01, pad(4)));
BOOST_TEST(binary_test_delimited("\x01\x02\x00\x00", 4, word, 0x0201, pad(4)));
@@ -47,6 +50,10 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00", 10,
qword, 0x0807060504030201LL, pad(10)));
#endif
+ BOOST_TEST(binary_test_delimited("\x00\x00\x80\x3f", 4, bin_float,
+ 1.0f, pad(4)));
+ BOOST_TEST(binary_test_delimited("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double, 1.0, pad(8)));
#else // BOOST_LITTLE_ENDIAN
@@ -62,6 +69,9 @@
BOOST_TEST(binary_test("\x81\x02\x03\x04\x05\x06\x07\x08", 8, qword,
0x8102030405060708LL));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float, 1.0f));
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, 1.0));
BOOST_TEST(binary_test_delimited("\x01\x00\x00\x00", 4, byte_, 0x01, pad(4)));
BOOST_TEST(binary_test_delimited("\x01\x02\x00\x00", 4, word, 0x0102, pad(4)));
@@ -70,6 +80,10 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00", 10,
qword, 0x0102030405060708LL, pad(10)));
#endif
+ BOOST_TEST(binary_test_delimited("\x3f\x80\x00\x00", 4, bin_float,
+ 1.0f, pad(4)));
+ BOOST_TEST(binary_test_delimited("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, 1.0, pad(8)));
#endif
}
@@ -82,6 +96,9 @@
BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
qword(0x0807060504030201LL)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double(1.0)));
#else
BOOST_TEST(binary_test("\x01", 1, byte_(0x01)));
BOOST_TEST(binary_test("\x01\x02", 2, word(0x0102)));
@@ -90,6 +107,9 @@
BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8,
qword(0x0102030405060708LL)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double(1.0)));
#endif
}
Modified: branches/release/libs/spirit/test/karma/binary2.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/binary2.cpp (original)
+++ branches/release/libs/spirit/test/karma/binary2.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -38,6 +38,11 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
10, big_qword, 0x0102030405060708LL, pad(10)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, big_bin_float, 1.0f));
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ big_bin_double, 1.0));
+ BOOST_TEST(binary_test_delimited("\x3f\xf0\x00\x00\x00\x00\x00\x00\x00\x00",
+ 10, big_bin_double, 1.0, pad(10)));
}
{
@@ -49,6 +54,11 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
10, big_qword(0x0102030405060708LL), pad(10)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, big_bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ big_bin_double(1.0)));
+ BOOST_TEST(binary_test_delimited("\x3f\xf0\x00\x00\x00\x00\x00\x00\x00\x00",
+ 10, big_bin_double(1.0), pad(10)));
}
{ // test little endian binaries
@@ -64,6 +74,11 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
10, little_qword, 0x0807060504030201LL, pad(10)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, little_bin_float, 1.0f));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ little_bin_double, 1.0));
+ BOOST_TEST(binary_test_delimited("\x00\x00\x00\x00\x00\x00\xf0\x3f\x00\x00",
+ 10, little_bin_double, 1.0, pad(10)));
}
{
@@ -75,12 +90,19 @@
BOOST_TEST(binary_test_delimited("\x01\x02\x03\x04\x05\x06\x07\x08\x00\x00",
10, little_qword(0x0807060504030201LL), pad(10)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, little_bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ little_bin_double(1.0)));
+ BOOST_TEST(binary_test_delimited("\x00\x00\x00\x00\x00\x00\xf0\x3f\x00\x00",
+ 10, little_bin_double(1.0), pad(10)));
}
{ // test native endian binaries
boost::optional<boost::uint8_t> v8;
boost::optional<boost::uint16_t> v16;
boost::optional<boost::uint32_t> v32;
+ boost::optional<float> vf;
+ boost::optional<double> vd;
#ifdef BOOST_LITTLE_ENDIAN
@@ -91,6 +113,8 @@
boost::optional<boost::uint64_t> v64;
BOOST_TEST(!binary_test("", 8, qword, v64));
#endif
+ BOOST_TEST(!binary_test("", 4, bin_float, vf));
+ BOOST_TEST(!binary_test("", 8, bin_double, vd));
#else // BOOST_LITTLE_ENDIAN
@@ -101,6 +125,8 @@
boost::optional<boost::uint64_t> v64;
BOOST_TEST(!binary_test("", 8, qword, v64));
#endif
+ BOOST_TEST(!binary_test("", 4, bin_float, vf));
+ BOOST_TEST(!binary_test("", 8, bin_double, vd));
#endif
}
Modified: branches/release/libs/spirit/test/karma/binary3.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/binary3.cpp (original)
+++ branches/release/libs/spirit/test/karma/binary3.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -38,6 +38,11 @@
boost::optional<boost::uint64_t> v64 (0x0807060504030201LL);
BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
#endif
+ boost::optional<float> vf(1.0f);
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float, vf));
+ boost::optional<double> vd(1.0);
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double, vd));
#else // BOOST_LITTLE_ENDIAN
@@ -51,6 +56,11 @@
boost::optional<boost::uint64_t> v64 (0x0102030405060708LL);
BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x08", 8, qword, v64));
#endif
+ boost::optional<float> vf(1.0f);
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float, vf));
+ boost::optional<double> vd(1.0);
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, vd));
#endif
}
@@ -89,6 +99,21 @@
BOOST_TEST(binary_test("\x02\x02\x03\x04\x05\x06\x07\x08", 8, qword,
++phoenix::ref(v64)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float,
+ phoenix::val(1.0f)));
+ float vf(1.0f);
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float,
+ phoenix::ref(vf)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x40", 4, bin_float,
+ ++phoenix::ref(vf)));
+
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double, phoenix::val(1.0)));
+ double vd(1.0);
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double, phoenix::ref(vd)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\x00\x40", 8,
+ bin_double, ++phoenix::ref(vd)));
#else // BOOST_LITTLE_ENDIAN
@@ -119,6 +144,21 @@
BOOST_TEST(binary_test("\x01\x02\x03\x04\x05\x06\x07\x09", 8, qword,
++phoenix::ref(v64)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float,
+ phoenix::val(1.0f)));
+ float vf(1.0f);
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float,
+ phoenix::ref(vf)));
+ BOOST_TEST(binary_test("\x40\x00\x00\x00", 4, bin_float,
+ ++phoenix::ref(vf)));
+
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, phoenix::val(1.0)));
+ double vd(1.0);
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, phoenix::ref(vd)));
+ BOOST_TEST(binary_test("\x40\x00\x00\x00\x00\x00\x00\x00", 8,
+ bin_double, ++phoenix::ref(vd)));
#endif
}
Modified: branches/release/libs/spirit/test/qi/binary.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/binary.cpp (original)
+++ branches/release/libs/spirit/test/qi/binary.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -16,6 +16,8 @@
{
using spirit_test::test_attr;
using spirit_test::test;
+ using spirit_test::binary_test;
+ using spirit_test::binary_test_attr;
using boost::spirit::qi::byte_;
using boost::spirit::qi::word;
@@ -29,6 +31,12 @@
using boost::spirit::qi::big_qword;
using boost::spirit::qi::little_qword;
#endif
+ using boost::spirit::qi::bin_float;
+ using boost::spirit::qi::big_bin_float;
+ using boost::spirit::qi::little_bin_float;
+ using boost::spirit::qi::bin_double;
+ using boost::spirit::qi::big_bin_double;
+ using boost::spirit::qi::little_bin_double;
boost::uint8_t uc;
boost::uint16_t us;
@@ -36,6 +44,8 @@
#ifdef BOOST_HAS_LONG_LONG
boost::uint64_t ul;
#endif
+ float f;
+ double d;
{ // test native endian binaries
#ifdef BOOST_LITTLE_ENDIAN
@@ -46,6 +56,10 @@
BOOST_TEST(test_attr("\x01\x02\x03\x04\x05\x06\x07\x08", qword, ul) &&
ul == 0x0807060504030201LL);
#endif
+ BOOST_TEST(binary_test_attr("\x00\x00\x80\x3f", 4, bin_float, f) &&
+ f == 1.0f);
+ BOOST_TEST(binary_test_attr("\x00\x00\x00\x00\x00\x00\xf0\x3f",
+ 8, bin_double, d) && f == 1.0);
#else
BOOST_TEST(test_attr("\x01", byte_, uc) && uc == 0x01);
BOOST_TEST(test_attr("\x01\x02", word, us) && us == 0x0102);
@@ -54,6 +68,10 @@
BOOST_TEST(test_attr("\x01\x02\x03\x04\x05\x06\x07\x08", qword, ul) &&
ul == 0x0102030405060708LL);
#endif
+ BOOST_TEST(binary_test_attr("\x3f\x80\x00\x00", 4, bin_float, f) &&
+ f == 1.0f);
+ BOOST_TEST(binary_test_attr("\x3f\xf0\x00\x00\x00\x00\x00\x00",
+ 8, bin_double, d) && f == 1.0);
#endif
}
@@ -66,6 +84,9 @@
BOOST_TEST(test("\x01\x02\x03\x04\x05\x06\x07\x08",
qword(0x0807060504030201LL)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ bin_double(1.0)));
#else
BOOST_TEST(test("\x01", byte_(0x01)));
BOOST_TEST(test("\x01\x02", word(0x0102)));
@@ -74,6 +95,9 @@
BOOST_TEST(test("\x01\x02\x03\x04\x05\x06\x07\x08",
qword(0x0102030405060708LL)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00\x00\x00\x00\x00", 8,
+ bin_double(1.0)));
#endif
}
@@ -84,6 +108,10 @@
BOOST_TEST(test_attr("\x01\x02\x03\x04\x05\x06\x07\x08", big_qword, ul)
&& ul == 0x0102030405060708LL);
#endif
+ BOOST_TEST(binary_test_attr("\x3f\x80\x00\x00", 4, big_bin_float, f) &&
+ f == 1.0f);
+ BOOST_TEST(binary_test_attr("\x3f\xf0\x00\x00\x00\x00\x00\x00",
+ 8, big_bin_double, d) && f == 1.0);
}
{
@@ -93,6 +121,9 @@
BOOST_TEST(test("\x01\x02\x03\x04\x05\x06\x07\x08",
big_qword(0x0102030405060708LL)));
#endif
+ BOOST_TEST(binary_test("\x3f\x80\x00\x00", 4, big_bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x3f\xf0\x00\x00\x00\x00\x00\x00", 8,
+ big_bin_double(1.0)));
}
{ // test little endian binaries
@@ -102,6 +133,10 @@
BOOST_TEST(test_attr("\x01\x02\x03\x04\x05\x06\x07\x08", little_qword, ul)
&& ul == 0x0807060504030201LL);
#endif
+ BOOST_TEST(binary_test_attr("\x00\x00\x80\x3f", 4,
+ little_bin_float, f) && f == 1.0f);
+ BOOST_TEST(binary_test_attr("\x00\x00\x00\x00\x00\x00\xf0\x3f",
+ 8, little_bin_double, d) && f == 1.0);
}
{
@@ -111,6 +146,9 @@
BOOST_TEST(test("\x01\x02\x03\x04\x05\x06\x07\x08",
little_qword(0x0807060504030201LL)));
#endif
+ BOOST_TEST(binary_test("\x00\x00\x80\x3f", 4, little_bin_float(1.0f)));
+ BOOST_TEST(binary_test("\x00\x00\x00\x00\x00\x00\xf0\x3f", 8,
+ little_bin_double(1.0)));
}
return boost::report_errors();
Modified: branches/release/libs/spirit/test/qi/symbols1.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/symbols1.cpp (original)
+++ branches/release/libs/spirit/test/qi/symbols1.cpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -51,11 +51,12 @@
("Tutit")
("Kim")
("Joey")
+ ("Joeyboy")
;
boost::mpl::true_ f = boost::mpl::bool_<boost::spirit::traits::is_parser<symbols<char, int> >::value>();
- // silence stupid compiler warnings
+ // silence stupid compiler warnings
// i.e. MSVC warning C4189: 'f' : local variable is initialized but not referenced
BOOST_TEST((f.value));
@@ -65,6 +66,7 @@
BOOST_TEST((test("Tutit", sym)));
BOOST_TEST((test("Kim", sym)));
BOOST_TEST((test("Joey", sym)));
+ BOOST_TEST((test("Joeyboy", sym)));
BOOST_TEST((!test("XXX", sym)));
// test copy
@@ -159,12 +161,12 @@
BOOST_TEST((test_attr("Joey", sym, i)));
BOOST_TEST(i == 6);
BOOST_TEST((!test_attr("XXX", sym, i)));
-
+
// double add:
-
+
sym.add("Joel", 265);
BOOST_TEST((test_attr("Joel", sym, i)));
- BOOST_TEST(i == 1);
+ BOOST_TEST(i == 1);
}
{ // actions
Modified: branches/release/libs/spirit/test/qi/test.hpp
==============================================================================
--- branches/release/libs/spirit/test/qi/test.hpp (original)
+++ branches/release/libs/spirit/test/qi/test.hpp 2012-01-09 09:36:46 EST (Mon, 09 Jan 2012)
@@ -44,6 +44,32 @@
&& (!full_match || (in == last));
}
+ template <typename Char, typename Parser>
+ bool binary_test(Char const* in, std::size_t size, Parser const& p,
+ bool full_match = true)
+ {
+ // we don't care about the result of the "what" function.
+ // we only care that all parsers have it:
+ boost::spirit::qi::what(p);
+
+ Char const* last = in + size;
+ return boost::spirit::qi::parse(in, last, p)
+ && (!full_match || (in == last));
+ }
+
+ template <typename Char, typename Parser, typename Skipper>
+ bool binary_test(Char const* in, std::size_t size, Parser const& p,
+ Skipper const& s, bool full_match = true)
+ {
+ // we don't care about the result of the "what" function.
+ // we only care that all parsers have it:
+ boost::spirit::qi::what(p);
+
+ Char const* last = in + size;
+ return boost::spirit::qi::phrase_parse(in, last, p, s)
+ && (!full_match || (in == last));
+ }
+
template <typename Char, typename Parser, typename Attr>
bool test_attr(Char const* in, Parser const& p
, Attr& attr, bool full_match = true)
@@ -74,6 +100,32 @@
&& (!full_match || (in == last));
}
+ template <typename Char, typename Parser, typename Attr>
+ bool binary_test_attr(Char const* in, std::size_t size, Parser const& p,
+ Attr& attr, bool full_match = true)
+ {
+ // we don't care about the result of the "what" function.
+ // we only care that all parsers have it:
+ boost::spirit::qi::what(p);
+
+ Char const* last = in + size;
+ return boost::spirit::qi::parse(in, last, p, attr)
+ && (!full_match || (in == last));
+ }
+
+ template <typename Char, typename Parser, typename Attr, typename Skipper>
+ bool binary_test_attr(Char const* in, std::size_t size, Parser const& p,
+ Attr& attr, Skipper const& s, bool full_match = true)
+ {
+ // we don't care about the result of the "what" function.
+ // we only care that all parsers have it:
+ boost::spirit::qi::what(p);
+
+ Char const* last = in + size;
+ return boost::spirit::qi::phrase_parse(in, last, p, s, attr)
+ && (!full_match || (in == last));
+ }
+
struct printer
{
typedef boost::spirit::utf8_string string;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk