diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail')
3 files changed, 215 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/fcall.hpp b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/fcall.hpp new file mode 100644 index 0000000..e4fa17f --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/fcall.hpp @@ -0,0 +1,53 @@ +/*============================================================================= + 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) +==============================================================================*/ +#ifndef BOOST_PP_IS_ITERATING + +#include <boost/preprocessor/iterate.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> + +#define BOOST_PP_FILENAME_1 \ + <boost/spirit/home/qi/nonterminal/detail/fcall.hpp> +#define BOOST_PP_ITERATION_LIMITS (1, SPIRIT_ARGUMENTS_LIMIT) +#include BOOST_PP_ITERATE() + +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#else // defined(BOOST_PP_IS_ITERATING) + +#define N BOOST_PP_ITERATION() + + template <BOOST_PP_ENUM_PARAMS(N, typename A)> + typename lazy_enable_if_c< + (params_size == N) + , proto::terminal< + spirit::qi::parameterized_nonterminal< + parameterized_subject_type + , fusion::vector<BOOST_PP_ENUM_PARAMS(N, A)> > + > + >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& f)) const + { + typedef fusion::vector<BOOST_PP_ENUM_PARAMS(N, A)> vector_type; + typedef spirit::qi::parameterized_nonterminal< + parameterized_subject_type, vector_type> parameterized_type; + typedef typename proto::terminal<parameterized_type>::type result_type; + + return result_type::make( + parameterized_type( + this->get_parameterized_subject() + , fusion::make_vector(BOOST_PP_ENUM_PARAMS(N, f))) + ); + } + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) + + diff --git a/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp new file mode 100644 index 0000000..0300a06 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2009 Francois Barel + + 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_PARAMETERIZED_AUGUST_09_2009_0539AM) +#define BOOST_SPIRIT_PARAMETERIZED_AUGUST_09_2009_0539AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/ref.hpp> + +#include <boost/spirit/home/support/handles_container.hpp> +#include <boost/spirit/home/qi/parser.hpp> + +namespace boost { namespace spirit { namespace qi +{ + /////////////////////////////////////////////////////////////////////////// + // parameterized_nonterminal: parser representing the invocation of a + // nonterminal, passing inherited attributes + /////////////////////////////////////////////////////////////////////////// + template <typename Subject, typename Params> + struct parameterized_nonterminal + : parser<parameterized_nonterminal<Subject, Params> > + { + parameterized_nonterminal(Subject const& subject, Params const& params) + : ref(subject), params(params) + { + } + + template <typename Context, typename Iterator> + struct attribute + // Forward to subject. + : Subject::template attribute<Context, Iterator> {}; + + template <typename Iterator, typename Context + , typename Skipper, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper + , Attribute& attr) const + { + // Forward to subject, passing the additional + // params argument to parse. + return ref.get().parse(first, last, context, skipper, attr, params); + } + + template <typename Context> + info what(Context& context) const + { + // Forward to subject. + return ref.get().what(context); + } + + boost::reference_wrapper<Subject const> ref; + Params params; + }; +}}} + +namespace boost { namespace spirit { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + template <typename Subject, typename Params, typename Attribute + , typename Context, typename Iterator> + struct handles_container<qi::parameterized_nonterminal<Subject, Params> + , Attribute, Context, Iterator> + : handles_container<typename remove_const<Subject>::type + , Attribute, Context, Iterator> + {}; +}}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp new file mode 100644 index 0000000..91bceba --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp @@ -0,0 +1,87 @@ +/*============================================================================= + 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_PARSER_BINDER_DECEMBER_05_2008_0516_PM) +#define BOOST_SPIRIT_PARSER_BINDER_DECEMBER_05_2008_0516_PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/fusion/include/at.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/spirit/home/support/has_semantic_action.hpp> + +namespace boost { namespace spirit { namespace qi { namespace detail +{ + // parser_binder for plain rules + template <typename Parser, typename Auto> + struct parser_binder + { + parser_binder(Parser const& p) + : p(p) {} + + template <typename Iterator, typename Skipper, typename Context> + bool call(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper, mpl::true_) const + { + // If DeducedAuto is false (semantic actions is present), the + // component's attribute is unused. + return p.parse(first, last, context, skipper, unused); + } + + template <typename Iterator, typename Skipper, typename Context> + bool call(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper, mpl::false_) const + { + // If DeducedAuto is true (no semantic action), we pass the rule's + // attribute on to the component. + return p.parse(first, last, context, skipper + , fusion::at_c<0>(context.attributes)); + } + + template <typename Iterator, typename Skipper, typename Context> + bool operator()( + Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper) const + { + // If Auto is false, we need to deduce whether to apply auto rule + typedef typename traits::has_semantic_action<Parser>::type auto_rule; + return call(first, last, context, skipper, auto_rule()); + } + + Parser p; + }; + + // parser_binder for auto rules + template <typename Parser> + struct parser_binder<Parser, mpl::true_> + { + parser_binder(Parser const& p) + : p(p) {} + + template <typename Iterator, typename Skipper, typename Context> + bool operator()( + Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper) const + { + // If Auto is true, we pass the rule's attribute on to the component. + return p.parse(first, last, context, skipper + , fusion::at_c<0>(context.attributes)); + } + + Parser p; + }; + + template <typename Auto, typename Parser> + inline parser_binder<Parser, Auto> + bind_parser(Parser const& p) + { + return parser_binder<Parser, Auto>(p); + } +}}}} + +#endif |