Stages of Compilation Flashcards

(6 cards)

1
Q

What is compilation?

A

process that translates a program written in a high level language into machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the four stages in compilation?

A

Lexical Analysis

Syntax Analysis

Code Generation

Optimisation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens in Lexical analysis

A

This stage involves identifying lexical ‘tokens’ in the code such as while, if etc.
White space and comments are ignored completely

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens in code generation?

A

Takes the Abstract syntax tree and traverses it to generate object code that can be executed by the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens in syntax analysis?

A

Makes sure all tokens follow the syntax rules of the language.
Flag up any errors.
If the code passes the syntax analysis then the compiler creates an Abstract Syntax Tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens in optimisation?

A

modifies the code to make it more efficient without changing its functionality.
it reduces the memory required to run the code, which leads to faster execution.
for example removing duplicate code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly