Finite State Machines Find the words that match '*and*$' where '*' is zero or more characters other then 'and$'. $ is the end of string marker. What is my alphabet? * a n d $ state symbol action a n d * $ 0 1 0 0 0 err 1 1 2 0 0 err 2 1 0 3 0 err 3 3 3 3 3 ok State diagram err err err ^ ^ ^ |$ |$ |$ --- a --- n --- d --- $ ------ | 0 |->->| 1 |->->| 2 |->->| 3 |->->|accept| --- --- \ --- --- ------ n| ^ d| a| ^ a| |n a| ^ d| | *| ->|<-|<-<-/<-<-<-<-<-/ *\->/ Developing a finite state machine for a or complicated set of rules. rule 1 *er$ rule 2 *ing$ * e r $ * i n g $ * e r $ i n g 0 0 1 0 err 2 0 0 1 0 1 3 err 2 0 0 2 0 1 0 err 2 4 0 3 0 1 0 OK 2 0 0 4 0 1 0 err 2 0 5 5 0 1 0 OK 2 0 0 --- err | 2 |<-<-<-<-< ^ /--- err ^ \ $| /i $| / i| --- e --- r --- $ ---- | 0 |->->| 1 |->->| 3 |->->| OK | --- --- --- ---- *| \ n| |\ n| r| ^ g| | | g| n| | *| \-| r| g| ^ / e *| \->|<-<-<-<-<-<-<-/