Categories

Compiler design

CSE - Compiler design - Questions and solutions
Question:-
Option (A)
it prefer a two pass compiler to an one pass compiler
Option (B)
it prefer an one pass compiler to a two pass compiler
Option (C)
prefer an interpreter to a compiler
Option (D)
not support recursion
Correct Option:
B
Question Solution:
In a two pass compiler, the space occupied by the first pass can be used by the second pass. Since an interpreter translates and executes one line at a time, it is less complex than a compiler. So it should occupy less space. Recursion needs run-time stack whose size changes dynamically.
So option (b) not holds true for such type of language.
Question:-
Option (A)
syntax analysis
Option (B)
semantic analysis
Option (C)
lexical analysis
Option (D)
code optimizer
Correct Option:
B
Question Solution:
During semantic analysis the compiler tries to detect constructs that have the right syntactic structure but no meaning to an operation involved. Example To add two identifier, one of which is the name of an array and other the name of a procedure.
Question:-
Option (A)
Coincidental cohesion
Option (B)
Functional cohesion
Option (C)
Both (a) and (b)
Option (D)
None of these
Correct Option:
A
Question Solution:
In the given example different function of the module carry out very different and unrelated activities starting from issuing of library books to creating library member records on one hand, and handling librarian request on the other.
Question:-
Option (A)
There are no such derivation tree possible
Option (B)
1
Option (C)
2
Option (D)
More than 2
Correct Option:
C
Question Solution:
Derivation for the sentence i + i * i↑i. One such derivation is
<expr> => + <expr>
=> + * <expr>
=> + * ↑­
=> i + i * i ↑­ i
Another possible derivation
<expr> => <expr> ↑­
=> + <expr> ↑­
=> + * ↑­
= i + i * i ↑­ i
In the above both underlined non-terminal denotes that it is being rewritten in the next step of derivation.
Two distinct syntax tree


Hence option (c) is true.