Hi Andrei,

> Now I'm seeking a regexp library for picolisp.

Speaking of myself, I never felt the need for a full-blown regexp
library, because I find the built-in 'match' function quite flexible,
especially in combination with other list functions.

To employ true regular expressions in PicoLisp, however, I would simply
write a glue function to the GNU regexp library. I haven't investigated
that library yet, but once wrote something similar (though probably more
primitive) for the 'fnmatch' function (file name matching).

To try it, put the following into a file "fnMatch.l":

################################################################
(load "lib/gcc.l")
(gcc "util" NIL 'fnMatch)

#include <fnmatch.h>

any fnMatch(any ex) {
   any x;

   x = evSym(cdr(ex));
   {
      char pat[bufSize(x)];

      bufString(x, pat);
      x = evSym(cddr(ex));
      {
         char str[bufSize(x)];

         bufString(x, str);
         return fnmatch(pat, str, 0)? Nil : T;
      }
   }
}
/**/
################################################################

You can test it as:

   $ ./p dbg.l fnMatch.l
   : (fnMatch "foo*.c" "foobar.c")
   -> T
   : (fnMatch "foo*.c" "bar.c")   
   -> NIL


In an analog way it should be possible to interface to the GNU regexp
library.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to