I need to implement a simple formula parser. What I am doing is first create a postfix notation and then evaluating the postfix string. Unfortunately, this algorithm doesn’t allow brackets i.e. (2+3)*a. Anyone knows how to extend the algorithm to allow brackets?
Thanks in advance,
Frank
The whole point of postfix notation is to eliminate the brackets in infix notation so that you can evaluate the expression more easily. If your current algorithm doesn’t allow brackets in the infix expression, then you’re using a bad algorithm.
The shunting yard algorithm will allow you to convert from infix to postfix even if the infix version has brackets.