Skip to content

Scanner, Finite State Automation

mfunkie edited this page Feb 16, 2013 · 1 revision

A finite state automation has the formal definition to be (Σ,S,s0,δ,F).

Σ is the alphabet of the machine. This includes spaces, brackets, alphanumeric characters, and other symbols that can be recognized as comment starters. The alphabet is finite and non-empty. That is to say there is a limit to what we can accept.

S is the finite, non-empty set of states. Each of our states can be considered to be situational based on where we are in the reading. s0 is the initial state that is included in the set of S. In our case it can move to several different states on varied input, or continue in its own state if it reads spaces because we need not begin a new token at such time.

δ is a state transition function. From a certain state, we can use a character in our alphabet to transfer to another state or transfer to itself. For an example a read in of 0-9 will move us into an integer state, and from there we could continue to read 0-9, or we could possibly read a decimal which would put us into a float state.

F is the final state, or list of final states. In our case we might need a final state that is an error state and a final state that is just a continue to the next token reading state.

Clone this wiki locally