Stages of compilation Flashcards

1
Q

Lexical Analysis

A

In the first stage of compilation, ​whitespace and comments are removed​ from the code.

The remaining code is analysed for keywords and names of variables and constants. These are ​replaced with tokens​ and information about the token associated with each keyword or identifier is stored in a ​symbol table​.

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

Syntax Analysis

A

In this stage, ​tokens are analysed against the grammar
and rules of the programming language​. Any tokens that break the rules of the programming language are ​flagged up as syntax errors​ and added to a list of errors.

eg : undeclared variable type, incomplete set of brackets.

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

Code Generation

A

The abstract syntax tree produced in the syntax analysis stage is used to produce machine code.

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

Optimisation

A

searches through the code for areas it could be made more
efficient. The aim of optimisation is to​ make the code faster to execute​ although this stage can significantly ​add to the overall time taken for compilation​.

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