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