add boost on mac
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2015 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_X3__ANNOTATE_ON_SUCCESS_HPP)
|
||||
#define BOOST_SPIRIT_X3__ANNOTATE_ON_SUCCESS_HPP
|
||||
|
||||
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
|
||||
#include <boost/spirit/home/x3/support/utility/lambda_visitor.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// The on_success handler tags the AST with the iterator position
|
||||
// for error handling.
|
||||
//
|
||||
// The on_success handler also ties the AST to a vector of iterator
|
||||
// positions for the purpose of subsequent semantic error handling
|
||||
// when the program is being compiled. See x3::position_cache in
|
||||
// x3/support/ast.
|
||||
//
|
||||
// We'll ask the X3's error_handler utility to do these.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct annotate_on_success
|
||||
{
|
||||
template <typename Iterator, typename Context, typename... Types>
|
||||
inline void on_success(Iterator const& first, Iterator const& last
|
||||
, variant<Types...>& ast, Context const& context)
|
||||
{
|
||||
ast.apply_visitor(x3::make_lambda_visitor<void>([&](auto& node)
|
||||
{
|
||||
this->on_success(first, last, node, context);
|
||||
}));
|
||||
}
|
||||
|
||||
template <typename T, typename Iterator, typename Context>
|
||||
inline void on_success(Iterator const& first, Iterator const& last
|
||||
, T& ast, Context const& context)
|
||||
{
|
||||
auto& error_handler = get<error_handler_tag>(context).get();
|
||||
error_handler.tag(ast, first, last);
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,242 @@
|
||||
/*=============================================================================
|
||||
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(BOOST_SPIRIT_X3_ERROR_REPORTING_MAY_19_2014_00405PM)
|
||||
#define BOOST_SPIRIT_X3_ERROR_REPORTING_MAY_19_2014_00405PM
|
||||
|
||||
#ifndef BOOST_SPIRIT_X3_NO_FILESYSTEM
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/locale/encoding_utf.hpp>
|
||||
#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
|
||||
#include <ostream>
|
||||
|
||||
// Clang-style error handling utilities
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
// tag used to get our error handler from the context
|
||||
struct error_handler_tag;
|
||||
|
||||
template <typename Iterator>
|
||||
class error_handler
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Iterator iterator_type;
|
||||
|
||||
error_handler(
|
||||
Iterator first, Iterator last, std::ostream& err_out
|
||||
, std::string file = "", int tabs = 4)
|
||||
: err_out(err_out)
|
||||
, file(file)
|
||||
, tabs(tabs)
|
||||
, pos_cache(first, last) {}
|
||||
|
||||
typedef void result_type;
|
||||
|
||||
void operator()(Iterator err_pos, std::string const& error_message) const;
|
||||
void operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const;
|
||||
void operator()(position_tagged pos, std::string const& message) const
|
||||
{
|
||||
auto where = pos_cache.position_of(pos);
|
||||
(*this)(where.begin(), where.end(), message);
|
||||
}
|
||||
|
||||
template <typename AST>
|
||||
void tag(AST& ast, Iterator first, Iterator last)
|
||||
{
|
||||
return pos_cache.annotate(ast, first, last);
|
||||
}
|
||||
|
||||
boost::iterator_range<Iterator> position_of(position_tagged pos) const
|
||||
{
|
||||
return pos_cache.position_of(pos);
|
||||
}
|
||||
|
||||
position_cache<std::vector<Iterator>> const& get_position_cache() const
|
||||
{
|
||||
return pos_cache;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void print_file_line(std::size_t line) const;
|
||||
void print_line(Iterator line_start, Iterator last) const;
|
||||
void print_indicator(Iterator& line_start, Iterator last, char ind) const;
|
||||
void skip_whitespace(Iterator& err_pos, Iterator last) const;
|
||||
void skip_non_whitespace(Iterator& err_pos, Iterator last) const;
|
||||
Iterator get_line_start(Iterator first, Iterator pos) const;
|
||||
std::size_t position(Iterator i) const;
|
||||
|
||||
std::ostream& err_out;
|
||||
std::string file;
|
||||
int tabs;
|
||||
position_cache<std::vector<Iterator>> pos_cache;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::print_file_line(std::size_t line) const
|
||||
{
|
||||
if (file != "")
|
||||
{
|
||||
#ifdef BOOST_SPIRIT_X3_NO_FILESYSTEM
|
||||
err_out << "In file " << file << ", ";
|
||||
#else
|
||||
namespace fs = boost::filesystem;
|
||||
err_out << "In file " << fs::path(file).generic_string() << ", ";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
err_out << "In ";
|
||||
}
|
||||
|
||||
err_out << "line " << line << ':' << std::endl;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::print_line(Iterator start, Iterator last) const
|
||||
{
|
||||
auto end = start;
|
||||
while (end != last)
|
||||
{
|
||||
auto c = *end;
|
||||
if (c == '\r' || c == '\n')
|
||||
break;
|
||||
else
|
||||
++end;
|
||||
}
|
||||
typedef typename std::iterator_traits<Iterator>::value_type char_type;
|
||||
std::basic_string<char_type> line{start, end};
|
||||
err_out << locale::conv::utf_to_utf<char>(line) << std::endl;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::print_indicator(Iterator& start, Iterator last, char ind) const
|
||||
{
|
||||
for (; start != last; ++start)
|
||||
{
|
||||
auto c = *start;
|
||||
if (c == '\r' || c == '\n')
|
||||
break;
|
||||
else if (c == '\t')
|
||||
for (int i = 0; i < tabs; ++i)
|
||||
err_out << ind;
|
||||
else
|
||||
err_out << ind;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::skip_whitespace(Iterator& err_pos, Iterator last) const
|
||||
{
|
||||
// make sure err_pos does not point to white space
|
||||
while (err_pos != last)
|
||||
{
|
||||
char c = *err_pos;
|
||||
if (std::isspace(c))
|
||||
++err_pos;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::skip_non_whitespace(Iterator& err_pos, Iterator last) const
|
||||
{
|
||||
// make sure err_pos does not point to white space
|
||||
while (err_pos != last)
|
||||
{
|
||||
char c = *err_pos;
|
||||
if (std::isspace(c))
|
||||
break;
|
||||
else
|
||||
++err_pos;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
inline Iterator error_handler<Iterator>::get_line_start(Iterator first, Iterator pos) const
|
||||
{
|
||||
Iterator latest = first;
|
||||
for (Iterator i = first; i != pos; ++i)
|
||||
if (*i == '\r' || *i == '\n')
|
||||
latest = i;
|
||||
return latest;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
std::size_t error_handler<Iterator>::position(Iterator i) const
|
||||
{
|
||||
std::size_t line { 1 };
|
||||
typename std::iterator_traits<Iterator>::value_type prev { 0 };
|
||||
|
||||
for (Iterator pos = pos_cache.first(); pos != i; ++pos) {
|
||||
auto c = *pos;
|
||||
switch (c) {
|
||||
case '\n':
|
||||
if (prev != '\r') ++line;
|
||||
break;
|
||||
case '\r':
|
||||
++line;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prev = c;
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::operator()(
|
||||
Iterator err_pos, std::string const& error_message) const
|
||||
{
|
||||
Iterator first = pos_cache.first();
|
||||
Iterator last = pos_cache.last();
|
||||
|
||||
// make sure err_pos does not point to white space
|
||||
skip_whitespace(err_pos, last);
|
||||
|
||||
print_file_line(position(err_pos));
|
||||
err_out << error_message << std::endl;
|
||||
|
||||
Iterator start = get_line_start(first, err_pos);
|
||||
if (start != first)
|
||||
++start;
|
||||
print_line(start, last);
|
||||
print_indicator(start, err_pos, '_');
|
||||
err_out << "^_" << std::endl;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
void error_handler<Iterator>::operator()(
|
||||
Iterator err_first, Iterator err_last, std::string const& error_message) const
|
||||
{
|
||||
Iterator first = pos_cache.first();
|
||||
Iterator last = pos_cache.last();
|
||||
|
||||
// make sure err_pos does not point to white space
|
||||
skip_whitespace(err_first, last);
|
||||
|
||||
print_file_line(position(err_first));
|
||||
err_out << error_message << std::endl;
|
||||
|
||||
Iterator start = get_line_start(first, err_first);
|
||||
if (start != first)
|
||||
++start;
|
||||
print_line(start, last);
|
||||
print_indicator(start, err_first, ' ');
|
||||
print_indicator(start, err_last, '~');
|
||||
err_out << " <<-- Here" << std::endl;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
Copyright (c) 2014 Jamboree
|
||||
|
||||
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_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED
|
||||
#define BOOST_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
{
|
||||
template <typename Sig, typename Enable = void>
|
||||
struct is_callable_impl : mpl::false_ {};
|
||||
|
||||
template <typename F, typename... A>
|
||||
struct is_callable_impl<F(A...), typename disable_if_substitution_failure<
|
||||
decltype(std::declval<F>()(std::declval<A>()...))>::type>
|
||||
: mpl::true_
|
||||
{};
|
||||
}}}}
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Sig>
|
||||
struct is_callable;
|
||||
|
||||
template <typename F, typename... A>
|
||||
struct is_callable<F(A...)> : detail::is_callable_impl<F(A...)> {};
|
||||
}}}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*=============================================================================
|
||||
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(BOOST_SPIRIT_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM)
|
||||
#define BOOST_SPIRIT_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename RT, typename... Lambdas>
|
||||
struct lambda_visitor;
|
||||
|
||||
template <typename RT, typename F, typename... Lambdas>
|
||||
struct lambda_visitor<RT, F, Lambdas...> : F, lambda_visitor<RT, Lambdas...>
|
||||
{
|
||||
typedef lambda_visitor<RT , Lambdas...> base_type;
|
||||
using F::operator();
|
||||
using base_type::operator();
|
||||
lambda_visitor(F f, Lambdas... lambdas)
|
||||
: F(f), base_type(lambdas...)
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename RT, typename F>
|
||||
struct lambda_visitor<RT, F> : F
|
||||
{
|
||||
typedef RT result_type;
|
||||
using F::operator();
|
||||
lambda_visitor(F f)
|
||||
: F(f)
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename RT>
|
||||
struct lambda_visitor<RT>
|
||||
{
|
||||
typedef RT result_type;
|
||||
};
|
||||
|
||||
template <typename RT, typename... Lambdas>
|
||||
lambda_visitor<RT, Lambdas...> make_lambda_visitor(Lambdas... lambdas)
|
||||
{
|
||||
return { lambdas... };
|
||||
}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/*=============================================================================
|
||||
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(BOOST_SPIRIT_X3_SFINAE_MAY_20_2013_0840AM)
|
||||
#define BOOST_SPIRIT_X3_SFINAE_MAY_20_2013_0840AM
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Expr, typename T = void>
|
||||
struct disable_if_substitution_failure
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename Expr, typename T>
|
||||
struct lazy_disable_if_substitution_failure
|
||||
{
|
||||
typedef typename T::type type;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
269
macx64/include/boost/spirit/home/x3/support/utility/testing.hpp
Normal file
269
macx64/include/boost/spirit/home/x3/support/utility/testing.hpp
Normal file
@@ -0,0 +1,269 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2015 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_X3_TEST_UTILITIES)
|
||||
#define BOOST_SPIRIT_X3_TEST_UTILITIES
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3 { namespace testing
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// compare
|
||||
//
|
||||
// Compares the contents of in with the template tem. The template
|
||||
// may include embedded regular expressions marked up within re_prefix
|
||||
// and re_suffix tags. For example, given the default RE markup, this
|
||||
// template <%[0-9]+%> will match any integer in in. The function
|
||||
// will return the first non-matching position. The flag full_match
|
||||
// indicates a full match. It is possible for returned pos to be
|
||||
// at the end of in (in.end()) while still returning full_match ==
|
||||
// false. In that case, we have a partial match.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename Iterator>
|
||||
struct compare_result
|
||||
{
|
||||
compare_result(
|
||||
Iterator pos
|
||||
, bool full_match
|
||||
) : pos(pos), full_match(full_match) {}
|
||||
|
||||
Iterator pos;
|
||||
bool full_match;
|
||||
};
|
||||
|
||||
template <typename Range>
|
||||
compare_result<typename Range::const_iterator>
|
||||
compare(
|
||||
Range const& in
|
||||
, Range const& tem
|
||||
, char const* re_prefix = "<%"
|
||||
, char const* re_suffix = "%>"
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// compare
|
||||
//
|
||||
// 1) Call f, given the contents of input_path loaded in a string.
|
||||
// The result of calling f is the output string.
|
||||
// 2) Compare the result of calling f with expected template
|
||||
// file (expect_path) using the low-level compare utility
|
||||
// abive
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <typename F>
|
||||
bool compare(
|
||||
fs::path input_path, fs::path expect_path
|
||||
, F f
|
||||
, char const* re_prefix = "<%"
|
||||
, char const* re_suffix = "%>"
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// for_each_file
|
||||
//
|
||||
// For each *.input and *.expect file in a given directory,
|
||||
// call the function f, passing in the *.input and *.expect paths.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <typename F>
|
||||
int for_each_file(fs::path p, F f);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// load_file
|
||||
//
|
||||
// Load file into a string.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
std::string load(fs::path p);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Implementation
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename Iterator>
|
||||
inline bool is_regex(
|
||||
Iterator& first
|
||||
, Iterator last
|
||||
, std::string& re
|
||||
, char const* re_prefix
|
||||
, char const* re_suffix
|
||||
)
|
||||
{
|
||||
boost::regex e(re_prefix + std::string("(.*?)") + re_suffix);
|
||||
boost::match_results<Iterator> what;
|
||||
if (boost::regex_search(
|
||||
first, last, what, e
|
||||
, boost::match_default | boost::match_continuous))
|
||||
{
|
||||
re = what[1].str();
|
||||
first = what[0].second;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
inline compare_result<typename Range::const_iterator>
|
||||
compare(
|
||||
Range const& in
|
||||
, Range const& tem
|
||||
, char const* re_prefix
|
||||
, char const* re_suffix
|
||||
)
|
||||
{
|
||||
typedef typename Range::const_iterator iter_t;
|
||||
typedef compare_result<iter_t> compare_result_t;
|
||||
|
||||
iter_t in_first = in.begin();
|
||||
iter_t in_last = in.end();
|
||||
iter_t tem_first = tem.begin();
|
||||
iter_t tem_last = tem.end();
|
||||
std::string re;
|
||||
|
||||
while (in_first != in_last && tem_first != tem_last)
|
||||
{
|
||||
if (is_regex(tem_first, tem_last, re, re_prefix, re_suffix))
|
||||
{
|
||||
boost::match_results<iter_t> what;
|
||||
boost::regex e(re);
|
||||
if (!boost::regex_search(
|
||||
in_first, in_last, what, e
|
||||
, boost::match_default | boost::match_continuous))
|
||||
{
|
||||
// RE mismatch: exit now.
|
||||
return compare_result_t(in_first, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RE match: gobble the matching string.
|
||||
in_first = what[0].second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Char by char comparison. Exit if we have a mismatch.
|
||||
if (*in_first++ != *tem_first++)
|
||||
return compare_result_t(in_first, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore trailing spaces in template
|
||||
bool has_trailing_nonspaces = false;
|
||||
while (tem_first != tem_last)
|
||||
{
|
||||
if (!std::isspace(*tem_first++))
|
||||
{
|
||||
has_trailing_nonspaces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (in_first != in_last)
|
||||
{
|
||||
if (!std::isspace(*in_first++))
|
||||
{
|
||||
has_trailing_nonspaces = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// return a full match only if the template is fully matched and if there
|
||||
// are no more characters to match in the source
|
||||
return compare_result_t(in_first, !has_trailing_nonspaces);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
inline int for_each_file(fs::path p, F f)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fs::exists(p) && fs::is_directory(p))
|
||||
{
|
||||
for (auto i = fs::directory_iterator(p); i != fs::directory_iterator(); ++i)
|
||||
{
|
||||
auto ext = fs::extension(i->path());
|
||||
if (ext == ".input")
|
||||
{
|
||||
auto input_path = i->path();
|
||||
auto expect_path = input_path;
|
||||
expect_path.replace_extension(".expect");
|
||||
f(input_path, expect_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Directory: " << fs::absolute(p) << " does not exist." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
catch (const fs::filesystem_error& ex)
|
||||
{
|
||||
std::cerr << ex.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline std::string load(fs::path p)
|
||||
{
|
||||
boost::filesystem::ifstream file(p);
|
||||
if (!file)
|
||||
return "";
|
||||
std::string contents((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||
return contents;
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
inline bool compare(
|
||||
fs::path input_path, fs::path expect_path
|
||||
, F f
|
||||
, char const* re_prefix
|
||||
, char const* re_suffix
|
||||
)
|
||||
{
|
||||
std::string output = f(load(input_path), input_path);
|
||||
std::string expected = load(expect_path);
|
||||
|
||||
auto result = compare(output, expected, re_prefix, re_suffix);
|
||||
if (!result.full_match)
|
||||
{
|
||||
std::cout << "=============================================" << std::endl;
|
||||
std::cout << "==== Mismatch Found:" << std::endl;
|
||||
int line = 1;
|
||||
int col = 1;
|
||||
for (auto i = output.begin(); i != result.pos; ++i)
|
||||
{
|
||||
if (*i == '\n')
|
||||
{
|
||||
line++;
|
||||
col = 0;
|
||||
}
|
||||
++col;
|
||||
}
|
||||
|
||||
std::cerr
|
||||
<< "==== File: " << expect_path
|
||||
<< ", Line: " << line
|
||||
<< ", Column: " << col
|
||||
<< std::endl;
|
||||
std::cerr << "=============================================" << std::endl;
|
||||
|
||||
// Print output
|
||||
std::cerr << output;
|
||||
std::cerr << "=============================================" << std::endl;
|
||||
std::cerr << "==== End" << std::endl;
|
||||
std::cerr << "=============================================" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
Copyright (c) 2014 Jamboree
|
||||
|
||||
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_SPIRIT_X3_UNREFCV_HPP_INCLUDED
|
||||
#define BOOST_SPIRIT_X3_UNREFCV_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename T>
|
||||
struct unrefcv : remove_cv<typename remove_reference<T>::type> {};
|
||||
|
||||
template <typename T>
|
||||
using unrefcv_t = typename unrefcv<T>::type;
|
||||
}}}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
105
macx64/include/boost/spirit/home/x3/support/utility/utf8.hpp
Normal file
105
macx64/include/boost/spirit/home/x3/support/utility/utf8.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/*=============================================================================
|
||||
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(BOOST_SPIRIT_X3_UC_TYPES_NOVEMBER_23_2008_0840PM)
|
||||
#define BOOST_SPIRIT_X3_UC_TYPES_NOVEMBER_23_2008_0840PM
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/regex/pending/unicode_iterator.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
typedef ::boost::uint32_t ucs4_char;
|
||||
typedef char utf8_char;
|
||||
typedef std::basic_string<ucs4_char> ucs4_string;
|
||||
typedef std::basic_string<utf8_char> utf8_string;
|
||||
|
||||
template <typename Char>
|
||||
inline utf8_string to_utf8(Char value)
|
||||
{
|
||||
// always store as UTF8
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
typedef typename make_unsigned<Char>::type UChar;
|
||||
*utf8_iter = (UChar)value;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
inline utf8_string to_utf8(Char const* str)
|
||||
{
|
||||
// always store as UTF8
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
typedef typename make_unsigned<Char>::type UChar;
|
||||
while (*str)
|
||||
*utf8_iter++ = (UChar)*str++;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Char, typename Traits, typename Allocator>
|
||||
inline utf8_string
|
||||
to_utf8(std::basic_string<Char, Traits, Allocator> const& str)
|
||||
{
|
||||
// always store as UTF8
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
typedef typename make_unsigned<Char>::type UChar;
|
||||
for (Char ch : str)
|
||||
{
|
||||
*utf8_iter++ = (UChar)ch;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assume wchar_t content is UTF-16 on Windows and UCS-4 on Unix
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
inline utf8_string to_utf8(wchar_t value)
|
||||
{
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
|
||||
u16_to_u32_iterator<wchar_t const*, ucs4_char> ucs4_iter(&value);
|
||||
*utf8_iter++ = *ucs4_iter;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline utf8_string to_utf8(wchar_t const* str)
|
||||
{
|
||||
utf8_string result;
|
||||
typedef std::back_insert_iterator<utf8_string> insert_iter;
|
||||
insert_iter out_iter(result);
|
||||
utf8_output_iterator<insert_iter> utf8_iter(out_iter);
|
||||
|
||||
u16_to_u32_iterator<wchar_t const*, ucs4_char> ucs4_iter(str);
|
||||
for (ucs4_char c; (c = *ucs4_iter) != ucs4_char(); ++ucs4_iter) {
|
||||
*utf8_iter++ = c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Traits, typename Allocator>
|
||||
inline utf8_string
|
||||
to_utf8(std::basic_string<wchar_t, Traits, Allocator> const& str)
|
||||
{
|
||||
return to_utf8(str.c_str());
|
||||
}
|
||||
#endif
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user