Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template...

7
Alex Aiken Compilers NFA to DFA

Transcript of Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template...

Page 1: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

Compilers

NFA to DFA

Page 2: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

NFA to DFA

Regular expressions

NFA

DFA

Lexical Specification

Table-driven Implementation of DFA

Page 3: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

NFA to DFA

1

0

1

A B C

D

E

F G H I J

Page 4: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

NFA to DFA

• An NFA may be in many states at any time

• How many different states?

Page 5: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

NFA to DFA

Page 6: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Alex Aiken

NFA to DFA

1

0 1

A B C

D

E

F G H I J

FGHIABCD

EJGHIABCD

ABCDHI 0

1

0

1 0 1

Page 7: Introduction to Programmingopenclassroom.stanford.edu/.../04-04-nfa-to-dfa.pdf · Template block2x2-1 Ordering of 0 buttons is: 13 24 NFA to DFA 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1 0 Choose

Template block2x2-1 Ordering of buttons is: 13 24

NFA to DFA

1

0

0

1

1

0

0

1

1

0

0 0

1

0

0

1

0

Choose the DFA that represents the same language as the given NFA