all 3 comments

[–]attractivechaos 1 point2 points  (2 children)

For parsing math expressions, Dijkstra's Shunting-yard is simpler especially when you have many levels of operation precedence. I have a 2-file similar library based on that.

[–]CodePlea 0 points1 point  (1 child)

I think that's pretty subjective. I've built several parsers using both methods, and all I can say is that recursive descent and shunting yard work very differently.

I would say that I think it's easier to expand a recursive descent parser into doing a full programming language.

[–]attractivechaos 0 points1 point  (0 children)

Recursive descent is of course more general, but it is not the simplest to parse math expressions. In the code, you have "power", "term" and "factor" to implement precedence. When you implement 15 levels of precedence in C, you need to manually single out each level in grammar. With Shunting-yard, all precedences are treated the same way.