You are on page 1of 2

Vellore Institute of Technology, Chennai

School of Computer Science and Engineering

BCSE307L – Compiler Design

Digital Assignment – Module 1 & 2

1. Explain with neat diagram about the phases of compiler and write output
of all the phases of compiler for following statements:
a) x = b-c*2
2. Construct DFA for (c | d)*c regular expression using Direct Method
Derivation

3. Perform leftmost derivation and draw parse tree.


S→A1B
A→0A | 𝜖
B→0B | 1B | 𝜖
Output string: 1001
4. Perform leftmost derivation and draw parse tree.
S→0S1 | 01 Output string: 000111
5. Perform rightmost derivation and draw parse tree.
E→E+E | E*E | id | (E) | -E
Output string: id + id * id
Ambiguous Grammar
6. S→ aS | Sa | 𝜖 (output string: aaaa)
7. S→ aSbS | bSaS | 𝜖 (output string: abab)
Left Recursion & Left Factoring
8. A→Abd | Aa | a
B→Be | b
9. Compute FIRST and FOLLOW for the following grammar
S → AS
S →b
A →SA
A→a
10.Analyse the give grammar to construct predictive parser
S→ +SS | *SS | a
with the string “+*aa”

You might also like