Professional Documents
Culture Documents
Work Out Problems
Work Out Problems
Work Out Problems
1. What are the phases of the compiler? Explain the phases in detail. Write down the output of each phase
for the expression:
i) a := b + c * 60
ii) a = (b+c) * (b+c) *2
iii) position := initial +rate * 60
iv) amount = principle + rate * 36.0
v) a := b + c - 60
i) abb (a|b)*
ii) (a|b)* abb
i) abb (a|b)*
ii) (a|b)* abb
iii) ab*| ab
iv) (a|b)* a
v)(a*|b*)*
i) (0+1)*(0+1)01
ii) (a|b|c)* (a|b)*
5. Draw the DFA for the augmented regular expression directly using syntax tree method.
i) (a|b)*#
ii) (a|b)* abb
iii) abb (a|b)*
UNIT - 2 SYNTAX ANALYSIS
1. what is an ambiguous grammar ? is the following grammar ? Prove E--> E+E/E*E/(E)/id for the
sentence id+id*id.
2. Explain the non-recursive implementation of predictive parser with the help of the grammar,
i) E--> E + T
E--> T
T--> T * F
T --> F
F--> (E) / id
iii) Define an LL(1) grammar. How do you check whether the grammar is LL(1) or not? Generate
LL(1) parsing table for the grammar.
S--> iEtS / iEtS / a
E--> b
Is grammar in LL(1) or not ?
3. Consider the grammar E--> E+E/E*E/id perform shift reduce parsing of the input String id1+id2*id3.