Equation (expression) parser with precedence?

前端 未结 23 1791
遇见更好的自我
遇见更好的自我 2020-11-22 11:44

I\'ve developed an equation parser using a simple stack algorithm that will handle binary (+, -, |, &, *, /, etc) operators, unary (!) operators, and parenthesis.

<
23条回答
  •  遥遥无期
    2020-11-22 12:17

    http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm

    Very good explanation of different approaches:

    • Recursive-descent recognition
    • The shunting yard algorithm
    • The classic solution
    • Precedence climbing

    Written in simple language and pseudo-code.

    I like 'precedence climbing' one.

提交回复
热议问题