1*357f1050SThomas Veerman /* Somewhat faster "wc" tool: match more text with each rule */ 2*357f1050SThomas Veerman 3*357f1050SThomas Veerman ws [ \t] 4*357f1050SThomas Veerman nonws [^ \t\n] 5*357f1050SThomas Veerman word {ws}*{nonws}+ 6*357f1050SThomas Veerman 7*357f1050SThomas Veerman %option main noyywrap 8*357f1050SThomas Veerman %% 9*357f1050SThomas Veerman int cc = 0, wc = 0, lc = 0; 10*357f1050SThomas Veerman 11*357f1050SThomas Veerman {word}{ws}* cc += yyleng; ++wc; 12*357f1050SThomas Veerman {word}{ws}*\n cc += yyleng; ++wc; ++lc; 13*357f1050SThomas Veerman 14*357f1050SThomas Veerman {ws}+ cc += yyleng; 15*357f1050SThomas Veerman 16*357f1050SThomas Veerman \n+ cc += yyleng; lc += yyleng; 17*357f1050SThomas Veerman 18*357f1050SThomas Veerman <<EOF>> { 19*357f1050SThomas Veerman printf( "%8d %8d %8d\n", lc, wc, cc ); 20*357f1050SThomas Veerman yyterminate(); 21*357f1050SThomas Veerman } 22