1 /* $NetBSD: wc1.l,v 1.1.1.1 2009/10/26 00:28:34 christos Exp $ */ 2 3 /* First cut at a flex-based "wc" tool. */ 4 5 ws [ \t] 6 nonws [^ \t\n] 7 8 %option main noyywrap 9 %% 10 int cc = 0, wc = 0, lc = 0; 11 12 {nonws}+ cc += yyleng; ++wc; 13 14 {ws}+ cc += yyleng; 15 16 \n ++lc; ++cc; 17 18 <<EOF>> { 19 printf( "%8d %8d %8d\n", lc, wc, cc ); 20 yyterminate(); 21 } 22