Homework 7 Suggestion

This is a bit of a hint for Homework 7: Don't use arrays. Use finite state machines.

A finite state machine table

FSM for counting reals

C code for the FSM

The links in this table are labeled by character types defined in chartypes.h. If your program calls getRealCharType from chartypes.c, it will transform input ASCII characters into these character types.

The "starter" main program of countreal.c contains the beginning of an finite state machine, implemented in a C program, to solve the homework program.

The real FSM

You will notice that there are many missing arcs in the FSM diagram. For example, there is no arcs labeled EXP coming out of the state labeled AFTERDOT.

In the real world, finite state machines are not draw with complete sets of arcs as they were in CSCI 255, ECE 109, or ECE 212. Instead default transitions are described in English-like statement. For example, there are no arcs labeled EOL or WSP in the diagram. That's because all arcs like these go to the INSPACE state. If you put all these arcs on the diagram, it would look like a bowl of spaghetti.

Similarly, there are lots of missing arcs on the right side of the diagram. Most of these go over to the state READINGWORD.

The "output"

The FSM above is also missing "output" actions. In fact, most arcs require nothing other than moving to a new state. Howefer, some arcs require an action, such as incrementing realCount or printing a line of output.

We're leaving that part of the assigment for you to complete.