分流场VS递归下降解析器 [英] Shunting-Yard VS Recursive Descent Parser
问题描述
我正在构建一个高级数学解析器,并且想知道Shunting-Yard与其他可用的解析器算法(例如下降解析器")之间的区别,因为我希望将公式存储为RPN表示法.
I am building an advanced mathematical parser and would like to know the difference between Shunting-Yard and the other available parser algorithms like "Descent Parser" knowing that I prefer to store the formula in RPN notation.
预先感谢
推荐答案
"shunting yard"算法从未使用过很多,因为它似乎只针对中缀表达式.递归下降解析很容易完成表达式以及使用更复杂的解析器进行的大多数操作.更一般地说,我发现它更有用,并且不需要记住两种技术.
I've never had much use for the "shunting yard" algorithm because it seems focused on just infix expressions. Recursive descent parsing easily does expressions and most of what you want to do with more complex parsers. Being more general, I find it more useful, and don't need to remember two techniques.
See my SO answer on how to build recursive descent parsers here: Is there an alternative for flex/bison that is usable on 8-bit embedded systems?
这篇关于分流场VS递归下降解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!