AX解析器生成器和mingw gcc 4.6运算符& [英] AXE Parser Generator and mingw gcc 4.6 operator &
问题描述
我从gb reasearch中使用ax解析器框架有点问题,并遇到gcc 4.6.2的问题。使用VC ++ 10-Compiler没有问题。
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.
行:
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示例。这里是我使用的代码:
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());
}
任何人都可以帮我解决这个错误?不能gcc 4.6处理自动类型?我得到与|相同的错误(或运算符)。该怎么办?
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?
非常感谢!
推荐答案
这是在gcc版本4.6.x中的错误,它是在4.7.0版本中修复的。如果不能升级编译器,请使用 ax :: r_rule< Iterator>
而不是 auto
。
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
.
这篇关于AX解析器生成器和mingw gcc 4.6运算符&的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!