0% found this document useful (0 votes)
21 views3 pages

24-25 - Assignment 2

Compiler design assignment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

24-25 - Assignment 2

Compiler design assignment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

4CP01 – Compiler design

Assignment 2
A.Y : 2024-25
1. Check following grammar is CLR or not?
S->1S0
S->0S1
s->10
2. Check following grammar is LR(1) or not?
S->aBc/bCc/aCd/bBd
B->e
C->e
3. Construct LALR parsing table for following grammar:
E->E+T/T
T->TF/F
F->F*/a/b
4. Write SDD for Binary to decimal number conversion
5. Write SDT for following grammar:
E->TE’
E’->+TE’
E’->epsilon
T->(E)
T->digit
6. 1) i=1
2) j=1
3) t1 = 10 * i
4) t2 = t1 + j
5) t3 = 8 * t2
6) t4 = t3 - 88
7) a[t4] = 0.0
8) j = j + 1
9) if j <= goto (3)
10) i = i + 1
11) if i <= 10 goto (2)
12) i = 1
13) t5 = i - 1
14) t6 = 88 * t5
15) a[t6] = 1.0
16) i = i + 1
17) if i <= 10 goto (13)
How many basic blocks can be generated?
7 Write 3 address code for following:
c=0
do
{
if (a < b) then
x++;
else
x–;
c++;
} while (c < 5)

8 Write 3 address code for following:


switch (ch)
{
case 1 : c = a + b;
break;
case 2 : c = a – b;
break;
}

9 Construct a DAG for the following three address code-


1. a=b+c
2. t1 = a x a
3. b = t1 + a
4. c = t1 x b
5. t2 = c + b
6. a = t2 + t2

You might also like