gpt4 book ai didi

c++ - boost T_CONTLINE token 不起作用

转载 作者:行者123 更新时间:2023-11-28 08:18:18 25 4
gpt4 key购买 nike

我认为 boost token ID 中存在错误。但我不确定。boost token 迭代器无法检测到 T_CONTLINE token ,即“\\”后跟“\n”,请参阅:http://www.boost.org/doc/libs/1_46_1/libs/wave/doc/token_ids.html

为了示例测试,我有一个测试文件:testfile.h

  1 #define Funtion(x) X + \
2 Y
3
4 #define MYVAR 100+\
5 200

这是寻找 T_CONTLINE 的程序

  1 #include <iostream>
2 #include <fstream>
3
4 #include <boost/wave/cpplexer/cpp_lex_token.hpp>
5 #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
6
7 typedef boost::wave::cpplexer::lex_token<> token_type;
8 typedef boost::wave::cpplexer::lex_iterator<token_type> token_iterator;
9 typedef token_type::position_type position_type;
10
11 int main()
12 {
13 const char* infile = "testfile.h";
14 std::string instr;
15 std::ifstream gmstream(infile);
16 if(!gmstream.is_open()) {
17 std::cerr << "Could not open file: "<< infile<<"\n";
18 }
19 gmstream.unsetf(std::ios::skipws);
20 instr = std::string(std::istreambuf_iterator<char>(gmstream.rdbuf()),
21 std::istreambuf_iterator<char>());
22
23 position_type pos(infile);
24 token_iterator it = token_iterator(instr.begin(), instr.end(), pos,
25 boost::wave::language_support(
26 boost::wave::support_cpp|boost::wave::support_option_long_long));
27 token_iterator end = token_iterator();
28
29 boost::wave::token_id id = *it;
30
31 while(it!=end) {
32 if(id == boost::wave::T_CONTLINE) {
33 std::cout<<"Found Contline";
34 }
35 ++it;
36 id = *it;
37 }
38 return 0;
39 }

但是我没有得到任何输出。

我正在使用 boost_1_47_1 和 gcc-4.5

编辑:实际上这里有一个类似的错误报告:

https://svn.boost.org/trac/boost/ticket/5569

查看更新日志:http://www.boost.org/doc/libs/1_47_0/libs/wave/ChangeLog

据报道,此错误已通过最新的 boost 1.47.0 解决,所以我安装了最新的 boost 1.47.0,但问题仍然存在。

最佳答案

是的,这个 token 并没有暴露在迭代器级别,它只是在处理的很早的时候在内部处理。这不是错误,而是预期的行为。我将在文档中添加注释。

关于c++ - boost T_CONTLINE token 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6892272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com