//strings
"\"hello\"",
" \" hello \" ",
" \" hello \"\"stranger\"\" \" ",
//ints
"1",
"23",
"456",
//floats
"3.3",
"34.35"
在线尝试:http://coliru.stacked-crooked.com/a/26fbd691876d9a8f
使用中
qi::rule<std::string::const_iterator, std::string()>
double_quoted_string = '"' >> *("\"\"" >> qi::attr('"') | ~qi::char_('"')) >> '"';
qi::rule<std::string::const_iterator, std::string()>
number = (+qi::ascii::digit >> *(qi::char_('.') >> +qi::ascii::digit));
qi::rule<std::string::const_iterator, std::string()>
immediate = double_quoted_string | number;
给我正确的结果-但我需要使用double_解析,因为我想支持语义符号,NaN等。
但使用
qi::rule<std::string::const_iterator, std::string()>
immediate = double_quoted_string | qi::uint_ | qi::double_;
打印整数值
"1" OK: ''
----
"23" OK: ''
----
"456" OK: '�'
和双精度数字完全无法解析
在Coliru上测试,Win7x64 VS2017最新,LLVM clang-cl
有时Colliru发出过多的警告,并且编译被暂停
知道在这里发生什么吗?
精神上的警告通常意味着-停在这里,有严重损坏的地方吗?
UPDATE
:如果在测试之前仅使用double_
,并且在使用/不使用uint_
解析器的情况下发生了更改,也会发生这种情况尝试:https://wandbox.org/permlink/UqgItWkfC2I8tkNF我尝试获取字符串,整数和浮点数的即时规则,以便我可以解析以下测试//字符串“ \” hello \“”,“ \” hello \“”,“ \” hello \“ \” stranger \“ \” \“”,// ints“ 1”,“ 23”,“ ...qi::raw
,以便按词法转换数字:qi::raw[qi::uint_]
和qi::raw[qi::double_]
。