Math expression parser for exercise