Compiler design miscellaneous
- Consider the following translation scheme:
S → FR
R → *E{print (‘*’); R | ε
E → F + E {print (‘+’); |F
F → (S)| id {print (id. value);}
Here, id is a token that represents an integer and id value represents, the corresponding integer value. For an input ‘2 * 3 + 4’, this translation scheme prints.
-
View Hint View Answer Discuss in Forum
I figured out the following tree and found the answer will be D. make a tree and perform post order evaluation.
Correct Option: D
I figured out the following tree and found the answer will be D. make a tree and perform post order evaluation.
- Which of the following statements are CORRECT?
(1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
(2) Automatic garbage collection is essential to implement recursion.
(3) Dynamic allocation of activation records is essential to implement recursion.
(4) Both heap and stack are essential to implement recursion.
-
View Hint View Answer Discuss in Forum
Heap is essential to allocate memory for data structures at runtime, not for recurssion.
Correct Option: D
Heap is essential to allocate memory for data structures at runtime, not for recurssion.
- Which one of the following is NOT performed during compilation?
-
View Hint View Answer Discuss in Forum
Dynamic memory allocation is not performed during compilation. It is performed during sun time not during complete time
Correct Option: A
Dynamic memory allocation is not performed during compilation. It is performed during sun time not during complete time
- Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at
-
View Hint View Answer Discuss in Forum
The two modules needed to be linked since definition exist & M2 & M1 refers it. So during linking phase M1 links to M2. Hence (c) is correct option.
Correct Option: C
The two modules needed to be linked since definition exist & M2 & M1 refers it. So during linking phase M1 links to M2. Hence (c) is correct option.
- Consider the basic block given below.
a = b + c
c = a + d
d = b + c
e = d - b
a = e + b
The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are
-
View Hint View Answer Discuss in Forum
The given block is
a = b + c
c = a + d = b + c + d
d = b + c
= b + b + c + d = 2b + c + d
e = d – b = b + b + c + d – b = b + c + d
a = e + b = b + b + c + d = 2b + c + d
Therefore e and c are same, a and d are same. The DAG generated is as follows:
The maximum number of nodes and edges is (6, 6)Correct Option: A
The given block is
a = b + c
c = a + d = b + c + d
d = b + c
= b + b + c + d = 2b + c + d
e = d – b = b + b + c + d – b = b + c + d
a = e + b = b + b + c + d = 2b + c + d
Therefore e and c are same, a and d are same. The DAG generated is as follows:
The maximum number of nodes and edges is (6, 6)