Mod 2 (introduction) Flashcards

1
Q

Language processing diagram (stages of language processing)

A

preprocessor -> compiler -> assembler -> linker/loader

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

role of preprocessor

A

a program may be divided into modules stored in a separate file
the task of collecting the source program in entrusted to the preprocessor
the preprocess is also required to expand on shorthands, called as macros

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

role of compiler

A

the modified source program is fed into the compiler.

the compiler produces an assembly language with the modified source program

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

role of assembler

A

the assembler processes the assembly program

it produces a relocatable machine code as its output

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

role of linker/loader

A

large programs need to be compiled in pieces.
the relocatable machine code may have to be linked together with other relocatable machine code and library files, so the program can actually run on the machine.

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

Structure of compiler

A
lexical analyzer
syntax analyzer
symantic analyzer
intermediate code generator
code optimizer
code generator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Role of lexical analyzer

A

reads the input from the source program and produces a meaningful sequence of character called as lexemes
these lexemes are sent to the next stages of the compiler as tokens
these lexemes are also stored into a symbol table for further referencing

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

Role of syntax analyzer

A

it uses the tokens generated in the prev stage of the analysis and generates an intermediate tree like representation, called the syntax tree
a syntax tree consists of interior nodes that represent the operations and the children of the node represent the arguments of the operation

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

Role of semantic analyzer

A

it uses the syntax tree and the symbol table from the previous steps to check for the type consistency with the language
it gathers the type information and saves it for either the syntax tree or the symbol table for subsequent use during the intermediate code generation

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

Role of intermediate code generator

A

most compilers generate a intermediate low level or machine like intermediate representation
this intermediate representation should have two important properties
- it should be easy to produce
- it should be easy to translate it to target machine code

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

Role of code optimizer

A

it attempts to improve the intermediate code so that it will result in a better target code
better usually means faster, but it can also shorter code, or it consumes less power

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

Role of code generator

A

the main role is to generate the target machine code of the given source code
it takes the intermediate code representation and maps it to the target language
if the target is machine code, it maps the memory location or registers for each variable
it is then translated into sequences of machine instructions
the crucial part is the judicious assignment of the registers for the local variables

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