Parser for calculator with operator precedence