首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AXE解析器生成器和明文gcc 4.6算子&

AXE解析器生成器和明文gcc 4.6算子&
EN

Stack Overflow用户
提问于 2012-02-27 23:36:36
回答 1查看 603关注 0票数 0

我在玩gb reasearch的axe解析器框架,但在使用gcc 4.6.2时遇到了问题。使用VC++10-Compiler没有任何问题。

这行代码:

代码语言:javascript
运行
复制
auto space = axe::r_any(" \t");

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

错误:

代码语言:javascript
运行
复制
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示例。下面是我使用的代码:

代码语言:javascript
运行
复制
#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不能处理自动打字吗?我得到了与|(或-操作符)相同的错误。该怎么办呢?

非常感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-19 04:57:48

这是gcc 4.6.x版本中的一个错误,已在4.7.0版本中修复。如果你不能升级编译器,那么就用axe::r_rule<Iterator>代替auto

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9467710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档