Reduce the number of duplicate errors

(errors that describe the same situation even though the message
and error source might be different, e.g. out of input errors).
Handle lexical errors in the parsing phase in a more consistent way.