add boost on mac
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2011 Aaron Graham
|
||||
//
|
||||
// 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_REPOSITORY_QI_ADVANCE_JAN_23_2011_1203PM)
|
||||
#define BOOST_SPIRIT_REPOSITORY_QI_ADVANCE_JAN_23_2011_1203PM
|
||||
|
||||
#include <boost/spirit/home/support/terminal.hpp>
|
||||
#include <boost/spirit/include/qi_parse.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// definition the place holder
|
||||
namespace boost { namespace spirit { namespace repository { namespace qi
|
||||
{
|
||||
BOOST_SPIRIT_TERMINAL_EX(advance)
|
||||
}}}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// implementation the enabler
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
template <typename A0>
|
||||
struct use_terminal<qi::domain
|
||||
, terminal_ex<repository::qi::tag::advance, fusion::vector1<A0> > >
|
||||
: mpl::or_<is_integral<A0>, is_enum<A0> >
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct use_lazy_terminal<qi::domain, repository::qi::tag::advance, 1>
|
||||
: mpl::true_
|
||||
{};
|
||||
}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// implementation of the parser
|
||||
namespace boost { namespace spirit { namespace repository { namespace qi
|
||||
{
|
||||
template <typename Int>
|
||||
struct advance_parser
|
||||
: boost::spirit::qi::primitive_parser< advance_parser<Int> >
|
||||
{
|
||||
// Define the attribute type exposed by this parser component
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef boost::spirit::unused_type type;
|
||||
};
|
||||
|
||||
advance_parser(Int dist)
|
||||
: dist(dist)
|
||||
{}
|
||||
|
||||
// This function is called during the actual parsing process
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context&, Skipper&, Attribute&) const
|
||||
{
|
||||
// This series of checks is designed to fail parsing on negative
|
||||
// values, without generating a "expression always evaluates true"
|
||||
// warning on unsigned types.
|
||||
if (dist == Int(0)) return true;
|
||||
if (dist < Int(1)) return false;
|
||||
|
||||
typedef typename std::iterator_traits<Iterator>::iterator_category
|
||||
iterator_category;
|
||||
return advance(first, last, iterator_category());
|
||||
}
|
||||
|
||||
// This function is called during error handling to create
|
||||
// a human readable string for the error context.
|
||||
template <typename Context>
|
||||
boost::spirit::info what(Context&) const
|
||||
{
|
||||
return boost::spirit::info("advance");
|
||||
}
|
||||
|
||||
private:
|
||||
// this is the general implementation used by most iterator categories
|
||||
template <typename Iterator, typename IteratorCategory>
|
||||
bool advance(Iterator& first, Iterator const& last
|
||||
, IteratorCategory) const
|
||||
{
|
||||
Int n = dist;
|
||||
Iterator i = first;
|
||||
while (n)
|
||||
{
|
||||
if (i == last) return false;
|
||||
++i;
|
||||
--n;
|
||||
}
|
||||
first = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
// this is a specialization for random access iterators
|
||||
template <typename Iterator>
|
||||
bool advance(Iterator& first, Iterator const& last
|
||||
, std::random_access_iterator_tag) const
|
||||
{
|
||||
Iterator const it = first + dist;
|
||||
if (it > last) return false;
|
||||
first = it;
|
||||
return true;
|
||||
}
|
||||
|
||||
Int const dist;
|
||||
};
|
||||
}}}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// instantiation of the parser
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
template <typename Modifiers, typename A0>
|
||||
struct make_primitive<
|
||||
terminal_ex<repository::qi::tag::advance, fusion::vector1<A0> >
|
||||
, Modifiers>
|
||||
{
|
||||
typedef repository::qi::advance_parser<A0> result_type;
|
||||
|
||||
template <typename Terminal>
|
||||
result_type operator()(Terminal const& term, unused_type) const
|
||||
{
|
||||
return result_type(fusion::at_c<0>(term.args));
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
// 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_REPOSITORY_QI_FLUSH_MULTI_PASS_JUL_10_2009_0535PM)
|
||||
#define BOOST_SPIRIT_REPOSITORY_QI_FLUSH_MULTI_PASS_JUL_10_2009_0535PM
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/home/qi/domain.hpp>
|
||||
#include <boost/spirit/home/qi/meta_compiler.hpp>
|
||||
#include <boost/spirit/home/support/common_terminals.hpp>
|
||||
#include <boost/spirit/home/support/info.hpp>
|
||||
#include <boost/spirit/home/support/unused.hpp>
|
||||
#include <boost/spirit/home/support/attributes.hpp>
|
||||
#include <boost/spirit/home/support/multi_pass.hpp>
|
||||
|
||||
#include <boost/spirit/repository/home/support/flush_multi_pass.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Enablers
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// enables flush_multi_pass
|
||||
template <>
|
||||
struct use_terminal<qi::domain, repository::tag::flush_multi_pass>
|
||||
: mpl::true_ {};
|
||||
|
||||
}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace spirit { namespace repository { namespace qi
|
||||
{
|
||||
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
||||
using repository::flush_multi_pass;
|
||||
#endif
|
||||
using repository::flush_multi_pass_type;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// for a flush_multi_pass_parser generated parser
|
||||
struct flush_multi_pass_parser
|
||||
: spirit::qi::primitive_parser<flush_multi_pass_parser>
|
||||
{
|
||||
template <typename Context, typename Unused>
|
||||
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
|
||||
{
|
||||
spirit::traits::clear_queue(first, traits::clear_mode::clear_always);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
info what(Context const& ctx) const
|
||||
{
|
||||
return info("flush_multi_pass");
|
||||
}
|
||||
};
|
||||
|
||||
}}}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Parser generators: make_xxx function (objects)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<repository::tag::flush_multi_pass, Modifiers>
|
||||
{
|
||||
typedef repository::qi::flush_multi_pass_parser result_type;
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// 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_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM)
|
||||
#define BOOST_SPIRIT_REPOSITORY_QI_ITER_POS_NOV_20_2009_1245PM
|
||||
|
||||
#include <boost/spirit/include/qi_parse.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// definition the place holder
|
||||
namespace boost { namespace spirit { namespace repository { namespace qi
|
||||
{
|
||||
BOOST_SPIRIT_TERMINAL(iter_pos)
|
||||
}}}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// implementation the enabler
|
||||
namespace boost { namespace spirit
|
||||
{
|
||||
// We want custom_parser::iter_pos to be usable as a terminal only,
|
||||
// and only for parser expressions (qi::domain).
|
||||
template <>
|
||||
struct use_terminal<qi::domain, repository::qi::tag::iter_pos>
|
||||
: mpl::true_
|
||||
{};
|
||||
}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// implementation of the parser
|
||||
namespace boost { namespace spirit { namespace repository { namespace qi
|
||||
{
|
||||
struct iter_pos_parser
|
||||
: boost::spirit::qi::primitive_parser<iter_pos_parser>
|
||||
{
|
||||
// Define the attribute type exposed by this parser component
|
||||
template <typename Context, typename Iterator>
|
||||
struct attribute
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
// This function is called during the actual parsing process
|
||||
template <typename Iterator, typename Context
|
||||
, typename Skipper, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context&, Skipper const& skipper, Attribute& attr) const
|
||||
{
|
||||
boost::spirit::qi::skip_over(first, last, skipper);
|
||||
boost::spirit::traits::assign_to(first, attr);
|
||||
return true;
|
||||
}
|
||||
|
||||
// This function is called during error handling to create
|
||||
// a human readable string for the error context.
|
||||
template <typename Context>
|
||||
boost::spirit::info what(Context&) const
|
||||
{
|
||||
return boost::spirit::info("iter_pos");
|
||||
}
|
||||
};
|
||||
}}}}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// instantiation of the parser
|
||||
namespace boost { namespace spirit { namespace qi
|
||||
{
|
||||
// This is the factory function object invoked in order to create
|
||||
// an instance of our iter_pos_parser.
|
||||
template <typename Modifiers>
|
||||
struct make_primitive<repository::qi::tag::iter_pos, Modifiers>
|
||||
{
|
||||
typedef repository::qi::iter_pos_parser result_type;
|
||||
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type();
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user