How can I use the skipper ascii::space WITHOUT skipping eol?(如何在不跳过 eol 的情况下使用船长 ascii::space?)
问题描述
我必须使用 boost::spirit 进行解析,我想使用phrase_parse 函数:
I have to use boost::spirit for parsing, and I want use phrase_parse function :
但是我的编译器不允许第四项(ascii::space - qi::eol).如何在不跳过 eol 的情况下使用船长 ascii::space ?
But the fourth term (ascii::space - qi::eol), isnt allowed by my compiler. How can I use the skipper ascii::space WITHOUT skipping eol ?
推荐答案
最简单的答案是
当然,这也取决于你的语法:如果它需要一个特定的船长类,你可能需要改变它.请参阅下面的通用处理方式(尽管您可以只为只接受 的语法指定
).qi::blank_type
qi::blank
Of course, it depends on your grammar too: if it expects a specific skipper class you might need to change that. See below for a generic way to handle that (although you could just specify qi::blank_type
for a Grammar that should only accept qi::blank
).
该示例也处理任意跳过程序.
The sample handles arbitrary skippers too.
Spirit 有几个指令会影响船长的使用:
Spirit has several directives that influence the use of skippers:
qi::lexeme
将解析子表达式而不考虑船长(对于例如语法中的字符串文字很有用)
will parse the sub-expression regardless of skipper (useful for e.g. string literals in a grammar)
qi::raw
将返回原始源迭代器范围,这意味着跳过的输入将包含在结果中
will return the raw source iterator range, meaning that skipped input will be included in the result
qi::no_skip
, qi::skip
可用于显式更改用于子表达式的船长类型
can be used to explicitely change the type of skipper used for the subexpression
Boost Spirit 网站上有一篇关于此类内容的好文章
The Boost Spirit site has a nice article about things like this
- 解析船长和跳过解析器
这篇关于如何在不跳过 eol 的情况下使用船长 ascii::space?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!