COMPILER DESIGN

INTRODUCTION TO COMPILER DESIGN

COMPILATION PROCESS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
THere are 4 main stages of comilation. Syntax Analysis 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: -The grammar of the programming is checked at Syntax analysis phase of the compiler.

Detailed explanation-2: -Syntax analysis is the compilation stage that immediately follows lexical analysis. Once tokens have been assigned to the code elements, the compiler checks that the tokens are in the correct order and that they follow the rules of the programming language being used.

Detailed explanation-3: -There are 6 phases in the compiler, namely, lexical analysis, syntax analysis, semantics analysis, intermediate code generation, code optimization, and code generation.

There is 1 question to complete.