Skip to main content
EnglandComputer ScienceSyllabus dot point

How is source code turned into something the processor can run, and what does a compiler do at each stage?

Program construction and translators: compilers, interpreters and assemblers and their differences, the distinction between source, object and executable code, and the stages of compilation (lexical analysis, syntax analysis, semantic analysis, code generation and optimisation).

An Eduqas Component 1 answer on translators: how compilers, interpreters and assemblers differ, the distinction between source, object and executable code, and the stages of compilation from lexical analysis through syntax and semantic analysis to code generation and optimisation.

Generated by Claude Opus 4.813 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

Eduqas wants you to distinguish compilers, interpreters and assemblers, explain the difference between source, object and executable code, and describe the stages of compilation: lexical analysis, syntax analysis, semantic analysis, code generation and optimisation.

The answer

Compilers, interpreters and assemblers

Source, object and executable code

The stages of compilation

Examples in context

C and C++ are typically compiled for speed and shipped as executables; scripting languages like Python are run through an interpreter for quick iteration (and actually compile to bytecode first). The assembler is what turns the assembly answers in Component 2 into runnable machine code. Understanding the compilation stages explains real error messages: a "syntax error" comes from the parser, a "type error" from semantic analysis, and it underpins the IDE features (covered next) that highlight these errors as you type.

Try this

Q1. State one advantage of a compiler over an interpreter. [1 mark]

  • Cue. The compiled executable runs faster (translation happens once) and can be distributed without the source code.

Q2. What is produced during lexical analysis? [1 mark]

  • Cue. A stream of tokens (and entries in the symbol table).

Q3. Distinguish source code from object code. [2 marks]

  • Cue. Source code is the human-readable high-level program; object code is the machine-code translation produced by the compiler.

Exam-style practice questions

Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Eduqas 20195 marksCompare a compiler with an interpreter, covering how each translates the source code, the speed of the resulting program, and the ease of finding errors.
Show worked answer →

Translation (up to 2 marks): a compiler translates the whole source program into machine code in one go, producing an executable that runs without the source; an interpreter translates and executes the source one statement at a time, with no separate executable produced.

Speed (up to 1 mark): compiled programs run faster because translation happens once before execution; interpreted programs run slower because each statement is translated every time it runs.

Finding errors (up to 2 marks): an interpreter is better for development and debugging because it stops at the first error and reports it immediately; a compiler reports all errors after attempting to compile the whole program, but the resulting code is faster to distribute.

Markers reward the whole-program versus statement-by-statement distinction, the speed comparison, and the debugging trade-off.

Eduqas 20215 marksDescribe what happens during lexical analysis and syntax analysis, the first two stages of compilation, and state what a symbol table is used for.
Show worked answer →

Lexical analysis (up to 2 marks): the source code is broken into tokens (keywords, identifiers, operators, literals); whitespace and comments are removed, and identifiers and constants are recorded in the symbol table.

Syntax analysis (up to 2 marks): the tokens are checked against the grammar rules of the language and arranged into a structure (a parse tree or abstract syntax tree); any rule violations produce syntax errors.

Symbol table (up to 1 mark): a data structure that stores identifiers (variable and subroutine names) along with information such as their type, scope and memory address, used throughout compilation.

Markers reward tokenising for lexical analysis, grammar-checking and tree-building for syntax analysis, and the role of the symbol table in tracking identifiers.

Related dot points

Sources & how we know this