Compiler Lecture 5
Compiler Lecture 5
Compiler Lecture 5
Today’s lecture:
How to minimise the (resulting) DFA
Practical Considerations; lex; wrap-up
CSE 359 - Compiler Masud Ibn Afjal, CSE, HSTU 1
Design
DFA Minimisation: the problem
b
C b
b
A a D E
a b b
B a a
a
For the curious, there is an alternative approach: create a graph in which there is an edge
between each pair of states which cannot coexist in a group because of the conflict
above. Then use a graph colouring algorithm to find the minimum number of colours
needed so that any two nodes connected by an edge do not have the same colour
(we’ll examine graph colouring algorithms later on, in register allocation)
b b
C b A, C b
b
A a D E a D E
a b b b b
B a B a
a a
a a
• fewer operations
• avoids memory operations (esp. important for large tables)
• added complexity may make the code ugly and difficult to understand