COMPILER DESIGN

INTRODUCTION TO COMPILER DESIGN

COMPILATION PROCESS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
THere are 4 main stages of compilation. Code generation is
A
Comments and unneeded spaces are removed. Remaining code is turned in to tokend and. A symbol table is created which holds the addresses of variables, labels and subroutines.
B
Tokens are checked to see if they match the spelling and grammar expected. This is done by parsing each token to determine if it uses the correct syntax for the programming language. If syntax errors are found, error messages are produced.
C
Variables are checked to ensure that they have been properly declared, used and are the correct data type. Operations are checked to ensure that they are legal for the type of variable being used, e.g. you would not try to store the result of a division operation as an integer.
D
Machine code is generated. Code optimisation to run as fast as possible. redundant data is removed.
Explanation: 

Detailed explanation-1: -Machine-Independent Optimization Techniques: Compile Time Evaluation. Common Subexpression Elimination. Variable Propagation. Dead Code Elimination.

Detailed explanation-2: -4. Intermediate Code Generation: The parse tree is semantically confirmed; now, an intermediate code generator develops three address codes. A middle-level language code generated by a compiler at the time of the translation of a source program into the object code is known as intermediate code or text.

Detailed explanation-3: -Code optimization is an optional phase. It is used to improve the intermediate code so that the output of the program could run faster and take less space. It removes the unnecessary lines of the code and arranges the sequence of statements in order to speed up the program execution.

There is 1 question to complete.