MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
One of the purposes of using intermediate code in compilers is to
A
make parsing and semantic analysis simpler.
B
improve error recovery and error reporting.
C
increase the chances of reusing the machine-independent code optimizer in other compilers.
D
improve the register allocation
Explanation: 

Detailed explanation-1: -Answer: d. to increase the chances of re-using the machine-independent code optimizer in other compilers. Explanation: After semantic analysis, the intermediate code increases the chances of reusing the machine-independent code optimizer in other compilers.

Detailed explanation-2: -increase the chance of reusing the machine-independent code optimizer in other compilers.

Detailed explanation-3: -Advantages of Intermediate Code We need intermediate code because if we don’t have the option to create intermediate code, we require a native compiler for each new machine. It becomes very easy to apply source code changes to enhance the implementation by optimising the intermediate code.

Detailed explanation-4: -What is intermediate code? Ans: During the translation of a source program into the object code for a target machine, a compiler may generate a middle-level language code, which is known as intermediate code or intermediate text. The complexity of this code lies between the source language code and the object code.

Detailed explanation-5: -Intermediate code eliminates the need of a new full compiler for every unique machine by keeping the analysis portion same for all the compilers. It becomes easier to apply the source code modifications to improve code performance by applying code optimization techniques on the intermediate code.

There is 1 question to complete.