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