Compiler-3
Compiler-3
Instructions:
(i) MCQ (20 Marks) +Descriptive (50 Marks) =70 Marks.
(ii) In descriptive section solve any 10 questions out of 15 questions
3 Which of the following is the important factor that justifies the use of a 1 2 U
stack in shift-reduce parsing?
a. The handle will always appear on top of stack and never inside
b. The handle will always appear inside the stack and never on top
c. The handle will never appear in stack
d. None of the above
16 For a C program accessing X[i] [j] [k], the following intermediate code is 2 4 N
generated by a compiler. Assume that the size of an integer is 32 bits and
the size of a character is 8 bits.
t0 = i * 1024
t1 = j * 32 t
2=k*4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which one of the following statements about the source code for the C
program is CORRECT?
a. X is declared as “int X[32] [32] [8]”.
b. X is declared as “int X[4] [1024] [32]”.
c. X is declared as “char X[4] [32] [8]”.
d. X is declared as “char X[32] [16] [2]”.
20 Consider the below given macro definition and macro call. Write the 5 6 C
code after macro expansion.
Macro definition:
MACRO
F1 &X
MOVER AREG , X
GBL &K
&K SET 1
.NEXT ADD AREG , 1
&K SET &K+1
AIF (&K LE 4) .NEXT
MEND
Macro call:
F1 100
24 Find basic block and draw control graph for following code written in 5 5 C
higher level language.
fact(x) {
int f = 1;
for (i = 2; i <= x; i++)
f = f * i;
return f;
}
25 Why there is a need to have intermediate code generation phase? Explain 5 4 U
any two techniques to implement three address code.
26 Write down the goals of an error handler in a parser. What are the different 5 2 U
error strategies used by a parser to recover from a syntactic error?
Note:
CO – Course Outcomes
BL – Bloom’s Taxonomy Level