boost-spirit

    2熱度

    1回答

    假設我們想要解析像這樣的遞歸塊。當「skip_comments_tag」以塊爲前綴時,我們會以遞歸方式跳過此塊中的所有註釋(/*...*/)。 { {} { skip_comments_tag{ {} /*comments*/ { /*comments*/ } } } } 很容易想出一個遞歸解析器,如Colir

    -1熱度

    1回答

    當文件在剩餘期望值的規則中間結束時,它不會觸發期望錯誤(當然,它確實無法解析)。 觸發該行爲的一個簡單的例子是這樣的: data_var_decls_r %= (lit("data") > lit('{')) > lit('}'); 如果輸入的是唯一 data { 然後最終的期望誤差預期}不會被觸發。 有沒有辦法處理超過文件末尾的期望錯誤?

    1熱度

    1回答

    我正在使用Spirit解析器來解析像id 1234這樣的字符串。它適用於內聯start = qi::lit("id") >> qi::int_;,但如果我想將它放入單獨的基於qi :: grammar的結構體中,則不是。見情況1,2和3在下面的例子: #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/pho

    2熱度

    1回答

    我基於我的應用程序關閉這個例子,並得到完全相同的結果。出於某種原因,輸入字符串的內容全部被解析爲融合結構'comments',並且沒有任何東西被解析爲融合結構'numbers'。所以不知道我在哪裏錯了。 namespace client { namespace ast { struct number { int num1; int num2;

    2熱度

    1回答

    從升壓精神X3教程: 首先,讓我們創建一個代表僱員一個結構: namespace client { namespace ast { struct employee { int age; std::string surname; std::string forename; double salary; }; }}

    2熱度

    2回答

    我可以從存儲在的std :: string,性病::向量或std ::字符數組解析數字。 但是,當字符在std :: unique_ptr中的緩衝區中時,我無法這樣做。 我可以在緩衝區拷貝到一個字符串,則提振精神,但我想避免這種拷貝 這裏是我的嘗試: #include<memory> #include<array> #include<iostream> #include "boost/spi

    1熱度

    1回答

    我想用Boost.Spirit來解析嵌套列表的數字。這是我到目前爲止有: //define a test string std::string string = "[[\t1 , 2 ], [3, 4, 65.4]]"; auto it = string.begin(); //parse the string std::vector<std::vector<double>> vector

    2熱度

    1回答

    我正在考慮自永遠以來(自從Uni上的編譯器類以來,我主要已經忘記了)編寫基本上我的第一個解析器。 由於我使用C++,我正在考慮使用Boost Spirit。然後我注意到有「常規」2.5.2,並且有一些名爲Spirit X3的代碼有一些神奇的子集。 我也注意到Boost Spirit X3在兩年前已經發布/討論/預發佈,但Boost Spirit的正式版本是2.5.2。最後,我讀: Where is

    1熱度

    1回答

    我試圖使用Boost 1.65.1中的Spirit X3來創建解析器。我減少了我的問題,下面的小例子用更簡單的結構: #include <boost/config/warning_disable.hpp> #include <boost/spirit/home/x3.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include

    2熱度

    2回答

    我最終得到了這些移動錯誤很多,我不太清楚爲什麼除了解析字符串的方式之外。刪除與「虛擬」相關的所有內容,並返回錯誤。 有人提到使用attr_gen(在文檔中找不到),通過這樣做,我可以通過這些「traits :: move_to」編譯錯誤,但解析器仍然失敗。我已經標記了我爲了編譯而添加的行,但不要認爲「< ---」是必要的。 #define BOOST_SPIRIT_X3_DEBUG #incl