From: Kent M Pitman
Subject: Re: regular expressions
Date: 
Message-ID: <sfw4t5shw0h.fsf@world.std.com>
SDS <···········@cctrading.com> writes:

> What is the reason of absence of the regular expression matching from
> LISP (not mentioned in either CLtL2 or CLHS) ? Even C has it :-) 
> (and scheme too!).

I'll spare you my standard lecture about asking "why" questions and
expecting a technical answer.  (Short form: Learn to expect political
answers.)  The fact is that regular expressions were not an entrenched
part of the Lisp culture at the time of CLTL.

I've used them since and agree they should be there.  They're already
on my list of things to agitate for if/when we do another round of
featurism.  But then, I can tell you, some people oppose all new
featurism as a matter of course and say new things like that should
appear in libraries which you are already free yourself to make.  A
third group will like extensions but won't want "another stupid little
special purpose language like FORMAT and LOOP" (although they will be
met by another group who thinks those little special purpose languages
were wonderful and we should do more of them).  So it will depend how
many of kind X and how many of kind Y and how many of kind Z are in
the room at the time.  And the true answer next time around will be
the same as it is now: "arbitrary headcount" since all of those
positions are entirely defensible and it comes down to a matter of
pure personal opinion.

Btw, I don't think Scheme (the language standard) does have it.  Maybe
there exist scheme implementations that do.  But for all I know, there
are CL implementations that do.  I'm on the Scheme "authors" committee,
too, and we can barely ever agree on "hard" questions like whether
 (define (foo x) x)
is an acceptable shorthand for
 (define foo (lambda (x) x))
or if it will clutter the language too much.  Scheme design is HIGHLY
biased away from anything that could remotely be called "featurism"
and while stable is also ... uh, ... spartan in the comfort it offers
programmers.  I guess I could go look and see if I'm wrong and regexps
were added while I wasn't looking, but honestly I absolutely can't
imagine regular expressions in Scheme before the heat death of the
universe (which might indeed be partially precipitated by a lengthy
discussion of the merits of such a thing).  If someone thinks I'm
wrong and it's really in the Scheme standard, tell me where and I'll
go check.  Don't want to be passing out misinformation on this.

From: Kelly Murray
Subject: Re: regular expressions
Date: 
Message-ID: <nmzpnj6c3g.fsf@bell.i-have-a-misconfigured-system-so-shoot-me>
> > What is the reason of absence of the regular expression matching from
> > LISP (not mentioned in either CLtL2 or CLHS) ? Even C has it :-) 
> > (and scheme too!).

> I'll spare you my standard lecture about asking "why" questions and
> expecting a technical answer.  (Short form: Learn to expect political
> answers.)  The fact is that regular expressions were not an entrenched
> part of the Lisp culture at the time of CLTL.

I don't see much reason to include it in the language per se.
It's just a library function right?  and current conventional wisdom
is such things should be left in "libraries".

For ACL, John Foderaro at Franz has an implemention,
the binary (and documentation) is available on our ftp site.
It's basically defines two additional functions #'match-regexp,
and #'compile-regexp.
It is used often for my webserver work.  Actually, I defined a function
"pattern-match", that does unix filename "globbing"
instead of regexp matching:

BTW, #'concat and #'strsubst are my utility functions.

(defun pattern-match (pattern string)
  (match-regexp
   (or (gethash pattern *pattern-cache*)
       (setf (gethash pattern *pattern-cache*)
	     (compile-regexp (pattern-to-regexp pattern))))
   string))

(defun pattern-to-regexp (pattern)
  (concat
   "^"  ;; must match at start
   (strsubst ".*" "*"
    (strsubst ".+" "?"
     (strsubst "\\." "." pattern)))
   "$" ;; must match at end too  (consume whole string)
  ))


The regexp matcher is just the kind of thing Lisp folks need to write.
It'll just be there if you want/need it, no standard committee to
hassle with..

(Frankly, I don't know why Franz doesn't release the sources (uh oh ;)
for these things, but that's what can happen if the community
at large isn't contributing these kind of useful utilities.)

-Kelly Murray  ···@franz.com
From: Sunil Mishra
Subject: Re: regular expressions
Date: 
Message-ID: <efy200vxx8r.fsf@cleon.cc.gatech.edu>
In article <··············@bell.i-have-a-misconfigured-system-so-shoot-me> Kelly Murray <···@franz.com> writes:

   > > What is the reason of absence of the regular expression matching from
   > > LISP (not mentioned in either CLtL2 or CLHS) ? Even C has it :-) 
   > > (and scheme too!).

   > I'll spare you my standard lecture about asking "why" questions and
   > expecting a technical answer.  (Short form: Learn to expect political
   > answers.)  The fact is that regular expressions were not an entrenched
   > part of the Lisp culture at the time of CLTL.

   I don't see much reason to include it in the language per se.
   It's just a library function right?  and current conventional wisdom
   is such things should be left in "libraries".

   For ACL, John Foderaro at Franz has an implemention,
   the binary (and documentation) is available on our ftp site.
   It's basically defines two additional functions #'match-regexp,
   and #'compile-regexp.
   It is used often for my webserver work.  Actually, I defined a function
   "pattern-match", that does unix filename "globbing"
   instead of regexp matching:

   BTW, #'concat and #'strsubst are my utility functions.

   (defun pattern-match (pattern string)
     (match-regexp
      (or (gethash pattern *pattern-cache*)
	  (setf (gethash pattern *pattern-cache*)
		(compile-regexp (pattern-to-regexp pattern))))
      string))

   (defun pattern-to-regexp (pattern)
     (concat
      "^"  ;; must match at start
      (strsubst ".*" "*"
       (strsubst ".+" "?"
	(strsubst "\\." "." pattern)))
      "$" ;; must match at end too  (consume whole string)
     ))


   The regexp matcher is just the kind of thing Lisp folks need to write.
   It'll just be there if you want/need it, no standard committee to
   hassle with..

   (Frankly, I don't know why Franz doesn't release the sources (uh oh ;)
   for these things, but that's what can happen if the community
   at large isn't contributing these kind of useful utilities.)

   -Kelly Murray  ···@franz.com

Also on the digitool ftp site (ftp.digitool.com) in the contributions sits
a regular expression matcher. It's quite new, and being maintained. I have
played with it only a little, and it seems quite powerful, offering fairly
extensive syntax and expression compilation. I don't think it's mac
specific, but I can't be sure.

What I'd like is a Flex like parser generator... I'd write one if I knew
how.

Sunil
From: Raymond Toy
Subject: Re: regular expressions
Date: 
Message-ID: <4nen4v2u1i.fsf@rtp.ericsson.se>
·······@cleon.cc.gatech.edu (Sunil Mishra) writes:

> 
> What I'd like is a Flex like parser generator... I'd write one if I knew
> how.

Do you want Flex as a lexer or yacc as a parser generator?

If the latter, there is zebu, a parser generator for Lisp.  Check the
CMU archives for an old version.

Ray
From: Sunil Mishra
Subject: Re: regular expressions
Date: 
Message-ID: <efybtzxrj9h.fsf@zebulon.cc.gatech.edu>
In article <··············@rtp.ericsson.se> Raymond Toy <·····@rtp.ericsson.se> writes:

   ·······@cleon.cc.gatech.edu (Sunil Mishra) writes:

   > 
   > What I'd like is a Flex like parser generator... I'd write one if I knew
   > how.

   Do you want Flex as a lexer or yacc as a parser generator?

   If the latter, there is zebu, a parser generator for Lisp.  Check the
   CMU archives for an old version.

   Ray

Woops! Sorry for the mixup :-)

Lexer is what I need.

Sunil
From: Sudhir Shenoy
Subject: Re: regular expressions
Date: 
Message-ID: <sshenoy-0711970906480001@ts900-15520.singnet.com.sg>
In article <···············@cleon.cc.gatech.edu>,
·······@cleon.cc.gatech.edu (Sunil Mishra) wrote:

> 
> Also on the digitool ftp site (ftp.digitool.com) in the contributions sits
> a regular expression matcher. It's quite new, and being maintained. I have
> played with it only a little, and it seems quite powerful, offering fairly
> extensive syntax and expression compilation. I don't think it's mac
> specific, but I can't be sure.
> 

No it isn't Mac specific. It does not compile under ACL for windows however
because ACL doesn't define character constants like #\Null which MCL does.
I tested it under CMUCL and there were no problems.

As the author, I'd like to say that I am not _really_ actively maintaining it.
It fits my needs at present and I haven't had any requests for improvements
or bug fixes yet :-) The only thing someone wanted was a tarred gzipped
version instead of the stuffit archive on the digitool site. This is available
on request (just email me).

Sudhir
From: Tim Bradshaw
Subject: Re: regular expressions
Date: 
Message-ID: <ey367q74bl4.fsf@eigg.aiai.ed.ac.uk>
This is kind of at a slight tangent, but does anyone know if there is
anything written about using a more sensible (in a lisp context) syntax
for regexps?  I've used various extensions (and even I think
implemented one for elk at some point) which make use of some variant
of Unix regexps, but they're really horrid in a Lisp context. I'm
thinking of something like:

	(seq (? (or "foo" "bar")) "burble")

instead of "(foo|bar)?burble".  It would just be so much easier to
manipulate & construct them like that (and one could compile it down
to the stringy version if need be reasonably trivially).

--tim
From: Raymond Toy
Subject: Re: regular expressions
Date: 
Message-ID: <4ng1pb2u4c.fsf@rtp.ericsson.se>
Tim Bradshaw <···@aiai.ed.ac.uk> writes:

> This is kind of at a slight tangent, but does anyone know if there is
> anything written about using a more sensible (in a lisp context) syntax
> for regexps?  I've used various extensions (and even I think
> implemented one for elk at some point) which make use of some variant
> of Unix regexps, but they're really horrid in a Lisp context. I'm
> thinking of something like:
> 
> 	(seq (? (or "foo" "bar")) "burble")
> 
> instead of "(foo|bar)?burble".  It would just be so much easier to
> manipulate & construct them like that (and one could compile it down
> to the stringy version if need be reasonably trivially).
> 

Not specifically for Lisp, but I believe scsh has this kind of regexp
syntax for Scheme.

Maybe it would be easy to convert to Lisp? 

Ray
From: Emergent Technologies
Subject: Re: regular expressions
Date: 
Message-ID: <uwwimt1h0.fsf@cape.com>
Tim Bradshaw <···@aiai.ed.ac.uk> writes:

> This is kind of at a slight tangent, but does anyone know if there is
> anything written about using a more sensible (in a lisp context) syntax
> for regexps?  

You should take a peek at Henry Baker's paper on the META pattern matcher.