Stages of Compilation (OCR A-Level Computer Science): Flashcards
📚Flashcards
Practise the cards
12 cards from this deck
ShowHide
Practise the cards
12 cards from this deck
Compilation definition
Compilation definition
Converting high-level code to machine code that a processor can execute
Four main stages of compilation
Four main stages of compilation
Lexical Analysis, Syntax Analysis, Code Generation, Optimisation
Purpose of lexical analysis
Purpose of lexical analysis
Break code into tokens & remove unnecessary elements
Tokenisation
Tokenisation
Dividing code into atomic units like keywords & identifiers
What lexical analysis removes
What lexical analysis removes
Whitespace and comments
Symbol table
Symbol table
Stores identifiers (variables, functions) during lexical analysis
Purpose of syntax analysis
Purpose of syntax analysis
Check tokens follow correct language syntax rules
AST (Abstract Syntax Tree)
AST (Abstract Syntax Tree)
Tree structure representing hierarchical relationships of code elements
Purpose of code generation
Purpose of code generation
Convert AST into machine code/object code
Purpose of optimisation
Purpose of optimisation
Refine object code for execution efficiency & memory use
What optimisation removes
What optimisation removes
Redundant code, repeated calculations, excess memory access
Impact of comments on compilation
Impact of comments on compilation
None - removed during lexical analysis
