xref: /minix/external/bsd/flex/dist/examples/fastwc/wc2.l (revision ebfedea0)
1 /*	$NetBSD: wc2.l,v 1.1.1.1 2009/10/26 00:28:34 christos Exp $	*/
2 
3 /* Somewhat faster "wc" tool: match more text with each rule */
4 
5 ws    [ \t]
6 nonws [^ \t\n]
7 word  {ws}*{nonws}+
8 
9 %option main noyywrap
10 %%
11 	int cc = 0, wc = 0, lc = 0;
12 
13 {word}{ws}*	cc += yyleng; ++wc;
14 {word}{ws}*\n	cc += yyleng; ++wc; ++lc;
15 
16 {ws}+		cc += yyleng;
17 
18 \n+		cc += yyleng; lc += yyleng;
19 
20 <<EOF>>		{
21 		printf( "%8d %8d %8d\n", lc, wc, cc );
22 		yyterminate();
23 		}
24