Subj : Re: Compiler and an interpreter To : comp.programming From : spinoza1111 Date : Sat Jul 30 2005 06:18 am 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. Depends on the type of interpreter. If it is a "p-code" interpreter which compiles the raw source to instructions for a paper machine which are then interpreted then it will probably find all errors, except any erors masked by the error on the fourth line. If the interpreter is a pure (*reinen*) interpreter which interprets either raw source code, or else "cooked" source code which has been converted to fixed length tokens, then for "efficiency" or because its coders were bone lazy, the interpreter may stop at the first error. But if the interpreter is of the second type there is no reason why, it could not cease interpreting but continue parsing and finding further errors. "Compiler" and "interpreter" are fuzzy names which encompass a range of practise. Basically, if the "compiler" creates native code for a real machine, it is really a compiler. If the "compiler" creates bytecode for Java or CLR for .Net, it is a compiler. But if one's compiler creates p-code which is then interpreted, it approaches a boundary, it isn't a REAL compiler just yet. It compiles but it isn't quite a studly Compiler. An interpreter interprets one clause at a time on the analogy of a human iinterpreter who waits for his client to say something. But if this is our metaphor, the human interpreter doesn't stop interpreting merely because her client lays an egg. > > Thanks .