I'm writing a calculator, and to start, I'm writing basic arithmetic functionality. I've figured out how to tackle the "EMDAS" portion of the Order of Ops, however, I don't have a clue on how to simplify parentheses. The code I've written doesn't work in that regard, though everything else so far works great. How would you guys do the parentheses?
pseudo-code which needs revising/reworking (I've written actual code, but it's fairly confusing...) solveParentheses(String equation): loop until no more parentheses: find first parenthesis store its location in a variable find close parenthesis store its location in a variable If found one but not the other, give error message save the content of the parentheses into an array that array = solveParentheses(that array) simplify order of ops inside parentheses set the location of end parenthesis to result of simplification set indices between the first parenthesis and result to "null" :end loop count number of null values new array of length equation.length-nullcounter fill array with non-null values return array :end function