raise an error if a closing parenthesis or bracket is missing