1 /* First cut at a flex-based "wc" tool. */ 2 3 ws [ \t] 4 nonws [^ \t\n] 5 6 %% 7 int cc = 0, wc = 0, lc = 0; 8 9 {nonws}+ cc += yyleng; ++wc; 10 11 {ws}+ cc += yyleng; 12 13 \n ++lc; ++cc; 14 15 <<EOF>> { 16 printf( "%8d %8d %8d\n", lc, wc, cc ); 17 yyterminate(); 18 } 19