Stanford University: Keith Schwarz's "FLEX in a Nutshell"

Read these notes. FLEX is a scanner generator. It produces a scanner, given a description of the patterns to be identified and actions to take for each token.