用提升气解析包含文字的字符串

Parse string containing literal with Boost Spirit Qi

本文关键字:包含 文字 字符串      更新时间:2023-10-16

我很想解析这样的字符串:

<stuff I don't care> <literal value> <more stuff I don't care>

用CCD_ 1。假设<literal value>是例如ABC,那么我希望解析器接受:

Some text ABC more text

但拒绝:

Some text ACB more text

不幸的是,

*char_ >> lit("ABC") >> *char_

由于戚的贪婪而无法工作。有没有一种简单的方法来编写这个解析器?

使用

*(char_ - lit("ABC")) >> lit("ABC") >> *char_;

以防止CCD_ 4消耗CCD_。