process of compilation Flashcards

1
Q

name the stages of compilation in order

A
lexical analysis
syntax analysis
semantic analysis
code generation
optimisation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the Lexical analysis stage remove?

A

comments and spaces

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

What is replaced with tokens in this lexical analysis stage?

A

keywords, constants and identifiers in the source code

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

What is created in lexical analysis stage?

A

symbol table- holds the addresses of variables, labels and subroutines

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

What’s the function of the syntax analysis stage?

A

Each statement is checked against the rules of syntax for the assembler

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

What’s checked in syntax analysis?

A

spelling

grammar

sequence of input characters, symbols, items or tokens should obey the rules of syntax of the language

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

Describe parsing.

A

task of systematically breaking down high level statements into their component parts e.g. reserved words and variables

during translation process

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

What does the semantic analysis stage do?

A

check meanings of statements are clear and consistent with rules of compiler, structure and data types that are supposed to be used

checks to see if all variables in program have been declared

carries out type checks e.g. makes sure real values haven’t been assigned to integer variables

checks that appropriate operations have been carried out on variables e.g. integer division not carried out on real variables

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

What does the code generation stage do?

A

generates machine code

high level statements (most) translated into several machine code instructions

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

What is optimisation stage?

A

employing a technique to try and reduce the execution time of the object program

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

Explain a syntax error.

A

occurs when program is being compiled

code doesn’t fit into expected syntax of the language

e.g. spelling mistake, not closing brackets, missing colon

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

Explain linking error.

A

may occur if compiled program is linked to library routines

e.g. a program may not be present in the library

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

Explain run time error.

A

occurs when program is being run

parts of program work, elements have been coded incorrectly

program will crash (this is a run time error)

e.g. a program tries to display a user’s name but the name hasn’t been saved anywhere and so the program crashes

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

Explain rounding error.

A

When a number is approximated to the nearest whole number

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

Explain logical error.

A

causes a program to output an incorrect value, but the program doesn’t crash

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

Explain a truncation error.

A

where a number is approximated to a whole number/tenth/hundredth etc nearer to zero