0% found this document useful (0 votes)
126 views2 pages

Assignment2 Compilerdesign Aec (Manish Sir)

This document contains 13 questions related to compiler design topics such as predictive parsing, operator precedence parsing, LR parsing, ambiguity in grammars, and error handling. The questions cover constructing parsing tables from grammars, removing left recursion from grammars, and discussing parsing techniques like top-down parsing and bottom-up parsing.

Uploaded by

prashant
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views2 pages

Assignment2 Compilerdesign Aec (Manish Sir)

This document contains 13 questions related to compiler design topics such as predictive parsing, operator precedence parsing, LR parsing, ambiguity in grammars, and error handling. The questions cover constructing parsing tables from grammars, removing left recursion from grammars, and discussing parsing techniques like top-down parsing and bottom-up parsing.

Uploaded by

prashant
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Subject: - Compiler Design (TCS-502)

_________________________________________________________________
____

Q1.Consider the following grammar find out the predictive parsing table . (10)
(i) E→ E+T │ T (ii) S→ iEtS│ iEtSeS │a
T→ T* F │ F E→ b
F→ (E) │ id

Q2. Construct all possible parse trees corresponding to the string i+ j * k for the
following grammar . also comment on the precedence of operator + and * used in
the grammar E → E+E, E → E*E , E → id

Q3. Discuss the operator precedence parsing algorithm . Consider the following
operator grammar and precedence functions ; explain the parsing of input string
id +id*id , Precedence Functions :-

+ * id $
f 4 2 4 0
g 3 1 5 0

Q4. Consider the following grammar construct the predictive parsing table.
S→ (L) │ a
L→ L, S │ S

Q5. Consider the following grammar :-


E→ E+T │ T
T→ T* F │ F
F→ (E) │ id
(i) Remove the left recursion
(ii) Compute the FIRST and FOLLOW sets of non terminals of the resulting
grammar .
(iii) Show the resulting grammar is LL(1)
(iv) Construct the LL(1) parsing table for the resulting grammar .

Q6.Discuss algorithms for computation of the sets of LR(1) items . Also show that the
following grammar is LR(1) but not LALR(1)
G:- S→ Aa │ bAc │Bc│ bBa
A→ d
B→d
Q7. Consider the following grammar
E→ E+T │ T
T→ T* F │ F
F→ F*│ a │ b
(a) Construct the collection of LR (0) items for the above grammar.
(b) Construct DFA transition diagram.
(c) Construct the parsing table using SLR algorithm.
Q8. State the problems associated with Top-Down parsing .State and eliminate the
problem associated with the following grammar for Top-Down parsing
E→ E+T │ T
T→ T* F │ F
F→ (E) │ id
Q9. What do you understand by Lexical phase errors and Syntactic phase error .
Also suggest the methods of error recovery .

Q10. Discuss the following parameters parsing techniques with suitable example :-
(i) Call by value
(ii) Call by reference
(iii) Call by name

Q11. Construct the LALR parsing table for the following grammar :-
S→ AA │ T
A→ aA │b
Q12. Consider the following operator precedence matrix and compute the precedence
function :-

a ( ) ; $
a .> .> .>
( <. <. = <.
) .> .> .>
; <. <. .> .>
$ <. <.

Q13. Give the algorithm for construction of predictive parsing table . Consider the
following grammar construct predictive parsing table :-
S→ iEtSM │ T
M→ eS │E
E→ b

You might also like