source:
trunk/flex/examples/fastwc/wc2.l@
3039
| Last change on this file since 3039 was 3031, checked in by , 18 years ago | |
|---|---|
| File size: 370 bytes | |
| Line | |
|---|---|
| 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 | } |
Note:
See TracBrowser
for help on using the repository browser.
