Equation (expression) parser with precedence?

前端 未结 23 1799
遇见更好的自我
遇见更好的自我 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 12:17

    I have posted source for an ultra compact (1 class, < 10 KiB) Java Math Evaluator on my web site. This is a recursive descent parser of the type that caused the cranial explosion for the poster of the accepted answer.

    It supports full precedence, parenthesis, named variables and single-argument functions.

提交回复
热议问题