From: Michael Parker
Subject: [Announce] CL-AWK (Common Lisp AWK library)
Date: 
Message-ID: <038D36424A1C01F9.65E29BB8B196CA2C.A6955F3341EEC795@lp.airnews.net>
I've written a text-processing library that I call CLAWK.  It's a pretty
feature-complete implementation of AWK in common lisp, splits, matches,
etc, as well as a defawk macro that lets you write some awfully awk-ish
looking programs.

For example, here's the password-file-checker from "The AWK Programming
Language", in AWK.

    BEGIN {
        FS = ";" }
    NF != 7 {
        printf("line %d, does not have 7 fields: %s\n", NR, $0)}
    $1 ~ /[^A-Za-z0-9]/ {
        printf("line %d, nonalphanumeric user id: %s\n", NR, $0)}
    $2 == "" {
        printf("line %d, no password: %s\n", NR, $0)}
    $3 ~ /[^0-9]/ {
        printf("line %d, nonnumeric user id: %s\n", NR, $0)}
    $4 ~ /[^0-9]/ {
        printf("line %d, nonnumeric group id: %s\n", NR, $0)}
    $6 !~ /^\// {
        printf("line %d, invalid login directory: %s\n", NR, $0)}

And here's the same program written in CLAWK:

    (defawk checkpass ()
      (BEGIN
       (setq *FS* ";"))
      ((/= *NF* 7)
       (format t "~%line ~D, does not have 7 fields: ~S" *NR* $0))
      ((~ $1 #/[^A-Za-z0-9]/)
       (format t "~%line ~D, nonalphanumeric user id: ~S" *NR* $0))
      (($== $2 "")
       (format t "~%line ~D, no password: ~S" *NR* $0))
      ((~ $3 #/[^0-9]/)
       (format t "~%line ~D, nonnumeric user id: ~S" *NR* $0))
      ((~ $4 #/[^0-9]/)
       (format t "~%line ~D, nonnumeric group id: ~S" *NR* $0))
      ((!~ $6 #/^\//)
       (format t "~%line ~D, invalid login directory: ~S" *NR* $0)) )

The interesting thing about the library, from the CL point of view,
is probably the regex matcher, and the utility library that the AWK
stuff is built on, the match, split, scan, and such, since that's
all available without using the funky defawk macro.

I've been using it on my (sadly) AWK-free lispm, but I've tested it
and it works on clisp and Lispworks 4.2 as well.


at http://www.geocities.com/mparker762

From: Marco Antoniotti
Subject: Re: [Announce] CL-AWK (Common Lisp AWK library)
Date: 
Message-ID: <y6cg046vibc.fsf@octagon.mrl.nyu.edu>
Thanks.  It looks very good.

I have not checked the code thourougly yet.  However, if you do not do
fancy READTABLE tricks, CLAWK will bomb in MCL, since that
implementation uses (or at least it did) #\$ for something pathname
related.  This is why the INFIX package uses #I(..) instead of the TeXy $..$.

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: ·······@inetmi.com
Subject: Re: [Announce] CL-AWK (Common Lisp AWK library)
Date: 
Message-ID: <ur8njg6o1.fsf@chicago.inetmi.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> I have not checked the code thourougly yet.  However, if you do not
> do fancy READTABLE tricks, CLAWK will bomb in MCL, since that
> implementation uses (or at least it did) #\$ for something pathname
> related.  This is why the INFIX package uses #I(..) instead of the
> TeXy $..$.

MCL has a readmacro #$, which is used to look up the equivalent of
foreign constants from a database.

Symbols that start with $ should be fine (though the #$ macro creates
symbols whose names start with $, they are all in the CCL package).


John Wiseman
From: Marco Antoniotti
Subject: Re: [Announce] CL-AWK (Common Lisp AWK library)
Date: 
Message-ID: <y6c4rkdsbz2.fsf@octagon.mrl.nyu.edu>
·······@inetmi.com writes:

> Marco Antoniotti <·······@cs.nyu.edu> writes:
> 
> > I have not checked the code thourougly yet.  However, if you do not
> > do fancy READTABLE tricks, CLAWK will bomb in MCL, since that
> > implementation uses (or at least it did) #\$ for something pathname
> > related.  This is why the INFIX package uses #I(..) instead of the
> > TeXy $..$.
> 
> MCL has a readmacro #$, which is used to look up the equivalent of
> foreign constants from a database.
> 
> Symbols that start with $ should be fine (though the #$ macro creates
> symbols whose names start with $, they are all in the CCL package).

Oh well.  I guess they must have changed that.

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.