We can generate a lexical analyzer automatically by using a lexical analyzer generator. This generator takes as input the precise specification of the tokens of the language and a specification of the action to be performed on the identification of each token. As an output, it generates a lexical analyzer. The UNIX tool lex is such a generator. Lex: Lex is a lexical analyzer generator and Yacc is a parser generator. They help us to write programs that transform structured input.