From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: Paul Eggert <eggert@cs.ucla.edu>, emacs-devel@gnu.org
Subject: Re: Fixing ill-conditioned regular expressions. Proof of concept.
Date: Thu, 26 Feb 2015 14:12:32 -0500 [thread overview]
Message-ID: <jwvzj80ebps.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20150226162119.GD19320@acm.fritz.box> (Alan Mackenzie's message of "Thu, 26 Feb 2015 16:21:19 +0000")
>> > R*\(\)R*
>> > , but anybody who writes such regexps deserves what she gets.
>> What is it that I deserve to get?
> You deserve, perhaps, to lose (match-beginning 1) and (match-end 1),
> which were ill-defined anyway.
Why do you think so? They seem perfectly well-defined to me.
They're just always equal to one another, of course, but to the extent
that the regexp syntax only forces me to put "named positions" in pairs,
if I need a single position, it's fairly natural to just use \(\).
> Have you really written a regexp like this (apart from for testing
> purposes)?. If so, what's it for?
grep '\\\\(\\\\)' **/*.el
finds 27 matches. Taking one example from the list:
lisp/emacs-lisp/smie.el: ((looking-at "\\s(\\|\\s)\\(\\)")
what this does is to let me use (match-beginning 1) to figure out which
of the two alternatives was matched. I could have written this as
((looking-at "\\s(\\|\\(\\s)\\)")
but this would be (marginally) slower, because we'd always push
a "group-start" marker before try to match "\\s)", whereas with the
other rule, we only do that when we know "\\s)" has matched.
> By the way, how do you see the prospects of this file becoming
> incorporated into Emacs at some stage?
To be honest, I haven't looked at it at all, yet.
The vague understanding I have of what it might be sounds interesting.
It's just a patch trying to cover up the worst aspects of the
current regexp engine, but since there doesn't seem to be much interest
in improving/overhauling the regexp engine, maybe it's a good stop-gap.
Stefan
next prev parent reply other threads:[~2015-02-26 19:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-23 18:12 Fixing ill-conditioned regular expressions. Proof of concept Alan Mackenzie
2015-02-23 19:55 ` Paul Eggert
2015-02-23 20:21 ` Alan Mackenzie
2015-02-23 22:19 ` Paul Eggert
2015-02-23 22:42 ` Alan Mackenzie
2015-02-23 23:07 ` Artur Malabarba
2015-02-23 23:37 ` Paul Eggert
2015-02-25 10:08 ` Alan Mackenzie
2015-02-26 1:11 ` Stephen J. Turnbull
2015-02-26 8:46 ` Paul Eggert
2015-02-26 10:11 ` Alan Mackenzie
2015-02-26 11:05 ` Tassilo Horn
2015-02-26 13:09 ` Alan Mackenzie
2015-02-26 13:46 ` Stefan Monnier
2015-02-26 16:21 ` Alan Mackenzie
2015-02-26 19:12 ` Stefan Monnier [this message]
2015-02-26 20:01 ` Alan Mackenzie
2015-02-27 13:45 ` Stefan Monnier
2015-02-24 16:29 ` Stefan Monnier
2015-02-24 6:20 ` Philipp Stephani
2015-03-13 22:53 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvzj80ebps.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=acm@muc.de \
--cc=eggert@cs.ucla.edu \
--cc=emacs-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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.