【发布时间】:2012-01-27 10:44:26
【问题描述】:
是否有可能以某种方式将“通用”错误处理(如教程中给出的)与 Nabialek 技巧结合起来?像这样:
...
on_error<fail>
(
start
, std::cout
<< val("Error! Expecting ")
<< _4 // what failed?
<< val(" here: \"")
<< construct<std::string>(_3, _2) // iterators to error-pos, end
<< val("\"")
<< std::endl
);
start = *(keyword[_a = _1] > lazy(*_a));
some_other_rule.name("other rule's name");
...
现在,当 some_other_rule 被延迟调用并失败时,错误消息显示 "lazy" 是预期的,而不是 "other rule's name"(我需要)。它应该以这种方式工作,而我只是在其他地方弄错了,还是涉及其他一些特定的技巧?
【问题讨论】:
标签: c++ error-handling boost-spirit boost-spirit-qi