Compiler Design-P
Compiler Design-P
DFA(Σ=ab=(a,aa,ba,ab…)
b a,b
a
Q0 Q1
NFA(Σ=(0+1)*1(0+1))
1 0,1
Q0 Q1 Q2
NFA TO DFA Conversion
NFA of all binary strings in 2nd last bit is 1
0 1
Q0 Q1 Q0,Q1
Q1 Q2
Q2
Q2 - -
NFA to DFA
Expand only one time
1st row will be copied as it is
0 0
q0 qo q0,q1
q0,q1 q0,q2
q0,q1,q2
Q0,q2 q0 Q0,q1
1
q0 Q0,q1
0 0 1
1
Q0,q2 Q0,q1,q2
0
1
Some points about DFA NFA
• NFA final state is also DFA final state
• DFA is complex compare to NFA
• DFA in number of state is more
• If NFA is N than DFA is n 2 power n(n=3,2 power3=8)state
Symbol Table and Syntax tree
• Id1=id2-id3*2
=
X
+
Y *
z 2
Int to real no
……..
t1=int to real(2)
t2=z*t1
t3=t2+b
id1=t3
Reduce intermediate code
T1=z*2.0
Id1=y+t1
tasks
• A-b*c+d
• A*(b+c)-d/2
• (a+b)*(c-d)+((e/f)*(a=b))