[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fixing ill-conditioned regular expressions. Proof of concept.
From: |
Alan Mackenzie |
Subject: |
Re: Fixing ill-conditioned regular expressions. Proof of concept. |
Date: |
Thu, 26 Feb 2015 20:01:08 +0000 |
User-agent: |
Mutt/1.5.22 (2013-10-16) |
Hello, Stefan.
On Thu, Feb 26, 2015 at 02:12:32PM -0500, Stefan Monnier wrote:
> >> > 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 \(\).
I really did mean R*\(\)R*, with R being the same on both sides of the
\(\), but the *s possibly being +s. _That_ is nasty and undefined.
> > 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.
OK.
> > 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.
Thanks. I'll continue working on it, adding a decent set of test cases
too.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Fixing ill-conditioned regular expressions. Proof of concept., (continued)
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Paul Eggert, 2015/02/23
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Alan Mackenzie, 2015/02/25
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Stephen J. Turnbull, 2015/02/25
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Paul Eggert, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Alan Mackenzie, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Tassilo Horn, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Alan Mackenzie, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Stefan Monnier, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Alan Mackenzie, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Stefan Monnier, 2015/02/26
- Re: Fixing ill-conditioned regular expressions. Proof of concept.,
Alan Mackenzie <=
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Stefan Monnier, 2015/02/27
- Re: Fixing ill-conditioned regular expressions. Proof of concept., Stefan Monnier, 2015/02/24
Re: Fixing ill-conditioned regular expressions. Proof of concept., Philipp Stephani, 2015/02/24