A-level Computer Science revision · Processors, software and development

Translators and compilation

The idea

Compilers translate the whole source code into machine code before running; interpreters translate and run line by line; assemblers translate assembly language. Compilation stages: lexical analysis (tokens, symbol table), syntax analysis (grammar, parse tree), code generation and optimisation. Linkers combine object code with libraries; loaders place code in memory.

  1. Compiler: whole program, fast executable, errors listed at end.
  2. Interpreter: line by line, easier debugging, slower.
  3. Stages: lexical, syntax, code generation, optimisation.

Watch out Lexical analysis removes whitespace and comments and builds the symbol table; it does not check grammar.

See it worked

Worked example

Which compilation stage checks the program follows the language's rules?

  1. Tokens are checked against the grammar.
  2. A parse tree is built.
  3. Syntax analysis.

Answer Syntax analysis

Your turn

Question 11 mark

Which translator converts assembly language into machine code?

Choose one
Question 21 mark

What does a linker do?

Choose one
Question 32 marks

Give one advantage of an interpreter during development.

Write your answer, then see a model answer
  1. Name the advantage.
  2. Explain it.

Answer Errors are reported as each line runs, so the programmer can find and fix them quickly without recompiling the whole program.

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms