使用qi :: double_和qi :: uint_]的组合即时=字符串| float | int规则时,std :: cout输出断开,

问题描述 投票:1回答:2
我尝试获取字符串,整数和浮点数的即时规则,以便我可以解析以下测试]

//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”,“ ...
boost-spirit boost-spirit-qi
2个回答
1
投票
在整数和双浮点解析器上使用qi::raw,以便按词法转换数字:qi::raw[qi::uint_]qi::raw[qi::double_]

0
投票
“解析”的宽松定义是将文本表示形式转换为“另一个”(通常是更多的[[native
© www.soinside.com 2019 - 2024. All rights reserved.