xref: /minix/external/bsd/flex/dist/examples/fastwc/wc1.l (revision 0a6a1f1d)
1 /* First cut at a flex-based "wc" tool. */
2 
3 ws    [ \t]
4 nonws [^ \t\n]
5 
6 %option main noyywrap
7 %%
8 	int cc = 0, wc = 0, lc = 0;
9 
10 {nonws}+	cc += yyleng; ++wc;
11 
12 {ws}+		cc += yyleng;
13 
14 \n		++lc; ++cc;
15 
16 <<EOF>>		{
17 		printf( "%8d %8d %8d\n", lc, wc, cc );
18 		yyterminate();
19 		}
20