home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / flex-2.4.7-src.lha / GNU / src / amiga / flex-2.4.7 / MISC / fastwc / wc2.l < prev    next >
Encoding:
Text File  |  1993-07-23  |  348 b   |  21 lines

  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. %%
  8.     int cc = 0, wc = 0, lc = 0;
  9.  
  10. {word}{ws}*    cc += yyleng; ++wc;
  11. {word}{ws}*\n    cc += yyleng; ++wc; ++lc;
  12.  
  13. {ws}+        cc += yyleng;
  14.  
  15. \n+        cc += yyleng; lc += yyleng;
  16.  
  17. <<EOF>>        {
  18.         printf( "%8d %8d %8d\n", lc, wc, cc );
  19.         yyterminate();
  20.         }
  21.