Theory QBank
Theory QBank
Theory QBank
1
SINHGAD TECHNICAL EDUCATION SOCIETY’S
17. What are different data structures used for symbol table? Explain.
UNIT- II Parsing
1. Explain Recursive Descent parser with an example.
2. What is Shift-Reduce and Reduce-Reduce conflict? How these can be resolved?
3. Test whether the following grammar is LL(1) or not? Construct LL(1) parser table.
S-> AB | gDa
A-> ab | c
B-> dC
C-> gC | g
D-> fD | g
4. Explain in brief the function of an operator precedence parser.
5. Discuss the problems in top-down parsing. With suitable examples, explain how they can
be overcome?
2
SINHGAD TECHNICAL EDUCATION SOCIETY’S
5. Explain the technique of “Back Patching” for translation of flow of control statement: if-
then, if-then-else and while do.
3
SINHGAD TECHNICAL EDUCATION SOCIETY’S
10. What are synthesized and inherited attributes? What are Marker Non-terminal symbols?
Give example.
11. Write syntax directed translation scheme to generate three-address code for function call
and return statements in C. For the following statement in a C program, write the three-
address code that will be generated by your scheme.
X = fun(y+2*3, 0)-1
Assume that x and y are integer variables and function ‘fun’ returns an integer value.
12. Generate three address code for the following program fragment, where a and b are
integer arrays of sizes 25*40 each, and there are four bytes per word. Variables add, i
and j are integers and are defined.
main()
{
add=0;i=j=1;
do
{
add=add+a[i][j]*b[j][i];
i=i+1;
j=j+1;
}
while(i<=25 && j<=40);
}
2. What is a DAG? Using suitable example discuss its application in code generation phase.
3. Describe any code generation algorithm you know with suitable illustration.
}
Printf(“%d”,count);
}
i) Translate the program into three address code statements.
ii) Generate target machine code
iii) Construct the flow graph
iv) For the flow graph, indicate the back edges and their natural loops
Move invariant computations out of the loops
5. What is the need of code optimization? Discuss principal sources of code optimization.
6. 1. Consider the following basic block. Draw the DAG representation of the block
and identify local common sub expressions. Eliminate the common expressions
and rewrite the basic block. Assume that none of the temp variables (S1, S2, …..,
S9) are needed outside the block. The basic block statements are
L10: S1=4*I
S2= addr(A)-4
S3= S2[S1]
S4=4*I
S5=addr(B)-4
S6=S5[S4]
S7= S3*S6
S8=PROD+S7
S9=I+1
I=S9
i. Available expression
ii. Reaching definitions
iii. Live variables
Support your answer with proper example flow graphs wherever necessary.
10. What is “next use” information? Explain its use in code generation.
11. Explain how loopsin flow graph are identified?
12. Discuss Register allocation and assignment with respect to code generation.
13. Explain in brief following techniques.
i. Constant folding
ii. Loop unrolling
iii. Strength reduction
4. Explain the two machine models use by parallel and distrusted programs.
10. What are the key implementation issues should consider by compiler for parallel object
oriented languages?
13. What are issues runtime systems should take care for message passing implementation?
16. What does a JIT compiler do opposed to a non-JIT compiler. Explain along with
example.