AX Parser Generator和mingw gcc 4.6 operator&

时间:2012-02-27 15:36:36

标签: c++ parsing gcc c++11 parser-generator

我正在使用gb reasearch中的ax解析器框架,并且遇到了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

我正在使用PDF中的CSV-Example。这是我使用的代码:

#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无法处理自动类型?我得到了与|相同的错误(或运营商)。怎么办?

非常感谢!!!

1 个答案:

答案 0 :(得分:1)

这是gcc版本4.6.x中的一个错误,它已在4.7.0版本中修复。如果您无法升级编译器,请使用axe::r_rule<Iterator>代替auto