James Kanze
10/19/2008 5:10:00 PM
On Oct 19, 12:26 pm, Erik Wikström <Erik-wikst...@telia.com> wrote:
> On 2008-10-19 12:04, Juha Nieminen wrote:
> > Erik Wikström wrote:
> >> As a rule, you can only trust the first error message a
> >> compiler (any compiler) emits, all after might be the
> >> result of the compiler being thrown of by the first error.
> > Which raises the question: Why do compilers bother with the
> > rest of the errors? Why not just stop with the first error?
Would you use such a compiler?
> Because sometimes they are reliable and fixing more than one
> error between recompiles is nice. After using a compiler for
> some time you can generally tell which errors are due to
> earlier errors and which are genuine errors.
Resynchronizing after an error is one of the most difficult
things in compiler construction; you want to absorb (and throw
out) enough input to avoid follow-up errors, but you don't want
to miss any real errors after the detected error. In this case,
the compiler was obviously not throwing out enough, keeping both
the partially parsed new expression, and the next token. In the
end, the only thing that stopped it was a hard wired maximum
number of errors. (Most compilers do this as well, as a safety
net. After all, what's the use of going on if the actual error
was that you fed an Ada program to the C++ compiler?)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34