etc/services - sync with NetBSD-8
[minix.git] / external / bsd / flex / dist / examples / fastwc / wc4.l
blob90c36eed2cc48cc30f7a069d6d5c1467c7029b04
1 /* Fastest version of wc: add rules to pick up newlines, too */
3 ws    [ \t]
4 nonws [^ \t\n]
5 word  {ws}*{nonws}+
6 words {word}{ws}+
8 %option main noyywrap
9 %%
10         int cc = 0, wc = 0, lc = 0;
12 {word}{ws}*             ++wc; cc += yyleng;
13 {word}{ws}*\n           ++wc; cc += yyleng; ++lc;
14 {words}{word}{ws}*      wc += 2; cc += yyleng;
15 {words}{word}{ws}*\n    wc += 2; cc += yyleng; ++lc;
16 {words}{2}{word}{ws}*   wc += 3; cc += yyleng;
17 {words}{2}{word}{ws}*\n wc += 3; cc += yyleng; ++lc;
18 {words}{3}{word}{ws}*   wc += 4; cc += yyleng;
19 {words}{3}{word}{ws}*\n wc += 4; cc += yyleng; ++lc;
21 {ws}+                   cc += yyleng;
23 \n+                     cc += yyleng; lc += yyleng;
25 <<EOF>>         {
26                 printf( "%8d %8d %8d\n", lc, wc, cc );
27                 yyterminate();
28                 }