unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Bruce Korb <bkorb@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: Fwd: Emacs-like file buffers
Date: Sun, 14 May 2006 07:58:21 -0700	[thread overview]
Message-ID: <4467458D.7010402@gnu.org> (raw)
In-Reply-To: <9c4a82e00605131827h16d7dad5l59848987406707b1@mail.gmail.com>

Jason Meade wrote:
> Is there a standard for regular expressions somewhere?

"a standard"?  No.  "are standards"?  Yes.  Many.  Naturally,
that is the problem.

> It seems like
> most implements (from grep through tcl, perl, and beyond) seem to
> agree on simple stuff like ^[a-c]?002*[^b]+$ etc... (not all
> understand ? and + I've noticed....) but very few seem to share an
> affinity for \w or \< ... \> etcetera.
> 
> I don't use regular expressions (outside of grep) everyday, but when I
> do use them, it's usually for some serious pattern matching, with
> variable capture (via $1, or \#1 etc). I'm starting to incorporate
> search-forward and search-backwards into my filebuffer lib. For that
> kind of work, even strchr will work (sorta. binary data is a problem).
> However, eventually I'll want to be able to regex my buffers, and once
> I add the guile hooks, it would be nice to share the same regex syntax
> with everyone else. After all, the last thing you want is to load a
> module, only to find that it's not syntax compatible with the rest of
> the language!

The most comprehensible and still useful thing would be to provide
a "regcomp" funtion that had a usable implementation of the REG_BASIC
flag and, perhaps, added such tweaks as REG_PERL et al.  The reason
I said, "usable implementation" is because in my implementation of
regexec(3C), REG_BASIC is not defined so there is no way to tell
the regex compiler that I want a basic re.  SO, into the guile.h
family of headers, add:

   #ifndef REG_BASIC
   #  define GUILE_REG_BASIC   0x10000
   #else
   #  define GUILE_REG_BASIC   REG_BASIC
   #endif

then overload "make-regexp" and "regexp-exec" to cope with this and
"I'd-rather-use-Perl-syntax" flags.  Or even a "I-want-fnmatch-
style-globbing" match flag.  It brings all the pattern matching
stuff together making it findable (very important in a huge interface)
and relatively easy to use (i.e. remember).  :)  That's my nickel.

Cheers - Bruce

P.S. one thing missing from the ice-9 regex functions seems to be a way
to pass such flags through to the implementing libguile functions.
Perhaps I just missed how to do it?

(define (string-match pattern str . args)
   (let ((rx (make-regexp pattern))
         (start (if (pair? args) (car args) 0)))
     (regexp-exec rx str start)))


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2006-05-14 14:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-07  7:18 Emacs-like file buffers Jason Meade
2006-05-07 19:02 ` Rob Browning
2006-05-08 23:42   ` Kevin Ryde
2006-05-09  0:50     ` Rob Browning
2006-05-13  1:55       ` Kevin Ryde
2006-05-13  4:08         ` Rob Browning
     [not found]           ` <9c4a82e00605122309g6f3e061etd702479d88664b96@mail.gmail.com>
     [not found]             ` <87ejyx37af.fsf@trouble.defaultvalue.org>
     [not found]               ` <9c4a82e00605131824v23a934dah1404210beb57e1b3@mail.gmail.com>
2006-05-14  1:27                 ` Fwd: " Jason Meade
2006-05-14 14:58                   ` Bruce Korb [this message]
2006-05-14 22:34                     ` Kevin Ryde
2006-05-14 22:11                   ` Kevin Ryde
2006-05-19 12:12                   ` Regular expressions Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4467458D.7010402@gnu.org \
    --to=bkorb@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).