Fixes precedence issue. Uses while instead of for loop in shuntingYard()