Subj : Re: Compiler and an interpreter To : comp.programming From : cri Date : Fri Jul 29 2005 08:59 pm On Fri, 29 Jul 2005 18:15:23 +0100, Jon Harrop wrote: >anjali wrote: > >> Suppose in a source-code file, the 4th line contains the first syntax >> error.Can anybody please tell me how the compiler and interpreter will >> behave when the given file will be the input to them? >> >> My guess is that the compiler will go through the entire file and will >> report all the syntax errors in the file while the interpreter will >> stop its execution exactly after the 4th line and will say that there >> is a syntax error in the 4th line. > >As a syntax error is a parse error, the compiler/interpreter will stop >during parsing and will never actually compiler or interpret any code. This isn't quite true - command line interpreters carry on in the presence of syntax errors. > >Some compilers stop at the first syntax error (e.g. OCaml). Others try to >recover and continue parsing (e.g. MLton). The former makes it more tedious >to correct a source file containing many trivial syntax errors. The latter >will often recover incorrectly and report nonsensical errors in the >remainder of the code. Richard Harter, cri@tiac.net http://home.tiac.net/~cri, http://www.varinoma.com Save the Earth now!! It's the only planet with chocolate. .