Implement a function to parse and evaluate nested mathematical operations for a calculator application.