Here are a number of short Lex programs to demonstrate what sorts of things you can do with Lex . Several of these programs are copied from the book lex & yacc by John R. Levine, Tony Mason, and Doug Brown, published by O'Reilly & Associates, 1992.
flexcode to recognize parts of speech, combined with a
yaccprogram to recognize the grammatical structure of the sentence.
flexportions of a simple calculator program (copied from the O'Reilly book).
the Makefile for all these.