%{ #include #include int chars = 0; int words = 0; int lines = 0; %} %option noyywrap %% [a-zA-Z]+ {words++; chars += yyleng;} \n {chars++; lines++;} . {chars++;} %% int main( ) { yylex( ); printf("Characters: %d\nWords: %d\nLines: %d\n", chars, words, lines); return 0; }