Compiler Construction

Q1. Generate operator precedence table for the following grammar G= {{S,A}, {0,1,a,b, #), P,S) where P is given as below: S 0S1|A A→ aAb | #

(4)

Q2. Check whether that the given grammar G' is LL(1) or not by using predictive parsing

Table

G'={{X,Y,Z}, {(,), num, +,y), P, S) where P is given as below: X→ (Y)\num

Y YXZ y

Z+XZ |&

Click here to join us on Social Media for getting instant update on every notice

(4)

Q3. a) Explain analysis and synthesis model of a compiler with the help of a block diagram.

b) Eliminate left factoring from the given grammar: S-bSSaaS | bSSaSb | bSb | a

(3)

(1)

Q4. Design a DFA that can recognize prefix and postfix constructs as given below: {++id/id++/--id/ id--}[Note: also follow the identifier rule of C.]

Q5. Construct SLR parsing table for the gram nar, G= {{ident, letter, digit}, {c,d), P, ident} where P is given as below:

ident→ letter digit

digit→ letter digit | digit letter| d |

letter → c❘ & -

Also give the DFA using LR(0) items.

Q1. a) What are the possible error-recovery actions in Predictive parser. b) Give the input and output for the analysis phases of a compiler using given expression: I=(P*R*T)/100;

(2)

Q2. Calculate first and follow for the following grammar:

(2)

X-E1+SY Yb

YE 1-SXc

Give the predictive parsing table, Also check whether that the given grammar is LL(1) or not.

(4)

Q3. a) Give a R.E. that can recognize a declaration statement of C language. b) Eliminate left recursion from the following grammar:

(2)

S→ Aalb

A→ Ac | Ad | AAB | bA| Ba | aA| zAA &

B→cB | b | aB 

Q5. Construct SLR parsing table for the following grammar: E-T+E T

Tint Tint (E)

Also give the DFA using LR(0) items.