What is the purpose of a compiler? Give an example of their use.
What is the purpose of an interpreter? Give an example of their use.
What is the purpose of an assembler? Give an example of their use.
Explain the principal stages involved in the compilation process:-
lexical analysis
symbol table construction
syntax analysis
semantic analysis
code generation
optimisation
Describe and give examples of programming errors
Explains why they are needed
Explains how the code you write is executed by a machine
Compilers are required to convert high level code into executable/machine code.
It will translate the whole program in one go.
It produces an executable file which will run without the compiler installation being needed.
They are large complex programs. The have to be re-compiled after a change.
Use - They are used to convert one programming language to another.
An interpreter translates each line of code at run time i.e. every time the code is executed.
As it interpreters each line of code, it is slower than a complier as it would translate the same statements over and over.
At runtime the interpreter will be required.
They are smaller simpler programs. They can be amended and run without translating the whole program.
They are easier to use as errors are reported and corrected as execuation continues.
An assembler translates low level (assembly language) code into machine code.
A video to show the various stages of comilation and symbol table construction
Revise - Stages of compilation
When programming I am sure you have not done everything the first time. Where have you had the following errors:-
syntax - mistake in rule of language e.g. spelling, IF but no THEN
run time - stops the execution of code e.g. trying to divide by zero
logical - mistake in program e.g. A + B rather than A * B
WJEC Blending Resources - These are interactive resources that will help with your knowledge and understanding. You could use these as revision for the topic