[Overview] [Previous] [Next]
Implementing a DFA
If you don't object to the go to statement,
there is an easy way to implement a DFA:
q0 : read char;
if eof then accept string;
if char = 0 then go to q2;
if char = 1 then go to q1;
q1 : read char;
if eof then reject string;
if char = 0 then go to q3;
if char = 1 then go to q0;
q2 : read char;
if eof then reject string;
if char = 0 then go to q0;
if char = 1 then go to q3;
q3 : read char;
if eof then reject string;
if char = 0 then go to q1;
if char = 1 then go to q2;
Copyright © 1996 by David Matuszek
Last modified Jan 29, 1996