小编srs*_*srs的帖子

"碳复制"是一个c ++的梦想?

对于我自己的小解析器框架,我试图定义(类似)以下函数:

template <class T>
// with operator>>( std::istream&, T& )
void tryParse( std::istream& is, T& tgt )
{
    is >> tgt /* , *BUT* store every character that is consumed by this operation
    in some string. If afterwards, is.fail() (which should indicate a parsing
    error for now), put all the characters read back into the 'is' stream so that
    we can try a different parser. */
}
Run Code Online (Sandbox Code Playgroud)

然后我可以这样写:(也许不是最好的例子)

/* grammar: MyData     = <IntTriple> | <DoublePair>
            DoublePair = <double> <double>
            IntTriple …
Run Code Online (Sandbox Code Playgroud)

c++ parsing istream

5
推荐指数
1
解决办法
466
查看次数

标签 统计

c++ ×1

istream ×1

parsing ×1