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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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
- Program construction: the features of an integrated development environment (IDE), modular and structured program design, the use of libraries, and writing maintainable code with sensible naming, comments and indentation.
An Eduqas Component 1 answer on program construction: the features of an integrated development environment (editor, debugger, error diagnostics), modular and structured design, using libraries, and the conventions that make code readable and maintainable.
- Programming principles: primitive and composite data types, variables and constants, scope and lifetime, and the three programming constructs of sequence, selection and iteration used to build structured programs.
An Eduqas Component 1 answer on programming principles: the primitive data types, variables versus constants, local versus global scope and lifetime, type conversion, and the three programming constructs sequence, selection and iteration.
- Assembly language: the instruction set with its opcode and operand, common operations (load, store, add, jump, compare), the relationship between assembly and machine code, and immediate, direct and indirect addressing modes.
An Eduqas Component 2 answer on assembly language: the opcode and operand structure of an instruction, common operations such as load, store, add, jump and compare, how assembly maps to machine code via the assembler, and immediate, direct and indirect addressing modes.
- Software applications: the distinction between system software and application software, generic, special-purpose and bespoke applications, the role of utility programs (compression, defragmentation, backup, antivirus), and how software is licensed.
An Eduqas Component 2 answer on software applications: the distinction between system and application software, generic, special-purpose and bespoke applications, the role of utility programs such as compression, defragmentation, backup and antivirus, and software licensing models.
- Testing and correctness: the types of program error (syntax, runtime and logic), test strategies and test data (normal, boundary and erroneous), trace tables and dry runs, and validation and verification of input data.
An Eduqas Component 1 answer on testing and correctness: syntax, runtime and logic errors, choosing normal, boundary and erroneous test data, dry runs with trace tables, and the difference between validation and verification of input.
Sources & how we know this
- WJEC Eduqas GCE AS/A Level Computer Science specification (from 2015) — Eduqas (2015)