1
我有以下代碼(floatDecs和intDecs是符號解析器):空間跳躍不工作的精神,氣
// Definition of the value parser:
typedef boost::variant<double,int64_t> value_type;
typedef boost::fusion::vector<std::string, value_type> dec_type;
rule<std::string::const_iterator, boost::variant<double,int64_t>(std::string)> value;
value = real_parser<double, strict_real_policies<double>>() [ boost::phoenix::bind(boost::lambda::unlambda(floatDecs.add), _r1, _1) ] |
int_parser<int64_t, 10>() [ boost::phoenix::bind(boost::lambda::unlambda(intDecs.add), _r1, _1) ];
rule<std::string::const_iterator, std::string()> ident;
ident %= lexeme[ alpha >> *alnum ];
rule<std::string::const_iterator, dec_type(), boost::spirit::qi::locals<std::string>, space_type> dec;
ident %= ident [_a = _1] >> lit('=') >> value(_a);
boost::spirit::qi::phrase_parse(testing.cbegin(), testing.cend(), dec, space);
的問題:它僅適用,當我在每個規則中刪除空間類型和更換最後一行
boost::spirit::qi::parse(testing.cbegin(), testing.cend(), dec);
你試圖解析什麼輸入?如果「不起作用」是什麼意思?出於好奇, – sehe
,答案如何幫助?我想知道。此外,它可能會幫助您在將來寫出更好的問題。謝謝 – sehe
我只是把兩個資源(他的和我的)都拿來比較,看看我做錯了什麼,因爲他的代碼正在工作。他幫我看看,我的代碼有什麼問題,所以我將他的答案標記爲有用。 – user1861174