Week1 (1.2) Flashcards

1
Q

What are the two main parts of a compiler?

A

Analysis (front end) and synthesis (back end).

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

What does the analysis part of a compiler do?

A

Breaks the source program into pieces, imposes grammatical structure, and creates an intermediate representation.

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

What does the synthesis part of a compiler do?

A

Constructs the target program from the intermediate representation and symbol table.

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

What is the symbol table in a compiler?

A

A data structure that stores information about the source program, such as variable attributes.

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

What is the purpose of the machine-independent optimization phase?

A

To transform the intermediate representation to produce a better target program.

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

What is lexical analysis?

A

The phase that groups characters into lexemes and converts them into tokens for syntax analysis.

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

What is a token in lexical analysis?

A

A pair consisting of a token name and an attribute value, representing a meaningful sequence of characters.

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

What is syntax analysis?

A

The phase that uses tokens to create a tree-like intermediate representation of the program’s structure.

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

What is semantic analysis?

A

The phase that checks for semantic consistency and gathers type information for later stages.

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

What is type checking in semantic analysis?

A

Ensuring operators have matching operands and performing necessary type coercions.

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

What is intermediate code generation?

A

The phase where the source program is converted into an abstract machine-like intermediate representation.

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

What is three-address code?

A

A form of intermediate representation with assembly-like instructions and at most three operands per instruction.

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

What is code optimization?

A

The phase that improves intermediate code for better target code, such as faster or more efficient execution.

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

What is code generation?

A

The phase where intermediate representation is translated into target machine code.

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

What is the role of registers in code generation?

A

Registers are assigned to hold variables for efficient execution.

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

What is symbol-table management?

A

The process of recording variable names and attributes for use during compilation.

17
Q

What is a compiler pass?

A

A grouping of phases that reads an input file and writes an output file, such as front-end or back-end passes.

18
Q

What is the role of compiler-construction tools?

A

To assist in implementing compiler phases, such as parser generators, scanner generators, and code generators.

19
Q

What does a parser generator do?

A

Automatically produces syntax analyzers from a grammatical description of a programming language.

20
Q

What does a scanner generator do?

A

Creates lexical analyzers from regular-expression descriptions of tokens.