implemented error raising for parseSum and parseProduct