- normal state: copy a character to a token buffer
- accept state: return a token & go back to intial state
- “error” state: report an error & stop
to make a finite automata as a code we need
- state
- lookahead() - just look
- next() - next character
- return token
- report error (there is error state)
- while lookahead() ≠ EOF
- case per state
- Regex to DFA separately
- Combine DFAs to NFA
- NFA to DFA conversion
- Adjust DFA