AXE Parser Generator and mingw gcc 4.6 operator &

孤者浪人 提交于 2019-12-11 15:32:57

问题


I'm playing a bit with axe parser framework from gb reasearch and got problems with gcc 4.6.2. With VC++10-Compiler there are no problems.

The line:

auto space = axe::r_any(" \t");

// trailing spaces
auto trailing_spaces = *space & (comma | endl);

The error:

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

I'm playing with the CSV-Example from the PDF. Here's the code i used:

#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());
}

Cann anyone help me with this error? Can't gcc 4.6 handle the auto-type? I get the same error with the | (or-operator). What to do?

Thank you very much!!!


回答1:


This is a bug in gcc versions 4.6.x, it was fixed in version 4.7.0. If you can't upgrade compiler then use axe::r_rule<Iterator> instead of auto.



来源:https://stackoverflow.com/questions/9467710/axe-parser-generator-and-mingw-gcc-4-6-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!