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. Lexical 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 lexical analyzer is responsible for removing the white spaces and comments from the source program. It corresponds to the error messages with the source program. It helps to identify the tokens. The input characters are read by the lexical analyzer from the source code.

Detailed explanation-2: -Explanation: Lexical analyzer is used in the compiler for removing the Whitespace and comments. It is also used in breaking the syntaxes into the set of tokens.

Detailed explanation-3: -Lexical analysis is the first phase of a compiler. It takes modified source code from language preprocessors that are written in the form of sentences. The lexical analyzer breaks these syntaxes into a series of tokens, by removing any whitespace or comments in the source code.

There is 1 question to complete.