1.2.2 Application Generation - Stages of compilation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a lexicon

A

A lexicon is a general term meaning a collection of terms related to a specific subject.

In computer language this is the use of ‘=’, ‘if’ or other command words/keywords. These terms are lexemes.

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

What does the compiler break source code down into?

A

The compiler breaks down the ASCII characters that the source code is made up of into component parts called ‘lexemes’.

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

What is a lexeme?

A

A lexeme is the smallest unit of language, it cannot be broken down further without losing meaning.

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

What are the stages of compilation?

A

Lexical analysis - the splitting down of the ASCII code into lexemes

Draft token table - lexemes are converted into tokens, both these and notes on what each token does is stored in a token table.

Syntax analysis - the checking of whether the tokens make sense in the grammar of the language and if tokens are the expected data type.

Code generation - the conversion of source code via the output of lexical and syntactic analysis into machine code.

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

What are some characters or combinations of characters ignored by lexical analysis?

A

Comments, tabs and whitespace are removed from the source code during lexical analysis.

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

What is a token?

A

A token is a fixed length binary number - lexemes are converted into tokens as the CPU works more efficiently when data chunks are standard sizes.

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

Where are all the tokens created stored?

A

After lexical analysis - the whole source code will have been converted by the compiler into a token table in memory.

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

As the compiler finds lexemes during lexical analysis, what does it do?

A

As the compiler finds lexemes it converts them into tokens and notes what each token does.

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

What do token tables store?

A

Tokens and notes on what each token does alongside them.

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

What is syntactic analysis?

A

Syntactic analysis includes syntax analysis and semantic analysis. This is where the compiler checks that the code makes sense.

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

What is syntax analysis (parsing)?

A

During syntax analysis, the compiler checks that the arrangement of the tokens make sense in the grammar of the language.

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

What is semantic analysis?

A

During semantic analysis, the compiler checks that the tokens are the expected data types.

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

What happens if an error is detected during syntactic analysis (parsing)?

A

During syntactic analysis, if an error is detected it is added to the ‘compiler report’. Once the compiler has finished analysing the code, the complete report is returned to the programmer.

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

What is code generation?

A

Code generation is the final stage of compilation. It converts source code via the output of lexical and syntactic analysis into machine code. The result is stored as an object file.

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

What is the result of code generation stored as?

A

The result of code generation is stored as an object file.

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

What are the two stages of code generation?

A

The creating of machine code and the optimisation of machine code.

During the creation, each token is converted into machine code instructions and memory is allocated to the tokens discovered during lexical analysis.

During the optimisation the code generator tries to optimise the code, making it as fast as efficient as possible.

17
Q

What happens during the creating of machine code stage of code generation?

A

Each token is converted into machine code instructions and memory is allocated to the tokens discovered during lexical analysis.

The code generator also works out relative addresses for jumping around within the program - these addresses are made explicit in machine code

18
Q

What happens during the optimisation stage of code generation?

A

During the optimisation the code generator tries to optimise the code, making it as fast and efficient as possible.

19
Q

What does code generation involve?

A

Producing machine code and storing it as an object file.
Allocating memory locations to variables and constants.
Working out relative addresses and adjusting the machine code apprioriately.
Optimising the machine code to maximise memory efficiency or speed.