且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

语义动作在boost :: spirit解析中运行多次

更新时间:2023-11-12 21:35:34

即使稍后回溯,也会触发语义动作.

Semantic actions fire even if there's backtracking later.

解析器表达式可能会抛出.

Parser expressions might throw.

仅出于这些原因,在语义动作中进行动态分配并不是一个好主意.如果需要,请使用智能指针(尽管这样做仍然效率低下).

For these reasons alone, it's not a good idea to do dynamic allocations in your semantic actions. If you need to, use smart pointers (though this will still be inefficient).

请参见

  • Boost Spirit: "Semantic actions are evil"?
  • How can I use polymorphic attributes with boost::spirit::qi parsers?