【发布时间】:2013-12-29 18:01:44
【问题描述】:
考虑以下解析器:
#include <assert.h>
#include <iostream>
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
struct command_toten_parser : qi::grammar<const char *, std::string()> {
command_toten_parser() : command_toten_parser::base_type(r) {
r = *qi::blank >> *qi::graph >> *qi::blank;
}
qi::rule<const char *, std::string()> r;
};
int main(int argc, char *argv[]) {
command_toten_parser p;
std::string c, s(" asdf a1 a2 ");
const char *b = &*s.begin();
const char *e = &*s.end();
assert(qi::parse(b, e, p, c));
std::string rest(b, e);
assert(c == std::string("asdf"));
assert(rest == std::string("a1 a2 "));
return 0;
}
如何更改我的解析器,使*qi::blank 匹配的部分未被捕获(并且我的断言通过)
【问题讨论】:
标签: c++ boost-spirit boost-spirit-qi