stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM)
|
||||
#define BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/detail/assign_to.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename A0> // enables attr()
|
||||
struct use_terminal<
|
||||
qi::domain, terminal_ex<tag::attr, fusion::vector1<A0> > >
|
||||
: mpl::true_ {};
|
||||
|
||||
template <> // enables *lazy* attr()
|
||||
struct use_lazy_terminal<qi::domain, tag::attr, 1>
|
||||
: mpl::true_ {};
|
||||
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::attr;
|
||||
#endif
|
||||
using spirit::attr_type;
|
||||
|
||||
template <typename Value>
|
||||
struct attr_parser : primitive_parser<attr_parser<Value> >
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute : remove_const<Value> {};
|
||||
|
||||
attr_parser(typename add_reference<Value>::type value)
|
||||
: value_(value) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool parse(Iterator& /*first*/, Iterator const& /*last*/
|
||||
, Context& /*context*/, Skipper const& /*skipper*/
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
spirit::traits::assign_to(value_, attr_);
|
||||
return true; // never consume any input, succeed always
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& /*context*/) const
|
||||
{
|
||||
return info("attr");
|
||||
}
|
||||
|
||||
Value value_;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
attr_parser& operator= (attr_parser const&);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Modifiers, typename A0>
|
||||
struct make_primitive<
|
||||
terminal_ex<tag::attr, fusion::vector1<A0> >
|
||||
, Modifiers>
|
||||
{
|
||||
typedef typename add_const<A0>::type const_value;
|
||||
typedef attr_parser<const_value> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, unused_type) const
|
||||
{
|
||||
return result_type(fusion::at_c<0>(term.args));
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename Attr, typename Context, typename Iterator>
|
||||
struct handles_container<qi::attr_parser<T>, Attr, Context, Iterator>
|
||||
: traits::is_container<Attr> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
// Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#if !defined(SPIRIT_QI_ATTR_CAST_SEP_26_2009_0735PM)
|
||||
#define SPIRIT_QI_ATTR_CAST_SEP_26_2009_0735PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/auxiliary/attr_cast.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// enables attr_cast<>() pseudo parser
|
||||
template <typename Expr, typename Exposed, typename Transformed>
|
||||
struct use_terminal<qi::domain
|
||||
, tag::stateful_tag<Expr, tag::attr_cast, Exposed, Transformed> >
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
using spirit::attr_cast;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// attr_cast_parser consumes the attribute of subject generator without
|
||||
// generating anything
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Exposed, typename Transformed, typename Subject>
|
||||
struct attr_cast_parser
|
||||
: unary_parser<attr_cast_parser<Exposed, Transformed, Subject> >
|
||||
{
|
||||
typedef typename result_of::compile<qi::domain, Subject>::type
|
||||
subject_type;
|
||||
|
||||
typedef typename mpl::eval_if<
|
||||
traits::not_is_unused<Transformed>
|
||||
, mpl::identity<Transformed>
|
||||
, traits::attribute_of<subject_type> >::type
|
||||
transformed_attribute_type;
|
||||
|
||||
attr_cast_parser(Subject const& subject_)
|
||||
: subject(subject_)
|
||||
{
|
||||
// If you got an error_invalid_expression error message here,
|
||||
// then the expression (Subject) is not a valid spirit qi
|
||||
// expression.
|
||||
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Subject);
|
||||
}
|
||||
|
||||
// If Exposed is given, we use the given type, otherwise all we can do
|
||||
// is to guess, so we expose our inner type as an attribute and
|
||||
// deal with the passed attribute inside the parse function.
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
: mpl::if_<traits::not_is_unused<Exposed>, Exposed
|
||||
, transformed_attribute_type>
|
||||
{};
|
||||
|
||||
template <typename Iterator, typename Context, typename Skipper
|
||||
, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_param) const
|
||||
{
|
||||
// Find the real exposed attribute. If exposed is given, we use it
|
||||
// otherwise we assume the exposed attribute type to be the actual
|
||||
// attribute type as passed by the user.
|
||||
typedef typename mpl::if_<
|
||||
traits::not_is_unused<Exposed>, Exposed, Attribute>::type
|
||||
exposed_attribute_type;
|
||||
|
||||
// do down-stream transformation, provides attribute for embedded
|
||||
// parser
|
||||
typedef traits::transform_attribute<
|
||||
exposed_attribute_type, transformed_attribute_type, domain>
|
||||
transform;
|
||||
|
||||
typename transform::type attr_ = transform::pre(attr_param);
|
||||
|
||||
if (!compile<qi::domain>(subject).
|
||||
parse(first, last, context, skipper, attr_))
|
||||
{
|
||||
transform::fail(attr_param);
|
||||
return false;
|
||||
}
|
||||
|
||||
// do up-stream transformation, this mainly integrates the results
|
||||
// back into the original attribute value, if appropriate
|
||||
traits::post_transform(attr_param, attr_);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("attr_cast"
|
||||
, compile<qi::domain>(subject).what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
attr_cast_parser& operator= (attr_cast_parser const&);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generator: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Expr, typename Exposed, typename Transformed
|
||||
, typename Modifiers>
|
||||
struct make_primitive<
|
||||
tag::stateful_tag<Expr, tag::attr_cast, Exposed, Transformed>, Modifiers>
|
||||
{
|
||||
typedef attr_cast_parser<Exposed, Transformed, Expr> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, unused_type) const
|
||||
{
|
||||
typedef tag::stateful_tag<
|
||||
Expr, tag::attr_cast, Exposed, Transformed> tag_type;
|
||||
using spirit::detail::get_stateful_data;
|
||||
return result_type(get_stateful_data<tag_type>::call(term));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_EOI_APRIL_18_2008_0751PM)
|
||||
#define BOOST_SPIRIT_EOI_APRIL_18_2008_0751PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_terminal<qi::domain, tag::eoi> // enables eoi
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::eoi;
|
||||
#endif
|
||||
using spirit::eoi_type;
|
||||
|
||||
struct eoi_parser : primitive_parser<eoi_parser>
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef unused_type type;
|
||||
};
|
||||
|
||||
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);
|
||||
return first == last;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& /*context*/) const
|
||||
{
|
||||
return info("eoi");
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<tag::eoi, Modifiers>
|
||||
{
|
||||
typedef eoi_parser result_type;
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM)
|
||||
#define BOOST_SPIRIT_EOL_APRIL_18_2008_0751PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_terminal<qi::domain, tag::eol> // enables eol
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::eol;
|
||||
#endif
|
||||
using spirit::eol_type;
|
||||
|
||||
struct eol_parser : primitive_parser<eol_parser>
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef unused_type type;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
Iterator it = first;
|
||||
bool matched = false;
|
||||
if (it != last && *it == '\r') // CR
|
||||
{
|
||||
matched = true;
|
||||
++it;
|
||||
}
|
||||
if (it != last && *it == '\n') // LF
|
||||
{
|
||||
matched = true;
|
||||
++it;
|
||||
}
|
||||
|
||||
if (!matched)
|
||||
return false;
|
||||
|
||||
first = it;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& /*context*/) const
|
||||
{
|
||||
return info("eol");
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<tag::eol, Modifiers>
|
||||
{
|
||||
typedef eol_parser result_type;
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_EPS_MARCH_23_2007_0454PM)
|
||||
#define BOOST_SPIRIT_EPS_MARCH_23_2007_0454PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_terminal<qi::domain, tag::eps> // enables eps
|
||||
: mpl::true_ {};
|
||||
|
||||
template <typename A0>
|
||||
struct use_terminal<qi::domain
|
||||
, terminal_ex<tag::eps, fusion::vector1<A0> > // enables eps(bool-condition)
|
||||
> : is_convertible<A0, bool> {};
|
||||
|
||||
template <> // enables eps(f)
|
||||
struct use_lazy_terminal<
|
||||
qi::domain, tag::eps, 1 /*arity*/
|
||||
> : mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::eps;
|
||||
#endif
|
||||
using spirit::eps_type;
|
||||
|
||||
struct eps_parser : primitive_parser<eps_parser>
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef unused_type type;
|
||||
};
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& /*context*/) const
|
||||
{
|
||||
return info("eps");
|
||||
}
|
||||
};
|
||||
|
||||
struct semantic_predicate : primitive_parser<semantic_predicate>
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef unused_type type;
|
||||
};
|
||||
|
||||
semantic_predicate(bool predicate_)
|
||||
: predicate(predicate_) {}
|
||||
|
||||
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);
|
||||
return predicate;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& /*context*/) const
|
||||
{
|
||||
return info("semantic-predicate");
|
||||
}
|
||||
|
||||
bool predicate;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<tag::eps, Modifiers>
|
||||
{
|
||||
typedef eps_parser result_type;
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Modifiers, typename A0>
|
||||
struct make_primitive<
|
||||
terminal_ex<tag::eps, fusion::vector1<A0> >
|
||||
, Modifiers>
|
||||
{
|
||||
typedef semantic_predicate result_type;
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, unused_type) const
|
||||
{
|
||||
return result_type(fusion::at_c<0>(term.args) ? true : false);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,287 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_LAZY_MARCH_27_2007_1002AM)
|
||||
#define BOOST_SPIRIT_LAZY_MARCH_27_2007_1002AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/lazy.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#include <boost/utility/result_of.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Eval>
|
||||
struct use_terminal<qi::domain, phoenix::actor<Eval> > // enables phoenix actors
|
||||
: mpl::true_ {};
|
||||
|
||||
// forward declaration
|
||||
template <typename Terminal, typename Actor, int Arity>
|
||||
struct lazy_terminal;
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
using spirit::lazy;
|
||||
typedef modify<qi::domain> qi_modify;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename Parser, typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool lazy_parse_impl(Parser const& p
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr, mpl::false_)
|
||||
{
|
||||
return p.parse(first, last, context, skipper, attr);
|
||||
}
|
||||
|
||||
template <typename Parser, typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool lazy_parse_impl(Parser const& p
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& /*attr*/, mpl::true_)
|
||||
{
|
||||
// If DeducedAuto is false (semantic actions is present), the
|
||||
// component's attribute is unused.
|
||||
return p.parse(first, last, context, skipper, unused);
|
||||
}
|
||||
|
||||
template <typename Parser, typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool lazy_parse_impl_main(Parser const& p
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr)
|
||||
{
|
||||
// If DeducedAuto is true (no semantic action), we pass the parser's
|
||||
// attribute on to the component.
|
||||
typedef typename traits::has_semantic_action<Parser>::type auto_rule;
|
||||
return lazy_parse_impl(p, first, last, context, skipper, attr, auto_rule());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Function, typename Modifiers>
|
||||
struct lazy_parser : parser<lazy_parser<Function, Modifiers> >
|
||||
{
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
boost::result_of<qi_modify(tag::lazy_eval, Modifiers)>::type
|
||||
modifier;
|
||||
|
||||
typedef typename
|
||||
remove_reference<
|
||||
typename boost::result_of<Function(unused_type, Context)>::type
|
||||
>::type
|
||||
expr_type;
|
||||
|
||||
// If you got an error_invalid_expression error message here,
|
||||
// then the expression (expr_type) is not a valid spirit qi
|
||||
// expression.
|
||||
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type);
|
||||
|
||||
typedef typename
|
||||
result_of::compile<qi::domain, expr_type, modifier>::type
|
||||
parser_type;
|
||||
|
||||
typedef typename
|
||||
traits::attribute_of<parser_type, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
lazy_parser(Function const& function_, Modifiers const& modifiers_)
|
||||
: function(function_), modifiers(modifiers_) {}
|
||||
|
||||
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 detail::lazy_parse_impl_main(
|
||||
compile<qi::domain>(function(unused, context)
|
||||
, qi_modify()(tag::lazy_eval(), modifiers))
|
||||
, first, last, context, skipper, attr);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("lazy"
|
||||
, compile<qi::domain>(function(unused, context)
|
||||
, qi_modify()(tag::lazy_eval(), modifiers))
|
||||
.what(context)
|
||||
);
|
||||
}
|
||||
|
||||
Function function;
|
||||
Modifiers modifiers;
|
||||
};
|
||||
|
||||
|
||||
template <typename Function, typename Subject, typename Modifiers>
|
||||
struct lazy_directive
|
||||
: unary_parser<lazy_directive<Function, Subject, Modifiers> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
boost::result_of<qi_modify(tag::lazy_eval, Modifiers)>::type
|
||||
modifier;
|
||||
|
||||
typedef typename
|
||||
remove_reference<
|
||||
typename boost::result_of<Function(unused_type, Context)>::type
|
||||
>::type
|
||||
directive_expr_type;
|
||||
|
||||
typedef typename
|
||||
proto::result_of::make_expr<
|
||||
proto::tag::subscript
|
||||
, directive_expr_type
|
||||
, Subject
|
||||
>::type
|
||||
expr_type;
|
||||
|
||||
// If you got an error_invalid_expression error message here,
|
||||
// then the expression (expr_type) is not a valid spirit qi
|
||||
// expression.
|
||||
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type);
|
||||
|
||||
typedef typename
|
||||
result_of::compile<qi::domain, expr_type, modifier>::type
|
||||
parser_type;
|
||||
|
||||
typedef typename
|
||||
traits::attribute_of<parser_type, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
lazy_directive(
|
||||
Function const& function_
|
||||
, Subject const& subject_
|
||||
, Modifiers const& modifiers_)
|
||||
: function(function_), subject(subject_), modifiers(modifiers_) {}
|
||||
|
||||
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 detail::lazy_parse_impl_main(compile<qi::domain>(
|
||||
proto::make_expr<proto::tag::subscript>(
|
||||
function(unused, context)
|
||||
, subject)
|
||||
, qi_modify()(tag::lazy_eval(), modifiers))
|
||||
, first, last, context, skipper, attr);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("lazy-directive"
|
||||
, compile<qi::domain>(
|
||||
proto::make_expr<proto::tag::subscript>(
|
||||
function(unused, context)
|
||||
, subject
|
||||
), qi_modify()(tag::lazy_eval(), modifiers))
|
||||
.what(context)
|
||||
);
|
||||
}
|
||||
|
||||
Function function;
|
||||
Subject subject;
|
||||
Modifiers modifiers;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Eval, typename Modifiers>
|
||||
struct make_primitive<phoenix::actor<Eval>, Modifiers>
|
||||
{
|
||||
typedef lazy_parser<phoenix::actor<Eval>, Modifiers> result_type;
|
||||
result_type operator()(phoenix::actor<Eval> const& f
|
||||
, Modifiers const& modifiers) const
|
||||
{
|
||||
return result_type(f, modifiers);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Terminal, typename Actor, int Arity, typename Modifiers>
|
||||
struct make_primitive<lazy_terminal<Terminal, Actor, Arity>, Modifiers>
|
||||
{
|
||||
typedef lazy_parser<Actor, Modifiers> result_type;
|
||||
result_type operator()(
|
||||
lazy_terminal<Terminal, Actor, Arity> const& lt
|
||||
, Modifiers const& modifiers) const
|
||||
{
|
||||
return result_type(lt.actor, modifiers);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Terminal, typename Actor, int Arity, typename Subject, typename Modifiers>
|
||||
struct make_directive<lazy_terminal<Terminal, Actor, Arity>, Subject, Modifiers>
|
||||
{
|
||||
typedef lazy_directive<Actor, Subject, Modifiers> result_type;
|
||||
result_type operator()(
|
||||
lazy_terminal<Terminal, Actor, Arity> const& lt
|
||||
, Subject const& subject, Modifiers const& modifiers) const
|
||||
{
|
||||
return result_type(lt.actor, subject, modifiers);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Actor, typename Modifiers, typename Attribute
|
||||
, typename Context, typename Iterator>
|
||||
struct handles_container<
|
||||
qi::lazy_parser<Actor, Modifiers>, Attribute, Context, Iterator>
|
||||
: handles_container<
|
||||
typename qi::lazy_parser<Actor, Modifiers>::template
|
||||
attribute<Context, Iterator>::parser_type
|
||||
, Attribute, Context, Iterator>
|
||||
{};
|
||||
|
||||
template <typename Subject, typename Actor, typename Modifiers
|
||||
, typename Attribute, typename Context, typename Iterator>
|
||||
struct handles_container<
|
||||
qi::lazy_directive<Actor, Subject, Modifiers>, Attribute
|
||||
, Context, Iterator>
|
||||
: handles_container<
|
||||
typename qi::lazy_directive<Actor, Subject, Modifiers>::template
|
||||
attribute<Context, Iterator>::parser_type
|
||||
, Attribute, Context, Iterator>
|
||||
{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user