0% found this document useful (0 votes)
95 views10 pages

Compiler Design-P

The document discusses NFA to DFA conversion and some key points about DFAs and NFAs. It provides examples of an NFA and DFA over different alphabets. It then shows the steps to convert an NFA that accepts strings with a 1 as the second to last bit to an equivalent DFA. It notes that the DFA will have more states than the NFA. The document also mentions symbol tables, syntax trees, and reducing intermediate code during compilation.

Uploaded by

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

Compiler Design-P

The document discusses NFA to DFA conversion and some key points about DFAs and NFAs. It provides examples of an NFA and DFA over different alphabets. It then shows the steps to convert an NFA that accepts strings with a 1 as the second to last bit to an equivalent DFA. It notes that the DFA will have more states than the NFA. The document also mentions symbol tables, syntax trees, and reducing intermediate code during compilation.

Uploaded by

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

Compiler design-P

DFA(Σ=ab=(a,aa,ba,ab…)

b a,b

a
Q0 Q1
NFA(Σ=(0+1)*1(0+1))

0,1 Here final state is not required 0 or 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

q0,q1,q2 q0,q2 q0,q1,q2


0

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))

You might also like