Docsity

DFA Minimization, Acceptor - Compiler Construction - Lecture Slides, Slides of Compiler Construction

Partial preview of the text

Download DFA Minimization, Acceptor - Compiler Construction - Lecture Slides and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 9

2

DFA Minimization

 The generated DFA may

have a large number of

states.

 Hopcroft’s algorithm:

minimizes DFA states

4

DFA Minimization

 Idea: find groups of

equivalent states.

 All transitions from

states in one group G 1

go to states in the same

group G 2

5

DFA Minimization

 Idea: find groups of

equivalent states.

 All transitions from

states in one group G 1

go to states in the same

group G 2

7

DFA Minimization

DFA for (a | b )abb*

A

a

b a

b b B D E

C

a

b

b

a

a

8

DFA Minimization

Minimized DFA for (a | b )abb*

A,C

b a b b B D E a

b

a

a

10

Lexical Analyzers

 Lexical analyzers (scanners)

use the same mechanism

 but they:

  • Have multiple RE descriptions for multiple tokens
  • Have a character stream at the input

11

Lexical Analyzers

 Lexical analyzers (scanners)

use the same mechanism

 but they:

  • Have multiple RE descriptions for multiple tokens
  • Have a character stream at the input

13

Lexical Analyzers

  • Return a sequence of matching tokens at the output (or an error)
  • Always return the longest matching token

14

Lexical Analyzers

  • Return a sequence of matching tokens at the output (or an error)
  • Always return the longest matching token

16

Lexical Analyzer Generators

 The lexical analysis process

can automated

 We only need to specify

  • Regular expressions for tokens
  • Rule priorities for multiple longest match cases

17

Lexical Analyzer Generators

 The lexical analysis process

can automated

 We only need to specify

  • Regular expressions for tokens
  • Rule priorities for multiple longest match cases

19

Lexical Analyzer Generators

 Flex

generates lexical analyzer in C

or C++

 Jlex

written in Java. Generates

lexical analyzer in Java

20

Using Flex

 Provide a specification file

 Flex reads this file and

produces C or C++ output file

contains the scanner.

 The file consists of three

sections