Yea so I curiously studied your source code, It is pretty interesting, and much shorter than I expected May I recommend studying "Reverse polish notation" using the "Shunting yard algorithm" If you study the wikipedia page(s) then you'll be able to build much more complex parsing engines It converts an expression that needs parentheses into one that doesnt (3-5)/(1+2) ↓↓↓↓↓↓ 3 5 - 1 2 + /