具體而言,使用語法g,我該如何解析字符串s?我應該給我什麼論據?我嘗試了很多電話,總是遇到錯誤。如何使用parse/phrase_parse函數
此外,由於我不確定哪一個我稍後會用到,使用phrase_parse
會有什麼區別嗎?
namespace qi = boost::spirit::qi;
int main() {
My_grammar<std::string::const_iterator> g;
std::string s = "a"; // string to parse
if (qi::parse(/*...*/)) {
std::cout << "String parsed !";
} else {
std::cout << "String doesn't parse !";
}
return EXIT_SUCCESS;
}
這給我的幾個錯誤,這成爲第一: 從「布爾的boost ::精神::氣需要: :解析(Iterator&,Iterator,Expr&)[使用Iterator = __gnu_cxx :: __ normal_iterator>; Expr = My_grammar <__ gnu_cxx :: __ normal_iterator >>]' –
LogicalKip
我改變了答案,可能'auto'並不是完全推導出'std :: string :: const_iterator',這是上述工作需要。你也沒有把它標記爲C++ 11,所以我不應該使用'auto':X –