Вы находитесь на странице: 1из 8

Department of Computer Science & Engineering

B.I.T : Mesra : Ranchi

Sub. : CS 6105 Compiler Design B.E - VI Sem.

Q1. Define a translator and categorize it.


Q2. Explain briefly the challenges in designing a compiler.

Q3. Explain the following terms.


(i) Compiler
(ii) Interpreter
(iii) Assembler
(iv) Prepocessor
(v) Cross-Compiler

Q4. Describe briefly various phases of compilation processes and present


the structures of a compiler. What are the advantages and disadvantages
of multipass compilers.

Q5. Construct the two different parse trees for the expression
A/B*C
and also present the three address codes for both the cases.

Q6. Describe briefly how errors may be encountered by all the phases of a
Compiler and in these cases state function of an error handler.

Q7. Explain the term 'Bootstrapping'. Explain how bootstrapping helps in


constructing CROSS compiler.

Q8. Differentiate between syntax and semantics.


Q9. What is token? How token is passed to the subsequent phases of the lexical analyzer?
Q10. Differentiate between NFA and DFA?
Q11. Design NFA for (a|b)* abb.
Q12. What are the steps associated with transformation from NFA to DFA?

Module-II

Q14. What is CFG?


Q15. Write stepwise the implementation of the assignment statement
A := B

Q16. Which of the following expressions have l-values and / or R-values.


(i) A[I+1]
(ii) * A
(iii) & A
(iv) &( * A)
(v) *( & A)
(vi) * (&(&A))
Q17.Describe briefly the implementation of the following methods of
passing parameters
(i) Call-by-Reference
(ii) Call-by-Value
(iii) Call-by-Name
Q18 Construct the parse tree for the statement
while (A>B and A<C) do
A:= (A+B)*C
Q19. a) What is the need of lexical analysis
b) Explain a simple approach used to design of lexical analysis.
c) Write short notes i) LEX ii) YACC.
d) Explain different types of storage space allocation.
e) Explain about external and internal fragmentation.

Q20. Write short notes on: LEX, YACC.

1. Consider two or three high-level prog. lang. with which you are
familiar and discuss their features that you think are most valuable to
a programmer.
2. Discuss briefly the different phases of a compiler. Define the term
Pass. How it differs from phase? Explain. Analysis and synthesis
phases.

Module III and IV

Q21 . What are steps elated to eliminating left recursion?


Q22 . What is the difference between SLR, LR, LALR prasers?

Q23. Classify the following grammers as Regular,Right-linear,Context free or


Context sensitive.
a) S---->aB b) S-->aB c) S-->AB d) S--->AB
B-->Bc B-->bC A-->a A-->a
B-->b C-->c B-->bC B-->bC
C-->c B-->b C-->c
Q24. Consider the Grammar:
S--->ABSc
S-->Abc
B-->AB
Bb-->bb
Ab-->ab
Aa-->aa

Show informally that the strings: aabc,abbc,abcc are not derivable from
the grammer.
Q25. Design a CFG that generates all non empty strings of 0's and 1's s.t.
the first of the string is identical to the 2nd half.
Q26. Design a CFG that generate palindrome of 0's and 1's.

Q27. Consider the grammar :


E-->E+T|T
T-->T*F
F-->F|(E)
F--> a
Show informally that in G:
a) Any string of the form a * a * a *....* a can be derived.
b) The pairs *+, ++, ** and +* never can appear in a sentence.

Q28. a)Discuss the role of lexical analyzer in the context of compiler.


Can the job of lexical analyzer be performed by parser itself.
Justfy your answer.
b)What is ambiguous grammar ? How can you disambiguate that grammar?
Q29. a) What do you mean by Bottom up parsing? Why it is called shift reducing
parsing? What are the conflicts arised in shift-reduce passing?
Consider the grammar
E-->E+E, E-->E*E, E-->(E)
E-->id
and show shift reducing parsing action using stack for the
expression a*b+e.
b) Define a CFG. Why is it so important in constructing compiler? When is
a grammar said to be ambiguous.
c) Write the operator precedence parsing alg.

d) Design a shift reduce parser for the following grammar


S --> 1S1 /0S0/2

e) In shift Reduce parsing, rightmost derivation in reverse is followed.


Explain.
Q 30. Explain the concept of operator precedence granmar.
For the grammar E-->T|E-T, T-->F|T*F
F-->P, P-->i|(E)
a) Obtain LEADINGE and TRAILING for each nonterminal.
b) Find the precedenc table also.
c) Explain the operator precedence parsing alg.

Q31. What do you mean by Top-down parsing?


What are the disadvantages of Top-down parsing?
Consider the grammar:
E-->TE', E'-->E|e, T-->F|T',
T'-->T|e, F-->PF', F'-->*F'|e
P--(E)|a|b|e
a) Compute FIRST & FOLLOW for each non terminal of the above grammar.
b) Find the predictive parsing table and conclude whether the grammar
is LL(1) or not.

Q32. Consider the grammar


E-->E+T|T, T-->T*F|F,
F-->id.
Eliminate left recursion from the grammar.

Q33. Find derivation trees for the sentences


a*a +a*a
in the following grammar:
E---> E + E
E---> E * E
E---> a

Q34. Trace the backtracking parser systen on the following strings:


-d,s, +.dd$, d.d$, -dd$, -d.$
Where $ --> stop symbol
d --> any decimal digit
and the grammar is defined as
V --> SR$
S --> +
S --> -
S --> E
R --> .dN
R --> d N.N
N --> dN
N -->

Q35. For the same grammar defined in (14), show that the backtracking
parser can not accept these strings:
d + $, .-d+d$, .dd.$, -dd+$

Q36. Trace the backtracking parser for the ambiguous grammar.


S --> A$
A --> aAaA
A -->

when the input string is :


aaaa$
Discuse the factors the determine which of the left-most
canonical derivations the paeser actully produces.

Q37. Trace the Bottm-up parser on strings of prob. (14)


Q38 a) In an LL(i) parser, efficiency in finding rules can be gained by
using FIRST sets. Explain clearly. In LL(2) parser, what form will
elements of the FIRST and FOLLOW sets lake.
b) Design a Recursive descent parser for the following grammar
S --> Aa\b A --> AC \ Sd \ f

Q39. Consider the following grammar:


S --> asa/aa . Clearly the grammar generates all
even length strings of a's except for the empty string.

a) By tracing through the steps of a Top-down parser (with


backtracking) Which tries the alternate aSa before aa, show that
S succeeds on 2,4 or 8 a's but fails on 6 a's.

Q40. Define Simple precedence grammar.


For the grammar:
S --> a|^|(R),
T --> S,T|S,
R -->T . Is the Grammer is Simple Precedence Grammar?

Q41. Define Left factoring.


Q42.Given a grammar with the following productions:
D -->E#, E --T|E+T, T-->T|E+T, T-->P|T*P
^
P -->F|F|P, I -->i|(E)
a) Construct LR(0) m/c for the grammar
b) Show that the grammar is SLR(1)
c) Construct the SLR(1) parsing table for this grammar.

Q43. Consider the grammar:


S --> AS|a
A -->SA|a

a) List all the LR(0) items for the above grammar.


b) IS the grammar is SLR?
c) Is the grammar is LALR? LL(1).
Q44. a) Write short notes on LR grammar and its problem.
b) Explain the working of the driving program of a LR parser.
Q45. Consider the grammar

S --> Aa|bAc|dc|bda
A -->d .
Show the grammar is LALR(1) but not SLR.

Q46. Consider the grammar

S --> Aa|bAc|Bc|bBa
A -->d
B -->d
Show the grammar is LR (1) but not LALR (1).

Q47. Given a grammar with the following productions:


E T|E+T, T-->TF|F, F-->F*|a|b
Construct a SLR parsing table.

Q48. Given a grammar with the following productions:


E T|E+T, T-->TF|F, F-->F*|a|b
Construct a LALR parsing table.

Module V and VI
Q49. Writs SDTS for RE grammar to generate the NFA for corresponding RE.
Q50. Write SDTS to evaluate arithmetic expression?
Q51. What is Display? How does it help in accelerating program execution?
Q52. What is activation record? Explain the components of activation record.
Q53. For a language implementation in which activation record are created in stack, why it is not
recommended to have large arrays as local variables and parameters?
Q54. What is runtime storage allocation?

Q55. a) Give the parse tree and translation for the expression
(4*7+19)*2 according to the syntax-directed translation scheme.
b) Compare parse tree with syntax trees.

c) Discuss different types of Intermediate Code.

Q56. a) Translate a*-(b + c) into postfix form.


b) Write the syntax directed translation scheme for assignments with
mixed mode of operands.

Q57. If all operators are binary, then a string of operators and


operands is a postfix expression iff it obeys the following two
rules.
i) There is exactly one fewer operator than operands
ii) Every non empty prefix has fewer operations than operands.
Prove the above statement.

Q58. Write quadruples, triples and indirect triples for the expression
-(a+b)*(c+d)-(a+b+c).

Q59. Using the translation scheme translate the following prog. Segment to
quadruples:
While A < C and B < D do
if A = 1 then C: = C + 1
else
while A <= D do A : = A + 2

Module VII
Q60. Discuss factor effecting target code generation.
Q61. Consider the following statements
X=a/(b+c)-d *(e+f)
Assume two registers are available. Perform code generation using tree and dynamic programming.
Q62. Consider the following statements
X=a/(b+c)-d *(e+f)
Perform register allocation assuming (i) one (ii) two (iii) three registers available.

Q63. a) What do you Know about code optimization ?


b) What is DAG ? Explain the need of DAG.
Q64. Construct the DAG for the following basic block.
D: = B * C, E: =A + B, B: = B*C, A: = E - D.
Assume A, B and C are live at the end of the basic block.
Q65. What is Global dataflow analysis? Explain it.
Q66. Explain two types of translation scheme.
Q67. Draw the plain of an error detector/corrector and explain. What it
does?
Q68. Explain the error recovery in LR parsing process.
Q69. Explain the complete process of loop optimization taking an example.
Q70. Write the data flow equations and explain the meaning of each tern
used in it.
Q71. Design top down parsing processors for
A --> aSA/e
A --> bA/a
B -->bd/c
Q72.Discuss on Storage-allocation strategies
Q73. Role of Symbol table and Error handlers in Compilers.
Q74. Discuss the necessity of optimization in compilation
Q75. Discuss factor effecting optimization,
Q76. Specify necessary and sufficient condition for constant propogation, dead code elimination,
loops optimization.

*******

Вам также может понравиться