Compilation process Flashcards

1
Q

How many steps are there in the compilation process of a program?

A

Six total steps, with an optional extra one.

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

Name all of the steps in the compilation process of a program.

A
  1. Lexical analysis (scanning)
  2. Syntax analysis (parsing)
  3. Semantic analysis
  4. Immediate code generation
  5. Code optimization
  6. Code generation
  7. Extra: Linking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain the purpose of the first step of the compilation process.

A

The lexical analysis (scanning) reads the source code into BT characters and groups them into tokens.

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

Explain the process of the first step of the compilation process.

A

The lexical analysis process consists on having the lexer (or scanner) identify elements such as keywords, identifiers, operators, constants, and other syntactic elements, while discarding white spaces and comments.

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

What is the output of the first step of the compilation process?

A

Stream of tokens

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

Explain the purpose of the second step of the compilation process.

A

On the Syntax analysis (parsing), the stream of tokens is checked for whether the code follows the grammatical rules (syntax).

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

Explain the process of the second step of the compilation process.

A

On the syntax analysis, the parser constructs a parse (or syntax) tree, which represents the grammatical structure of the program. It identifies syntax errors, too.

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

What is the output of the first step of the compilation process?

A

Parse tree

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

Explain the purpose of the third step of the compilation process.

A

On the Semantic analysis, the meaning or semantics of the program is checked.

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

Explain the process of the third step of the compilation process.

A

On the Semantic analysis, a verification of type compatibility is done, if variables are declared before use, and other semantic checks are performed. Information about the program’s meaning is gathered.

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

What is the output of the third step of the compilation process?

A

Annotated syntax tree (AST)

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

Explain the purpose of the fourth step of the compilation process.

A

On the Immediate code generation, an intermediate representation (IR) of the source code is generated by the compiler.

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

Explain the process of the fourth step of the compilation process.

A

On the Immediate code generation, the AST is translated into an IR by translating arithmetic, logical, and relational expressions into intermediate code, such as three-address code, quadruples, or triples. Variables get assigned values. Control flow statements are handled.

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

What is the output of the fourth step of the compilation process.

A

Intermediate code (IR)

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

Explain the purpose of the fifth step of the compilation process.

A

On the Code optimization, there is an attempt to improve the performance and efficiency of the generation code by applying various optimization techniques.

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

Explain the process of the fifth step of the compilation process.

A

On the code optimization, transformations are performed on the IR by the optimizer. Optimizations could be constant folding, dead code elimination, and loop optimization.

17
Q

What is the output of the fifth step of the compilation process?

A

Optimized intermediate code.

18
Q

Explain the purpose of the sixth step of the compilation process.

A

On the Code generation, the optimized intermediate code is translated into the target machine code.

19
Q

Explain the process of the sixth step of the compilation process.

A

The code generator selects appropriate machine instructions for each IR instruction and allocates registers for variables.

20
Q

What is the output of the sixth step of the compilation process.

A

Target machine code or assembly code.

21
Q

What is the optional, extra step (seventh) of the compilation process?