File: wc2.l

package info (click to toggle)
flex-old 2.5.4a-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 2,868 kB
  • ctags: 1,162
  • sloc: ansic: 8,226; sh: 2,770; lex: 1,095; yacc: 605; makefile: 366; awk: 72; sed: 12
file content (20 lines) | stat: -rw-r--r-- 348 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Somewhat faster "wc" tool: match more text with each rule */

ws    [ \t]
nonws [^ \t\n]
word  {ws}*{nonws}+

%%
	int cc = 0, wc = 0, lc = 0;

{word}{ws}*	cc += yyleng; ++wc;
{word}{ws}*\n	cc += yyleng; ++wc; ++lc;

{ws}+		cc += yyleng;

\n+		cc += yyleng; lc += yyleng;

<<EOF>>		{
		printf( "%8d %8d %8d\n", lc, wc, cc );
		yyterminate();
		}