BSD 4_4_Lite1 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Thu, 22 Jul 1993 14:01:44 +0000 (06:01 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Thu, 22 Jul 1993 14:01:44 +0000 (06:01 -0800)
Work on file usr/src/contrib/flex-2.4.6/MISC/fastwc/wc1.l
Work on file usr/src/contrib/flex-2.4.6/MISC/fastwc/wc2.l
Work on file usr/src/contrib/flex-2.4.6/MISC/fastwc/wc3.l

Synthesized-from: CSRG/cd2/4.4BSD-Lite1

usr/src/contrib/flex-2.4.6/MISC/fastwc/wc1.l [new file with mode: 0644]
usr/src/contrib/flex-2.4.6/MISC/fastwc/wc2.l [new file with mode: 0644]
usr/src/contrib/flex-2.4.6/MISC/fastwc/wc3.l [new file with mode: 0644]

diff --git a/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc1.l b/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc1.l
new file mode 100644 (file)
index 0000000..d6696bc
--- /dev/null
@@ -0,0 +1,18 @@
+/* First cut at a flex-based "wc" tool. */
+
+ws    [ \t]
+nonws [^ \t\n]
+
+%%
+       int cc = 0, wc = 0, lc = 0;
+
+{nonws}+       cc += yyleng; ++wc;
+
+{ws}+          cc += yyleng;
+
+\n             ++lc; ++cc;
+
+<<EOF>>                {
+               printf( "%8d %8d %8d\n", lc, wc, cc );
+               yyterminate();
+               }
diff --git a/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc2.l b/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc2.l
new file mode 100644 (file)
index 0000000..bd63cd4
--- /dev/null
@@ -0,0 +1,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();
+               }
diff --git a/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc3.l b/usr/src/contrib/flex-2.4.6/MISC/fastwc/wc3.l
new file mode 100644 (file)
index 0000000..7c5f2e2
--- /dev/null
@@ -0,0 +1,24 @@
+/* Somewhat faster still: potentially match a lot of text with each rule */
+
+ws    [ \t]
+nonws [^ \t\n]
+word  {ws}*{nonws}+
+words {word}{ws}+
+
+%%
+       int cc = 0, wc = 0, lc = 0;
+
+{word}{ws}*            cc += yyleng; ++wc;
+{word}{ws}*\n          cc += yyleng; ++wc; ++lc;
+{words}{word}{ws}*     cc += yyleng; wc += 2;
+{words}{2}{word}{ws}*  cc += yyleng; wc += 3;
+{words}{3}{word}{ws}*  cc += yyleng; wc += 4;
+
+{ws}+                  cc += yyleng;
+
+\n+                    cc += yyleng; lc += yyleng;
+
+<<EOF>>                {
+               printf( "%8d %8d %8d\n", lc, wc, cc );
+               yyterminate();
+               }