stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2010 Bryce Lelbach
|
||||
|
||||
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_AS_DECEMBER_6_2010_1013AM)
|
||||
#define SPIRIT_AS_DECEMBER_6_2010_1013AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/detail/assign_to.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/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/spirit/home/support/assert_msg.hpp>
|
||||
#include <boost/spirit/home/support/container.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
template <typename T>
|
||||
struct as
|
||||
: stateful_tag_type<T, tag::as>
|
||||
{
|
||||
//~ BOOST_SPIRIT_ASSERT_MSG(
|
||||
//~ (traits::is_container<T>::type::value),
|
||||
//~ error_type_must_be_a_container,
|
||||
//~ (T));
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// enables as_string[...]
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::as_string>
|
||||
: mpl::true_ {};
|
||||
|
||||
// enables as_wstring[...]
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::as_wstring>
|
||||
: mpl::true_ {};
|
||||
|
||||
// enables as<T>[...]
|
||||
template <typename T>
|
||||
struct use_directive<qi::domain, tag::stateful_tag<T, tag::as> >
|
||||
: mpl::true_
|
||||
{};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::as_string;
|
||||
using spirit::as_wstring;
|
||||
#endif
|
||||
using spirit::as_string_type;
|
||||
using spirit::as_wstring_type;
|
||||
|
||||
template <typename Subject, typename T>
|
||||
struct as_directive : unary_parser<as_directive<Subject, T> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
as_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef T 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
|
||||
{
|
||||
Iterator i = first;
|
||||
T as_attr;
|
||||
if (subject.parse(i, last, context, skipper, as_attr))
|
||||
{
|
||||
spirit::traits::assign_to(as_attr, attr_);
|
||||
first = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context, typename Skipper>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper, T& attr_) const
|
||||
{
|
||||
Iterator i = first;
|
||||
if (subject.parse(i, last, context, skipper, attr_))
|
||||
{
|
||||
first = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("as", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::as_string, Subject, Modifiers>
|
||||
{
|
||||
typedef as_directive<Subject, std::string> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject
|
||||
, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::as_wstring, Subject, Modifiers>
|
||||
{
|
||||
typedef as_directive<Subject, std::basic_string<wchar_t> > result_type;
|
||||
result_type operator()(unused_type, Subject const& subject
|
||||
, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::stateful_tag<T, tag::as>, Subject, Modifiers>
|
||||
{
|
||||
typedef as_directive<Subject, T> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject
|
||||
, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename T>
|
||||
struct has_semantic_action<qi::as_directive<Subject, T> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename T, typename Attribute
|
||||
, typename Context, typename Iterator>
|
||||
struct handles_container<qi::as_directive<Subject, T>, Attribute
|
||||
, Context, Iterator>
|
||||
: mpl::false_ {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_ENCODING_MARCH_05_2010_0528PM)
|
||||
#define SPIRIT_ENCODING_MARCH_05_2010_0528PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename CharEncoding>
|
||||
struct use_directive<
|
||||
qi::domain, tag::char_code<tag::encoding, CharEncoding> > // enables encoding
|
||||
: mpl::true_ {};
|
||||
|
||||
template <typename CharEncoding>
|
||||
struct is_modifier_directive<qi::domain, tag::char_code<tag::encoding, CharEncoding> >
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_HOLD_FEBRUARY_6_2010_0917AM)
|
||||
#define SPIRIT_HOLD_FEBRUARY_6_2010_0917AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/support/attributes.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::hold> // enables hold
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::hold;
|
||||
#endif
|
||||
using spirit::hold_type;
|
||||
|
||||
template <typename Subject>
|
||||
struct hold_directive : unary_parser<hold_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
hold_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
traits::attribute_of<subject_type, Context, Iterator>::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
|
||||
{
|
||||
Attribute copy(attr_);
|
||||
if (subject.parse(first, last, context, skipper, copy))
|
||||
{
|
||||
traits::swap_impl(copy, attr_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("hold", subject.what(context));
|
||||
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::hold, Subject, Modifiers>
|
||||
{
|
||||
typedef hold_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::hold_directive<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::hold_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_LEXEME_MARCH_24_2007_0802AM)
|
||||
#define SPIRIT_LEXEME_MARCH_24_2007_0802AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::lexeme> // enables lexeme
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::lexeme;
|
||||
#endif
|
||||
using spirit::lexeme_type;
|
||||
|
||||
template <typename Subject>
|
||||
struct lexeme_directive : unary_parser<lexeme_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
lexeme_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
traits::attribute_of<subject_type, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
qi::skip_over(first, last, skipper);
|
||||
return subject.parse(first, last, context
|
||||
, detail::unused_skipper<Skipper>(skipper), attr_);
|
||||
}
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
// no need to pre-skip if skipper is unused
|
||||
//- qi::skip_over(first, last, skipper);
|
||||
return subject.parse(first, last, context
|
||||
, skipper, attr_);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("lexeme", subject.what(context));
|
||||
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::lexeme, Subject, Modifiers>
|
||||
{
|
||||
typedef lexeme_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::lexeme_directive<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::lexeme_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
/*=============================================================================
|
||||
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_MATCHES_JAN_07_2010_0745PM)
|
||||
#define SPIRIT_MATCHES_JAN_07_2010_0745PM
|
||||
|
||||
#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/detail/assign_to.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/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::matches> // enables matches
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::matches;
|
||||
#endif
|
||||
using spirit::matches_type;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// matches_directive returns whether the embedded parser matched
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct matches_directive : unary_parser<matches_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
matches_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef bool 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
|
||||
{
|
||||
bool result = subject.parse(first, last, context, skipper, unused);
|
||||
spirit::traits::assign_to(result, attr_);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("matches", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
matches_directive& operator= (matches_directive const&);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::matches, Subject, Modifiers>
|
||||
{
|
||||
typedef matches_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::matches_directive<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::matches_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_NO_CASE_OCTOBER_25_2008_0424PM)
|
||||
#define SPIRIT_NO_CASE_OCTOBER_25_2008_0424PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename CharEncoding>
|
||||
struct use_directive<
|
||||
qi::domain, tag::char_code<tag::no_case, CharEncoding> > // enables no_case
|
||||
: mpl::true_ {};
|
||||
|
||||
template <typename CharEncoding>
|
||||
struct is_modifier_directive<qi::domain, tag::char_code<tag::no_case, CharEncoding> >
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
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_NO_SKIP_JAN_16_2010_0802PM)
|
||||
#define SPIRIT_NO_SKIP_JAN_16_2010_0802PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/support/attributes.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::no_skip> // enables no_skip
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::no_skip;
|
||||
#endif
|
||||
using spirit::no_skip_type;
|
||||
|
||||
// same as lexeme[], but does not pre-skip
|
||||
template <typename Subject>
|
||||
struct no_skip_directive : unary_parser<no_skip_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
no_skip_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
traits::attribute_of<subject_type, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
return subject.parse(first, last, context
|
||||
, detail::unused_skipper<Skipper>(skipper), attr_);
|
||||
}
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
return subject.parse(first, last, context
|
||||
, skipper, attr_);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("no_skip", subject.what(context));
|
||||
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::no_skip, Subject, Modifiers>
|
||||
{
|
||||
typedef no_skip_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::no_skip_directive<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::no_skip_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,107 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_OMIT_MARCH_24_2007_0802AM)
|
||||
#define SPIRIT_OMIT_MARCH_24_2007_0802AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.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/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::omit> // enables omit
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::omit;
|
||||
#endif
|
||||
using spirit::omit_type;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// omit_directive forces the attribute of subject parser
|
||||
// to be unused_type
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct omit_directive : unary_parser<omit_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
omit_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
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
|
||||
{
|
||||
return subject.parse(first, last, context, skipper, attr_);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("omit", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
omit_directive& operator= (omit_directive const&);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::omit, Subject, Modifiers>
|
||||
{
|
||||
typedef omit_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::omit_directive<Subject> >
|
||||
: mpl::false_ {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::omit_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_RAW_APRIL_9_2007_0912AM)
|
||||
#define SPIRIT_RAW_APRIL_9_2007_0912AM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/parser.hpp>
|
||||
#include <boost/spirit/home/qi/detail/assign_to.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/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::raw> // enables raw
|
||||
: mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::raw;
|
||||
#endif
|
||||
using spirit::raw_type;
|
||||
|
||||
template <typename Subject>
|
||||
struct raw_directive : unary_parser<raw_directive<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
raw_directive(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef iterator_range<Iterator> 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 i = first;
|
||||
if (subject.parse(i, last, context, skipper, unused))
|
||||
{
|
||||
spirit::traits::assign_to(first, i, attr_);
|
||||
first = i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("raw", subject.what(context));
|
||||
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::raw, Subject, Modifiers>
|
||||
{
|
||||
typedef raw_directive<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::raw_directive<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::raw_directive<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,297 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Joel de Guzman
|
||||
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_REPEAT_NOVEMBER_14_2008_1148AM)
|
||||
#define SPIRIT_REPEAT_NOVEMBER_14_2008_1148AM
|
||||
|
||||
#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/auxiliary/lazy.hpp>
|
||||
#include <boost/spirit/home/qi/operator/kleene.hpp>
|
||||
#include <boost/spirit/home/support/container.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/qi/detail/fail_function.hpp>
|
||||
#include <boost/spirit/home/qi/detail/pass_container.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::repeat> // enables repeat[p]
|
||||
: mpl::true_ {};
|
||||
|
||||
template <typename T>
|
||||
struct use_directive<qi::domain
|
||||
, terminal_ex<tag::repeat // enables repeat(exact)[p]
|
||||
, fusion::vector1<T> >
|
||||
> : mpl::true_ {};
|
||||
|
||||
template <typename T>
|
||||
struct use_directive<qi::domain
|
||||
, terminal_ex<tag::repeat // enables repeat(min, max)[p]
|
||||
, fusion::vector2<T, T> >
|
||||
> : mpl::true_ {};
|
||||
|
||||
template <typename T>
|
||||
struct use_directive<qi::domain
|
||||
, terminal_ex<tag::repeat // enables repeat(min, inf)[p]
|
||||
, fusion::vector2<T, inf_type> >
|
||||
> : mpl::true_ {};
|
||||
|
||||
template <> // enables *lazy* repeat(exact)[p]
|
||||
struct use_lazy_directive<
|
||||
qi::domain
|
||||
, tag::repeat
|
||||
, 1 // arity
|
||||
> : mpl::true_ {};
|
||||
|
||||
template <> // enables *lazy* repeat(min, max)[p]
|
||||
struct use_lazy_directive< // and repeat(min, inf)[p]
|
||||
qi::domain
|
||||
, tag::repeat
|
||||
, 2 // arity
|
||||
> : mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::repeat;
|
||||
using spirit::inf;
|
||||
#endif
|
||||
using spirit::repeat_type;
|
||||
using spirit::inf_type;
|
||||
|
||||
template <typename T>
|
||||
struct exact_iterator // handles repeat(exact)[p]
|
||||
{
|
||||
exact_iterator(T const exact_)
|
||||
: exact(exact_) {}
|
||||
|
||||
typedef T type;
|
||||
T start() const { return 0; }
|
||||
bool got_max(T i) const { return i >= exact; }
|
||||
bool got_min(T i) const { return i >= exact; }
|
||||
|
||||
T const exact;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
exact_iterator& operator= (exact_iterator const&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct finite_iterator // handles repeat(min, max)[p]
|
||||
{
|
||||
finite_iterator(T const min_, T const max_)
|
||||
: min BOOST_PREVENT_MACRO_SUBSTITUTION (min_)
|
||||
, max BOOST_PREVENT_MACRO_SUBSTITUTION (max_) {}
|
||||
|
||||
typedef T type;
|
||||
T start() const { return 0; }
|
||||
bool got_max(T i) const { return i >= max; }
|
||||
bool got_min(T i) const { return i >= min; }
|
||||
|
||||
T const min;
|
||||
T const max;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
finite_iterator& operator= (finite_iterator const&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct infinite_iterator // handles repeat(min, inf)[p]
|
||||
{
|
||||
infinite_iterator(T const min_)
|
||||
: min BOOST_PREVENT_MACRO_SUBSTITUTION (min_) {}
|
||||
|
||||
typedef T type;
|
||||
T start() const { return 0; }
|
||||
bool got_max(T /*i*/) const { return false; }
|
||||
bool got_min(T i) const { return i >= min; }
|
||||
|
||||
T const min;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
infinite_iterator& operator= (infinite_iterator const&);
|
||||
};
|
||||
|
||||
template <typename Subject, typename LoopIter>
|
||||
struct repeat_parser : unary_parser<repeat_parser<Subject, LoopIter> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
// Build a std::vector from the subject's attribute. Note
|
||||
// that build_std_vector may return unused_type if the
|
||||
// subject's attribute is an unused_type.
|
||||
typedef typename
|
||||
traits::build_std_vector<
|
||||
typename traits::attribute_of<
|
||||
Subject, Context, Iterator>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
repeat_parser(Subject const& subject_, LoopIter const& iter_)
|
||||
: subject(subject_), iter(iter_) {}
|
||||
|
||||
template <typename F>
|
||||
bool parse_container(F f) const
|
||||
{
|
||||
typename LoopIter::type i = iter.start();
|
||||
for (/**/; !iter.got_min(i); ++i)
|
||||
{
|
||||
if (f (subject))
|
||||
return false;
|
||||
}
|
||||
|
||||
// parse some more up to the maximum specified
|
||||
typename F::iterator_type save = f.f.first;
|
||||
for (/**/; !iter.got_max(i); ++i)
|
||||
{
|
||||
if (f (subject))
|
||||
break;
|
||||
save = f.f.first;
|
||||
}
|
||||
|
||||
f.f.first = save;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
typedef detail::fail_function<Iterator, Context, Skipper>
|
||||
fail_function;
|
||||
|
||||
// ensure the attribute is actually a container type
|
||||
traits::make_container(attr_);
|
||||
|
||||
Iterator iter_local = first;
|
||||
fail_function f(iter_local, last, context, skipper);
|
||||
if (!parse_container(detail::make_pass_container(f, attr_)))
|
||||
return false;
|
||||
|
||||
first = f.first;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("repeat", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
LoopIter iter;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
repeat_parser& operator= (repeat_parser const&);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::repeat, Subject, Modifiers>
|
||||
{
|
||||
typedef kleene<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Subject, typename Modifiers>
|
||||
struct make_directive<
|
||||
terminal_ex<tag::repeat, fusion::vector1<T> >, Subject, Modifiers>
|
||||
{
|
||||
typedef exact_iterator<T> iterator_type;
|
||||
typedef repeat_parser<Subject, iterator_type> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(
|
||||
Terminal const& term, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject, fusion::at_c<0>(term.args));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Subject, typename Modifiers>
|
||||
struct make_directive<
|
||||
terminal_ex<tag::repeat, fusion::vector2<T, T> >, Subject, Modifiers>
|
||||
{
|
||||
typedef finite_iterator<T> iterator_type;
|
||||
typedef repeat_parser<Subject, iterator_type> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(
|
||||
Terminal const& term, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject,
|
||||
iterator_type(
|
||||
fusion::at_c<0>(term.args)
|
||||
, fusion::at_c<1>(term.args)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Subject, typename Modifiers>
|
||||
struct make_directive<
|
||||
terminal_ex<tag::repeat
|
||||
, fusion::vector2<T, inf_type> >, Subject, Modifiers>
|
||||
{
|
||||
typedef infinite_iterator<T> iterator_type;
|
||||
typedef repeat_parser<Subject, iterator_type> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(
|
||||
Terminal const& term, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject, fusion::at_c<0>(term.args));
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename LoopIter>
|
||||
struct has_semantic_action<qi::repeat_parser<Subject, LoopIter> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename LoopIter, typename Attribute
|
||||
, typename Context, typename Iterator>
|
||||
struct handles_container<qi::repeat_parser<Subject, LoopIter>
|
||||
, Attribute, Context, Iterator>
|
||||
: mpl::true_ {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,202 @@
|
||||
/*=============================================================================
|
||||
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(SPIRIT_SKIP_JANUARY_26_2008_0422PM)
|
||||
#define SPIRIT_SKIP_JANUARY_26_2008_0422PM
|
||||
|
||||
#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/auxiliary/lazy.hpp>
|
||||
#include <boost/spirit/home/qi/operator/kleene.hpp>
|
||||
#include <boost/spirit/home/qi/directive/lexeme.hpp>
|
||||
#include <boost/spirit/home/qi/skip_over.hpp>
|
||||
#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
|
||||
#include <boost/spirit/home/support/container.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/qi/detail/attributes.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/has_semantic_action.hpp>
|
||||
#include <boost/spirit/home/support/handles_container.hpp>
|
||||
#include <boost/fusion/include/at.hpp>
|
||||
#include <boost/fusion/include/vector.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <>
|
||||
struct use_directive<qi::domain, tag::skip> // enables skip[p]
|
||||
: mpl::true_ {};
|
||||
|
||||
template <typename T>
|
||||
struct use_directive<qi::domain
|
||||
, terminal_ex<tag::skip // enables skip(s)[p]
|
||||
, fusion::vector1<T> >
|
||||
> : boost::spirit::traits::matches<qi::domain, T> {};
|
||||
|
||||
template <> // enables *lazy* skip(s)[p]
|
||||
struct use_lazy_directive<
|
||||
qi::domain
|
||||
, tag::skip
|
||||
, 1 // arity
|
||||
> : mpl::true_ {};
|
||||
}}
|
||||
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using spirit::skip;
|
||||
#endif
|
||||
using spirit::skip_type;
|
||||
|
||||
template <typename Subject>
|
||||
struct reskip_parser : unary_parser<reskip_parser<Subject> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
traits::attribute_of<Subject, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
reskip_parser(Subject const& subject_)
|
||||
: subject(subject_) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& u // --> The skipper is reintroduced
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
return subject.parse(first, last, context
|
||||
, detail::get_skipper(u), attr_);
|
||||
}
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type
|
||||
parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper const& skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
return subject.parse(first, last, context
|
||||
, skipper, attr_);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("skip", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
};
|
||||
|
||||
template <typename Subject, typename Skipper>
|
||||
struct skip_parser : unary_parser<skip_parser<Subject, Skipper> >
|
||||
{
|
||||
typedef Subject subject_type;
|
||||
typedef Skipper skipper_type;
|
||||
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef typename
|
||||
traits::attribute_of<Subject, Context, Iterator>::type
|
||||
type;
|
||||
};
|
||||
|
||||
skip_parser(Subject const& subject_, Skipper const& skipper_)
|
||||
: subject(subject_), skipper(skipper_) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper_, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context& context, Skipper_ const& //skipper --> bypass the supplied skipper
|
||||
, Attribute& attr_) const
|
||||
{
|
||||
return subject.parse(first, last, context, skipper, attr_);
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context& context) const
|
||||
{
|
||||
return info("skip", subject.what(context));
|
||||
}
|
||||
|
||||
Subject subject;
|
||||
Skipper skipper;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Modifiers>
|
||||
struct make_directive<tag::skip, Subject, Modifiers>
|
||||
{
|
||||
typedef reskip_parser<Subject> result_type;
|
||||
result_type operator()(unused_type, Subject const& subject, unused_type) const
|
||||
{
|
||||
return result_type(subject);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Skipper, typename Subject, typename Modifiers>
|
||||
struct make_directive<
|
||||
terminal_ex<tag::skip, fusion::vector1<Skipper> >, Subject, Modifiers>
|
||||
{
|
||||
typedef typename
|
||||
result_of::compile<qi::domain, Skipper, Modifiers>::type
|
||||
skipper_type;
|
||||
|
||||
typedef skip_parser<Subject, skipper_type> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, Subject const& subject
|
||||
, Modifiers const& modifiers) const
|
||||
{
|
||||
return result_type(subject
|
||||
, compile<qi::domain>(fusion::at_c<0>(term.args), modifiers));
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject>
|
||||
struct has_semantic_action<qi::reskip_parser<Subject> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
template <typename Subject, typename Skipper>
|
||||
struct has_semantic_action<qi::skip_parser<Subject, Skipper> >
|
||||
: unary_has_semantic_action<Subject> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Subject, typename Attribute, typename Context
|
||||
, typename Iterator>
|
||||
struct handles_container<qi::reskip_parser<Subject>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
|
||||
template <typename Subject, typename Skipper, typename Attribute
|
||||
, typename Context, typename Iterator>
|
||||
struct handles_container<qi::skip_parser<Subject, Skipper>, Attribute
|
||||
, Context, Iterator>
|
||||
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user