I'm having a little problem trying to compile some code using the latest MinGW (GCC 4.5.2) under the 64-bit version of Windows Vista Home Premium. When compiling this file, I get a message saying "cc1plus.exe stopped working" and the compilation failed, without an error message. I tried to delete the file to an absolute minimum minimum, which still causes the problem:
#include <boost/spirit/include/classic_file_iterator.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/qi.hpp>
#include <vector>
#define BOOST_SPIRIT_AUTO(domain_, name, expr) \
typedef boost::proto::result_of:: \
deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \
BOOST_SPIRIT_ASSERT_MATCH( \
boost::spirit::domain_::domain, name##_expr_type); \
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
using namespace std;
struct TileCase {
vector<unsigned> filled;
vector<unsigned> optionalFilled;
TileCase() : filled(0),
optionalFilled(0){}
};
BOOST_FUSION_ADAPT_STRUCT (
TileCase,
(std::vector<unsigned>, filled)
(std::vector<unsigned>, optionalFilled)
)
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
namespace ascii = boost::spirit::ascii;
using phoenix::function;
using ascii::space;
using ascii::char_;
using qi::eol;
BOOST_SPIRIT_AUTO(qi, comment, ("/*" >> *(char_ - "*/") >> "*/")
| ascii::space
| ("//" >> *(char_ - eol) >> eol)
);
struct error_handler_ {
template<typename, typename, typename>
struct result { typedef void type; };
template <typename Iterator>
void operator()(
qi::info const& what,
Iterator err_pos, Iterator last) const
{
boost::spirit::classic::file_position_base<string> const& pos = err_pos.get_position();
stringstream error;
error << "Error! Expecting "
<< what
<< " at line "
<< pos.line
<< ", column "
<< pos.column
<< "!";
throw(runtime_error(error.str()));
}
};
function<error_handler_> const error_handler = error_handler_();
template<typename Iterator>
struct tileData : qi::grammar<Iterator, vector<TileCase>(), comment_expr_type> {
qi::rule<Iterator, vector<TileCase>(), comment_expr_type> start;
qi::rule<Iterator, TileCase(), qi::locals<unsigned>, comment_expr_type> tile;
qi::rule<Iterator, void(unsigned&, unsigned&), qi::locals<unsigned>, comment_expr_type> condBlock;
tileData() : tileData::base_type(start) {
using qi::eps;
using qi::lit;
using qi::on_error;
using qi::fail;
using qi::uint_;
using phoenix::at_c;
using phoenix::push_back;
using phoenix::resize;
using namespace qi::labels;
start = *tile[push_back(_val, _1)];
tile =
lit("filled")
> '('
> uint_
[
_a = _1,
resize(at_c<0>(_val), _1 + 1),
resize(at_c<1>(_val), _1 + 1)
]
> ')'
> '{'
> condBlock
(
(at_c<0>(_val))[_a],
(at_c<1>(_val))[_a]
)
> '}'
;
condBlock =
eps
[_a = 1]
>>
(
* (
(
+lit('+')
[_r1 += _a, _a *= 2]
)
|
(
+lit('*')
[_r2 += _a, _a *= 2]
)
|
(
+lit('-')
[_a *= 2]
)
)
)
;
on_error<fail>
(
start,
error_handler(_4, _3, _2)
);
}
};
int main() {
try {
typedef char char_type;
typedef boost::spirit::classic::file_iterator<char_type> iterator_type;
iterator_type first("Test.txt");
if (!first) throw(runtime_error("Failed to open file!"));
iterator_type last = first.make_end();
typedef boost::spirit::classic::position_iterator2<iterator_type> pos_iterator_type;
typedef tileData<pos_iterator_type> tileData;
pos_iterator_type pos_first(first, last, "Test.txt");
pos_iterator_type pos_last;
tileData tileData_parser;
vector<TileCase> cases;
if (phrase_parse(pos_first, pos_last, tileData_parser, comment, cases) && pos_first == pos_last) {
}
}
catch (const exception& e) {
cerr << "Exception while reading file:\n" << e.what() << endl;
return 1;
}
return 0;
}
, (-g). , , . , Spirit (, ), . , , , .
, Code:: Blocks, cc1plus . , , - -g. , MinGW, , . ?