Back to marketplace

1.2.2.6 Stages of Compilation

No description yet. This curated deck is ready for daily study.

Total cards: 6•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (6)

#1
Front (Question)

What are the 4 stages of compilation?

Back (Answer)

1) Lexical analysis 2) Syntax analysis 3) Code generation 4) Code optimisation

#2
Front (Question)

What happens in the lexical analysis stage?

Back (Answer)

• The Lexer starts by converting lexemes from the source code into a series of tokens • Scanned spaces, symbols are taken as indicators that word is complete • It then checks if the lexeme is valid using a predefined set of rules that allow every lexeme to be identified as a valid token

#3
Front (Question)

What can be considered a token?

Back (Answer)

Keywords, constants, identifiers, strings, numbers, operators and punctuation symbols

#4
Front (Question)

What happens in the syntax analysis stage?

Back (Answer)

• Receives its inputs in the form of tokens from lexical analysers. • Analyses the syntactical structure of the input, checking if it is in the correct syntax of the programming language it has been written in. • It does this by analysing the token stream against production rules to detect any errors in the code

#5
Front (Question)

What does the syntax analysis accomplish?

Back (Answer)

• Checking for errors and reporting them. • Building an abstract syntax tree (parse tree)

#6
Front (Question)

What does code optimisation do?

Back (Answer)

• Spotting redundant instructions and producing object code that achieves the same effect as the source program but not necessarily by the same means. • Removing subroutines that are never called. • Removing variables and constants that are never referenced.