- Create a symbol table. The symbol table will contain details of each symbol used in the program. A symbol might be a function name, a variable name, etc. The Symbol table will be used by the later stages of the compiler. It will contain the symbol name plus information about the item, e.g. an Integer, a procedure.

- It keeps track of line numbers.

- It produces an output listing.

- Each Reserved word, operator, etc. will be converted into a token to be passed to syntax analyser.

5 of 10

Syntax Analysis

The syntax analyser attempts to make sense of the program. There are two parts to this process:

- syntax analysis

- semantic analysis

Syntax analysis discovers whether the program consists of valid statements defined by the grammatical rules of the language, e.g. does a statment start with a semi-colon.

It is possible to have a statement that is synatically correct but has no meaning. Semantic analysis checks that the statements have some correct meaning.

6 of 10

Code Generation

After Syntax analysis the last stage is to generate the code.

It may include an optimiser that takes the code and modifies it so that it executes more quickly and/or uses less memory.

It is also possible to generate machine code that will execute on a different type of customer. This is known as CROSS-COMPLILATION.

7 of 10

Interpreter

An interpreter executes each line of code as it comes to it in the source program. Inorder to do this it has the following parts:

- Lexical Analysis

- Syntax Analysis

- Execution

The lexical analysis and the syntax analysis phases are similar to the compilier but the interupter does not generate any code.

8 of 10

Advantages of a Compiler

- A compiled program will always execute more quickly than one that is interpreted, as the interpeter has to understand every statement as it comes to it.

- The target program (called the object program) can be stored on disk and re-executed without being recompiled.

- Programs can be distributed in machine code form. This stops the user from modifying the program as they do not have access to the source code.

9 of 10

Advantages of an Interpreter

- Interpreters are useful for program development when execution speed is not important. As the interpreter is in command of the execution process debugging features can be built in.