Я немного играю со структурой синтаксического анализатора от gb reasearch и получил проблемы с gcc 4.6.2. С VC ++ 10-Compiler проблем нет.
Линия:
auto space = axe::r_any(" \t");
// trailing spaces
auto trailing_spaces = *space & (comma | endl);
Ошибка:
D:\Projekte\axeparser-build-desktop-Qt_4_8_0__Qt480mingw__Debug\..\axeparser\main.cpp:19: error: conversion from 'axe::r_and_t<axe::r_many_t<axe::r_pred_t<axe::is_any_t<const char*> >&, axe::r_empty_t>, axe::r_or_t<axe::r_char_t<char>&, axe::r_char_t<char>&> >' to non-scalar type 'axe::r_and_t<axe::r_many_t<axe::r_pred_t<axe::is_any_t<const char*> >&, axe::r_empty_t>&, axe::r_or_t<axe::r_char_t<char>&, axe::r_char_t<char>&>&>' requested
Я играю с CSV-примером из PDF. Вот код, который я использовал:
#include <iostream>
#include <axe.h>
#include <iostream>
#include <string.h>
using namespace std;
template<class I>
void csv(I begin, I end)
{
// define comma rule
auto comma = axe::r_lit(',');
// endl matches end of line symbol
auto endl = axe::r_lit('\n');
// space matches ' ' or '\t'
auto space = axe::r_any(" \t");
// trailing spaces
auto trailing_spaces = *space & (comma | endl);
std::string value;
// create extractor to print matched value
auto print_value = axe::e_ref([&value](I, I)
{
std::cout << "<" << value << ">";
});
// rule for comma separated value
auto csv_str = *space & +(axe::r_printable() - trailing_spaces)
>> value & *space;
// rule for single string of comma separated values
auto line = *((csv_str & comma) >> print_value)
& csv_str >> print_value
& endl >> axe::e_ref([](I, I)
{
std::cout << "\n";
});
// file contaning many csv lines
auto csv_file = +line | axe::r_fail([](I i1, I i2) {
std::cout << "\nFailed: " << std::string(i1, i2);
});
csv_file(begin, end);
}
int main()
{
auto space = axe::r_lit(' ');
auto spaces = space & space & space;
std::string moin = "232323233";
csv(moin.begin(), moin.end());
}
Может кто-нибудь помочь мне с этой ошибкой? Gcc 4.6 не может обработать автоматический тип? Я получаю ту же ошибку с | (Или-оператор). Что делать?
Большое спасибо !!!