2011-07-31 46 views
0

我認爲boost提示令牌ID中存在一個錯誤。但我不確定。 升壓令牌迭代器是無法檢測的T_CONTLINE令牌是「\ \」,然後「\ n」見:http://www.boost.org/doc/libs/1_46_1/libs/wave/doc/token_ids.htmlboost T_CONTLINE令牌不起作用

對於樣品測試中,我有一個測試文件: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

編輯: 其實有類似的bug報告張貼在這裏:

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

的修改記錄:http://www.boost.org/doc/libs/1_47_0/libs/wave/ChangeLog

這個bug被報告用最新的boost 1.47.0來解決所以我安裝了最新的boost 1.47.0,但仍然存在問題rema插件。

+0

我懷疑是否有錯誤。 – 2011-07-31 21:02:22

回答

1

是的,這個標記沒有暴露在迭代器級別上,它只是在處理的早期內部處理。這不是一個錯誤,而是預期的行爲。我將在文檔中添加一個註釋。

+0

謝謝...但我需要確定T_CONTLINE。我該怎麼做呢。問題是,當我將令牌讀入到一個stringstream中,然後將它們重寫入另一個文件時,所有的T_CONTLINE都會丟失並被空間替換。由此導致宏的格式受到嚴重影響。 –

+0

我向Wave添加了一個新標誌:support_option_emit_contnewlines,它允許庫發出T_CONTLINE標記。唯一需要注意的是,目前僅支持SLex自定義詞法分析器模塊。你現在需要使用它。 – hkaiser

+0

謝謝我看到了更新。因爲我現在在使用boost_wave,所以我認爲切換到SLex需要一些時間。是否有機會更新boost_wave的詞法分析器。 –

相關問題