xref: /minix/external/bsd/flex/dist/examples/fastwc/wc2.l (revision 0a6a1f1d)
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 %option main noyywrap
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 
14 {ws}+		cc += yyleng;
15 
16 \n+		cc += yyleng; lc += yyleng;
17 
18 <<EOF>>		{
19 		printf( "%8d %8d %8d\n", lc, wc, cc );
20 		yyterminate();
21 		}
22