|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56685 - in trunk/boost/spirit/home/qi: detail numeric/detail operator
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-09 19:58:23
Author: hkaiser
Date: 2009-10-09 19:58:22 EDT (Fri, 09 Oct 2009)
New Revision: 56685
URL: http://svn.boost.org/trac/boost/changeset/56685
Log:
Spirit: reverting change for alternative parsers
Text files modified:
trunk/boost/spirit/home/qi/detail/alternative_function.hpp | 18 +++++++++---
trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 2
trunk/boost/spirit/home/qi/operator/alternative.hpp | 57 ++-------------------------------------
3 files changed, 17 insertions(+), 60 deletions(-)
Modified: trunk/boost/spirit/home/qi/detail/alternative_function.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/alternative_function.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/alternative_function.hpp 2009-10-09 19:58:22 EDT (Fri, 09 Oct 2009)
@@ -33,17 +33,18 @@
}
template <typename Component>
- bool operator()(Component const& component) const
+ bool call(Component const& component, mpl::true_) const
{
// if Attribute is not a variant, then pass it as-is
return component.parse(first, last, context, skipper, attr);
}
- template <typename Component, typename T>
- bool operator()(Component const& component, mpl::identity<T>) const
+ template <typename Component>
+ bool call(Component const& component, mpl::false_) const
{
- // if Attribute is a variant, then create an attribute.
- T val;
+ // if Attribute is a variant, then create an attribute for
+ // the Component with its expected type.
+ typename traits::attribute_of<Component, Context, Iterator>::type val;
if (component.parse(first, last, context, skipper, val))
{
traits::assign_to(val, attr);
@@ -52,6 +53,13 @@
return false;
}
+ template <typename Component>
+ bool operator()(Component const& component) const
+ {
+ // return true if the parser succeeds
+ return call(component, spirit::traits::not_is_variant<Attribute>());
+ }
+
Iterator& first;
Iterator const& last;
Context& context;
Modified: trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp 2009-10-09 19:58:22 EDT (Fri, 09 Oct 2009)
@@ -445,7 +445,7 @@
{
if (count == 0) // must have at least one digit
return false;
- attr = 0;
+ traits::assign_to(0, attr);
first = it;
return true;
}
Modified: trunk/boost/spirit/home/qi/operator/alternative.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/operator/alternative.hpp (original)
+++ trunk/boost/spirit/home/qi/operator/alternative.hpp 2009-10-09 19:58:22 EDT (Fri, 09 Oct 2009)
@@ -19,7 +19,7 @@
#include <boost/spirit/home/support/detail/what_function.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/info.hpp>
-#include <boost/spirit/home/support/algorithm/any.hpp>
+#include <boost/fusion/include/any.hpp>
#include <boost/fusion/include/mpl.hpp>
#include <boost/fusion/include/for_each.hpp>
@@ -39,31 +39,6 @@
namespace boost { namespace spirit { namespace qi
{
- namespace detail
- {
- template <typename T>
- struct get_variant_element
- : mpl::identity<T> {};
-
- template <typename T>
- struct get_variant_element<recursive_wrapper<T> >
- : mpl::identity<T> {};
-
- template <typename T>
- struct get_variant_types;
-
-#define BOOST_SPIRIT_IDENTITY(z, n, data) get_variant_element<BOOST_PP_CAT(T, n)>
- template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
- struct get_variant_types<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
- {
- typedef mpl::vector<
- BOOST_PP_ENUM(
- BOOST_VARIANT_LIMIT_TYPES, BOOST_SPIRIT_IDENTITY, _)>
- type;
- };
-#undef BOOST_SPIRIT_IDENTITY
- }
-
template <typename Elements>
struct alternative : nary_parser<alternative<Elements> >
{
@@ -90,42 +65,16 @@
template <typename Iterator, typename Context
, typename Skipper, typename Attribute>
- bool parse_impl(Iterator& first, Iterator const& last
+ bool parse(Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
- , Attribute& attr, mpl::true_) const
+ , Attribute& attr) const
{
- // This branch is chosen if attr *is not* a variant
detail::alternative_function<Iterator, Context, Skipper, Attribute>
f(first, last, context, skipper, attr);
// return true if *any* of the parsers succeed
return fusion::any(elements, f);
}
-
- template <typename Iterator, typename Context
- , typename Skipper, typename Attribute>
- bool parse_impl(Iterator& first, Iterator const& last
- , Context& context, Skipper const& skipper
- , Attribute& attr, mpl::false_) const
- {
- // This branch is chosen if attr *is* a variant
- detail::alternative_function<Iterator, Context, Skipper, Attribute>
- f(first, last, context, skipper, attr);
-
- // return true if *any* of the parsers succeed
- typename detail::get_variant_types<Attribute>::type vtypes;
- return spirit::any(elements, vtypes, f);
- }
-
- template <typename Iterator, typename Context
- , typename Skipper, typename Attribute>
- bool parse(Iterator& first, Iterator const& last
- , Context& context, Skipper const& skipper
- , Attribute& attr) const
- {
- return parse_impl(first, last, context, skipper, attr,
- spirit::traits::not_is_variant<Attribute>());
- }
template <typename Context>
info what(Context& context) const
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