Source code can contain syntax errors.
Describe how a compiler and an interpreter differ in the way they deal with syntax errors.
Mark scheme
Award up to two marks for a linked description such as:
- The compiler reports all syntax errors after translation has finished (1) whereas the interpreter stops at the first error it finds (1)
- The interpreter reports a syntax error as soon as it finds one (1) and does not translate/execute any more of the program (1)
- The compiler continues translating after an error (1) and reports the errors at the end (1)
- The interpreter stops translating when it reaches an error (1) but the compiler finishes translating before reporting errors (1)
Do not accept answers about fixing/correcting errors or about object code.
Do not award 'the compiler finds more errors' without saying errors are reported at the end.
Example answers and how they were marked
A compiler reports all the syntax errors at the end of translation, whereas an interpreter stops and reports the error as soon as it finds one.
Why: Compiler reports errors at the end (1) and interpreter stops/reports at the first error (1).
An interpreter stops translating when it finds a syntax error.
Why: Interpreter stops at the first error (1); no comparison with when the compiler reports errors.
A compiler reports a syntax error immediately, before translating the rest of the program.
Why: Reverses the compiler's behaviour; it finishes translating before reporting errors.