DisplayCover |
A Correct Finite State Automatonfor Fixed Literals
Remember the finite state automaton from the previous page. It is replicated below.
Somehow we must fix this automaton so that it always checks whether there is at least one digit before the decimal point and at least one digit after the decimal point. The following finite state automaton accomplishes this.
Study this finite state automaton to see how it works. Try it with correctly formed strings, like 45.9 and 3.14159. Now try it with incorrect strings, such as 35.89.5, or 35 (with no decimal point). As before, this finite state automaton accepts the first two numbers and rejects the last two. However, this automaton will not accept strings like 5., .5, or . (just the decimal point by itself), unlike our first attempt. Therefore it important to remember when designing a finite state automaton that we want to be just as sure that it rejects all improperly formed strings as we are that it accepts all properly formed strings.
|