stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2009 Chris Hoeppler
|
||||
Copyright (c) 2014 Lee Clagett
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
|
||||
#if !defined(BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM)
|
||||
#define BOOST_SPIRIT_X3_CONFIX_MAY_30_2014_1819PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template<typename Prefix, typename Subject, typename Postfix>
|
||||
struct confix_directive :
|
||||
unary_parser<Subject, confix_directive<Prefix, Subject, Postfix>>
|
||||
{
|
||||
typedef unary_parser<
|
||||
Subject, confix_directive<Prefix, Subject, Postfix>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
confix_directive(Prefix const& prefix
|
||||
, Subject const& subject
|
||||
, Postfix const& postfix) :
|
||||
base_type(subject),
|
||||
prefix(prefix),
|
||||
postfix(postfix)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(
|
||||
Iterator& first, Iterator const& last
|
||||
, Context& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
Iterator save = first;
|
||||
|
||||
if (!(prefix.parse(first, last, context, rcontext, unused) &&
|
||||
this->subject.parse(first, last, context, rcontext, attr) &&
|
||||
postfix.parse(first, last, context, rcontext, unused)))
|
||||
{
|
||||
first = save;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Prefix prefix;
|
||||
Postfix postfix;
|
||||
};
|
||||
|
||||
template<typename Prefix, typename Postfix>
|
||||
struct confix_gen
|
||||
{
|
||||
template<typename Subject>
|
||||
confix_directive<
|
||||
Prefix, typename extension::as_parser<Subject>::value_type, Postfix>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { prefix, as_parser(subject), postfix };
|
||||
}
|
||||
|
||||
Prefix prefix;
|
||||
Postfix postfix;
|
||||
};
|
||||
|
||||
|
||||
template<typename Prefix, typename Postfix>
|
||||
confix_gen<typename extension::as_parser<Prefix>::value_type,
|
||||
typename extension::as_parser<Postfix>::value_type>
|
||||
confix(Prefix const& prefix, Postfix const& postfix)
|
||||
{
|
||||
return { as_parser(prefix), as_parser(postfix) };
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,104 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_EXPECT_MARCH_16_2012_1024PM)
|
||||
#define SPIRIT_EXPECT_MARCH_16_2012_1024PM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct expectation_failure : std::runtime_error
|
||||
{
|
||||
public:
|
||||
|
||||
expectation_failure(Iterator where, std::string const& which)
|
||||
: std::runtime_error("boost::spirit::x3::expectation_failure")
|
||||
, where_(where), which_(which)
|
||||
{}
|
||||
~expectation_failure() throw() {}
|
||||
|
||||
std::string which() const { return which_; }
|
||||
Iterator const& where() const { return where_; }
|
||||
|
||||
private:
|
||||
|
||||
Iterator where_;
|
||||
std::string which_;
|
||||
};
|
||||
|
||||
template <typename Subject>
|
||||
struct expect_directive : unary_parser<Subject, expect_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, expect_directive<Subject> > base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
|
||||
expect_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
bool r = this->subject.parse(first, last, context, rcontext, attr);
|
||||
|
||||
if (!r)
|
||||
{
|
||||
boost::throw_exception(
|
||||
expectation_failure<Iterator>(
|
||||
first, what(this->subject)));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
struct expect_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
expect_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const expect = expect_gen{};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
{
|
||||
// Special case handling for expect expressions.
|
||||
template <typename Subject, typename Context, typename RContext>
|
||||
struct parse_into_container_impl<expect_directive<Subject>, Context, RContext>
|
||||
{
|
||||
template <typename Iterator, typename Attribute>
|
||||
static bool call(
|
||||
expect_directive<Subject> const& parser
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr)
|
||||
{
|
||||
bool r = parse_into_container(
|
||||
parser.subject, first, last, context, rcontext, attr);
|
||||
|
||||
if (!r)
|
||||
{
|
||||
boost::throw_exception(
|
||||
expectation_failure<Iterator>(
|
||||
first, what(parser.subject)));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_LEXEME_MARCH_24_2007_0802AM)
|
||||
#define SPIRIT_LEXEME_MARCH_24_2007_0802AM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Subject>
|
||||
struct lexeme_directive : unary_parser<Subject, lexeme_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, lexeme_directive<Subject> > base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
lexeme_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename enable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
auto const& skipper = x3::get<skipper_tag>(context);
|
||||
|
||||
typedef unused_skipper<
|
||||
typename remove_reference<decltype(skipper)>::type>
|
||||
unused_skipper_type;
|
||||
unused_skipper_type unused_skipper(skipper);
|
||||
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<skipper_tag>(unused_skipper, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename disable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
// no need to pre-skip if skipper is unused
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, context
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
};
|
||||
|
||||
struct lexeme_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
lexeme_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const lexeme = lexeme_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2015 Mario Lang
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_HOME_X3_EXTENSIONS_MATCHES_HPP)
|
||||
#define BOOST_SPIRIT_HOME_X3_EXTENSIONS_MATCHES_HPP
|
||||
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Subject>
|
||||
struct matches_directive : unary_parser<Subject, matches_directive<Subject>>
|
||||
{
|
||||
using base_type = unary_parser<Subject, matches_directive<Subject>>;
|
||||
static bool const has_attribute = true;
|
||||
using attribute_type = bool;
|
||||
|
||||
matches_directive(Subject const& subject) : base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
bool const result = this->subject.parse(
|
||||
first, last, context, rcontext, unused);
|
||||
traits::move_to(result, attr);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct matches_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
matches_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const matches = matches_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Thomas Bernard
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_NO_CASE_SEPT_16_2014_0912PM)
|
||||
#define SPIRIT_NO_CASE_SEPT_16_2014_0912PM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/support/no_case.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
// propagate no_case information through the context
|
||||
template <typename Subject>
|
||||
struct no_case_directive : unary_parser<Subject, no_case_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, no_case_directive<Subject> > base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
no_case_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<no_case_tag>(no_case_compare_, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
};
|
||||
|
||||
struct no_case_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
no_case_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const no_case = no_case_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2013 Agustin Berge
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_NO_SKIP_JAN_16_2010_0802PM)
|
||||
#define SPIRIT_NO_SKIP_JAN_16_2010_0802PM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
// same as lexeme[], but does not pre-skip
|
||||
template <typename Subject>
|
||||
struct no_skip_directive : unary_parser<Subject, no_skip_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, no_skip_directive<Subject> > base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
no_skip_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename enable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
auto const& skipper = x3::get<skipper_tag>(context);
|
||||
|
||||
typedef unused_skipper<
|
||||
typename remove_reference<decltype(skipper)>::type>
|
||||
unused_skipper_type;
|
||||
unused_skipper_type unused_skipper(skipper);
|
||||
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<skipper_tag>(unused_skipper, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename disable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, context
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
};
|
||||
|
||||
struct no_skip_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
no_skip_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const no_skip = no_skip_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_OMIT_MARCH_24_2007_0802AM)
|
||||
#define SPIRIT_OMIT_MARCH_24_2007_0802AM
|
||||
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// omit_directive forces the attribute of subject parser
|
||||
// to be unused_type
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct omit_directive : unary_parser<Subject, omit_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, omit_directive<Subject> > base_type;
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
typedef Subject subject_type;
|
||||
omit_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context, typename RContext>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, unused_type) const
|
||||
{
|
||||
return this->subject.parse(first, last, context, rcontext, unused);
|
||||
}
|
||||
};
|
||||
|
||||
struct omit_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
omit_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const omit = omit_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_X3_RAW_APRIL_9_2007_0912AM)
|
||||
#define SPIRIT_X3_RAW_APRIL_9_2007_0912AM
|
||||
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
// this is a pseudo attribute type indicating that the parser wants the
|
||||
// iterator range pointing to the [first, last) matching characters from
|
||||
// the input iterators.
|
||||
struct raw_attribute_type {};
|
||||
|
||||
template <typename Subject>
|
||||
struct raw_directive : unary_parser<Subject, raw_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, raw_directive<Subject> > base_type;
|
||||
typedef raw_attribute_type attribute_type;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
typedef Subject subject_type;
|
||||
|
||||
raw_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
Iterator i = first;
|
||||
if (this->subject.parse(i, last, context, rcontext, unused))
|
||||
{
|
||||
traits::move_to(first, i, attr);
|
||||
first = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context, typename RContext>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, unused_type) const
|
||||
{
|
||||
return this->subject.parse(first, last, context, rcontext, unused);
|
||||
}
|
||||
};
|
||||
|
||||
struct raw_gen
|
||||
{
|
||||
template <typename Subject>
|
||||
raw_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const raw = raw_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,157 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2014 Thomas Bernard
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(SPIRIT_X3_REPEAT_APRIL_16_2014_0848AM)
|
||||
#define SPIRIT_X3_REPEAT_APRIL_16_2014_0848AM
|
||||
|
||||
#include <boost/function_types/function_type.hpp>
|
||||
#include <boost/function_types/parameter_types.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/operator/kleene.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct exact_count // handles repeat(exact)[p]
|
||||
{
|
||||
typedef T type;
|
||||
bool got_max(T i) const { return i >= exact_value; }
|
||||
bool got_min(T i) const { return i >= exact_value; }
|
||||
|
||||
T const exact_value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct finite_count // handles repeat(min, max)[p]
|
||||
{
|
||||
typedef T type;
|
||||
bool got_max(T i) const { return i >= max_value; }
|
||||
bool got_min(T i) const { return i >= min_value; }
|
||||
|
||||
T const min_value;
|
||||
T const max_value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct infinite_count // handles repeat(min, inf)[p]
|
||||
{
|
||||
typedef T type;
|
||||
bool got_max(T /*i*/) const { return false; }
|
||||
bool got_min(T i) const { return i >= min_value; }
|
||||
|
||||
T const min_value;
|
||||
};
|
||||
}}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template<typename Subject, typename RepeatCountLimit>
|
||||
struct repeat_directive : unary_parser<Subject, repeat_directive<Subject,RepeatCountLimit>>
|
||||
{
|
||||
typedef unary_parser<Subject, repeat_directive<Subject,RepeatCountLimit>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = true;
|
||||
|
||||
repeat_directive(Subject const& subject, RepeatCountLimit const& repeat_limit_)
|
||||
: base_type(subject)
|
||||
, repeat_limit(repeat_limit_)
|
||||
{}
|
||||
|
||||
template<typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(
|
||||
Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
Iterator local_iterator = first;
|
||||
typename RepeatCountLimit::type i{};
|
||||
for (/**/; !repeat_limit.got_min(i); ++i)
|
||||
{
|
||||
if (!detail::parse_into_container(
|
||||
this->subject, local_iterator, last, context, rcontext, attr))
|
||||
return false;
|
||||
}
|
||||
|
||||
first = local_iterator;
|
||||
// parse some more up to the maximum specified
|
||||
for (/**/; !repeat_limit.got_max(i); ++i)
|
||||
{
|
||||
if (!detail::parse_into_container(
|
||||
this->subject, first, last, context, rcontext, attr))
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
RepeatCountLimit repeat_limit;
|
||||
};
|
||||
|
||||
// Infinite loop tag type
|
||||
struct inf_type {};
|
||||
const inf_type inf = inf_type();
|
||||
|
||||
struct repeat_gen
|
||||
{
|
||||
template<typename Subject>
|
||||
kleene<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct repeat_gen_lvl1
|
||||
{
|
||||
repeat_gen_lvl1(T&& repeat_limit_)
|
||||
: repeat_limit(repeat_limit_)
|
||||
{}
|
||||
|
||||
template<typename Subject>
|
||||
repeat_directive< typename extension::as_parser<Subject>::value_type, T>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject),repeat_limit };
|
||||
}
|
||||
|
||||
T repeat_limit;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
repeat_gen_lvl1<detail::exact_count<T>>
|
||||
operator()(T const exact) const
|
||||
{
|
||||
return { detail::exact_count<T>{exact} };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
repeat_gen_lvl1<detail::finite_count<T>>
|
||||
operator()(T const min_val, T const max_val) const
|
||||
{
|
||||
return { detail::finite_count<T>{min_val,max_val} };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
repeat_gen_lvl1<detail::infinite_count<T>>
|
||||
operator()(T const min_val, inf_type const &) const
|
||||
{
|
||||
return { detail::infinite_count<T>{min_val} };
|
||||
}
|
||||
};
|
||||
|
||||
auto const repeat = repeat_gen{};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
template <typename Subject, typename RepeatCountLimit, typename Context>
|
||||
struct attribute_of<x3::repeat_directive<Subject,RepeatCountLimit>, Context>
|
||||
: build_container<typename attribute_of<Subject, Context>::type> {};
|
||||
}}}}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2011 Jamboree
|
||||
Copyright (c) 2014 Lee Clagett
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
==============================================================================*/
|
||||
#if !defined(BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM)
|
||||
#define BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template<typename Subject>
|
||||
struct seek_directive : unary_parser<Subject, seek_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, seek_directive<Subject>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
seek_directive(Subject const& subject) :
|
||||
base_type(subject) {}
|
||||
|
||||
template<typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(
|
||||
Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
Iterator current(first);
|
||||
for (/**/; current != last; ++current)
|
||||
{
|
||||
if (this->subject.parse(current, last, context, rcontext, attr))
|
||||
{
|
||||
first = current;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Test for when subjects match on input empty. Example:
|
||||
// comment = "//" >> seek[eol | eoi]
|
||||
if (this->subject.parse(current, last, context, rcontext, attr))
|
||||
{
|
||||
first = current;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct seek_gen
|
||||
{
|
||||
template<typename Subject>
|
||||
seek_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const seek = seek_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
Copyright (c) 2013 Agustin Berge
|
||||
|
||||
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_SKIP_JANUARY_26_2008_0422PM)
|
||||
#define SPIRIT_SKIP_JANUARY_26_2008_0422PM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Subject>
|
||||
struct reskip_directive : unary_parser<Subject, reskip_directive<Subject>>
|
||||
{
|
||||
typedef unary_parser<Subject, reskip_directive<Subject>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
reskip_directive(Subject const& subject)
|
||||
: base_type(subject) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename disable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
auto const& skipper =
|
||||
detail::get_unused_skipper(x3::get<skipper_tag>(context));
|
||||
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<skipper_tag>(skipper, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
typename enable_if<has_skipper<Context>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, context
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Subject, typename Skipper>
|
||||
struct skip_directive : unary_parser<Subject, skip_directive<Subject, Skipper>>
|
||||
{
|
||||
typedef unary_parser<Subject, skip_directive<Subject, Skipper>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
skip_directive(Subject const& subject, Skipper const& skipper)
|
||||
: base_type(subject)
|
||||
, skipper(skipper)
|
||||
{}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<skipper_tag>(skipper, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
|
||||
Skipper const skipper;
|
||||
};
|
||||
|
||||
struct reskip_gen
|
||||
{
|
||||
template <typename Skipper>
|
||||
struct skip_gen
|
||||
{
|
||||
skip_gen(Skipper const& skipper)
|
||||
: skipper_(skipper) {}
|
||||
|
||||
template <typename Subject>
|
||||
skip_directive<typename extension::as_parser<Subject>::value_type, Skipper>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject), skipper_ };
|
||||
}
|
||||
|
||||
Skipper skipper_;
|
||||
};
|
||||
|
||||
template <typename Skipper>
|
||||
skip_gen<Skipper> const operator()(Skipper const& skipper) const
|
||||
{
|
||||
return { skipper };
|
||||
}
|
||||
|
||||
template <typename Subject>
|
||||
reskip_directive<typename extension::as_parser<Subject>::value_type>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject) };
|
||||
}
|
||||
};
|
||||
|
||||
auto const skip = reskip_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,107 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2014 Joel de Guzman
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#if !defined(SPIRIT_X3_WITH_MAY_02_2014_0749AM)
|
||||
#define SPIRIT_X3_WITH_MAY_02_2014_0749AM
|
||||
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// with directive injects a value into the context prior to parsing.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Derived, typename T>
|
||||
struct with_value_holder
|
||||
: unary_parser<Subject, Derived>
|
||||
{
|
||||
typedef unary_parser<Subject, Derived> base_type;
|
||||
mutable T val;
|
||||
with_value_holder(Subject const& subject, T const& val)
|
||||
: base_type(subject)
|
||||
, val(val) {}
|
||||
};
|
||||
|
||||
template <typename Subject, typename Derived, typename T>
|
||||
struct with_value_holder<Subject, Derived, T const>
|
||||
: unary_parser<Subject, Derived>
|
||||
{
|
||||
typedef unary_parser<Subject, Derived> base_type;
|
||||
T val;
|
||||
with_value_holder(Subject const& subject, T const& val)
|
||||
: base_type(subject)
|
||||
, val(val) {}
|
||||
};
|
||||
|
||||
template <typename Subject, typename ID, typename T>
|
||||
struct with_directive
|
||||
: with_value_holder<Subject, with_directive<Subject, ID, T>, T>
|
||||
{
|
||||
typedef with_value_holder<Subject, with_directive<Subject, ID, T>, T> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
static bool const handles_container = Subject::handles_container;
|
||||
|
||||
typedef Subject subject_type;
|
||||
|
||||
with_directive(Subject const& subject, T const& val)
|
||||
: base_type(subject, val) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
return this->subject.parse(
|
||||
first, last
|
||||
, make_context<ID>(this->val, context)
|
||||
, rcontext
|
||||
, attr);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ID, typename T, typename NextContext = unused_type>
|
||||
struct with_context
|
||||
{
|
||||
typedef context<ID, T, NextContext> type;
|
||||
};
|
||||
|
||||
template <typename ID, typename T>
|
||||
struct with_context<ID, T, unused_type>
|
||||
{
|
||||
typedef context<ID, T> type;
|
||||
};
|
||||
|
||||
template <typename ID, typename T>
|
||||
struct with_gen
|
||||
{
|
||||
T& val;
|
||||
|
||||
with_gen(T& val)
|
||||
: val(val) {}
|
||||
|
||||
template <typename Subject>
|
||||
with_directive<typename extension::as_parser<Subject>::value_type, ID, T>
|
||||
operator[](Subject const& subject) const
|
||||
{
|
||||
return { as_parser(subject), val };
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ID, typename T>
|
||||
inline with_gen<ID, T> with(T& val)
|
||||
{
|
||||
return { val };
|
||||
}
|
||||
|
||||
template <typename ID, typename T>
|
||||
inline with_gen<ID, T const> with(T const& val)
|
||||
{
|
||||
return { val };
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user