help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How are regexen implemented in Emacs?


From: Stefan Monnier
Subject: Re: How are regexen implemented in Emacs?
Date: Mon, 12 Dec 2022 14:17:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Problems.html
>>> and started to wonder if the hints there mean that Emacs has a "naive",
>>> backtracking regex engine or a FA-based one?
>> Naive!
> And what are the reasons?

Largely historical, but changing it is a lot of work with uncertain
outcome:
- Reproducing the exact behavior of the naive match with a non-naive
  match can be tricky.
- The naive approach sucks when the match fails in many
  different ways, but it's quite efficient when the match succeeds
  without any backtracking.
Ideally, we'd like to replace the regexp engine with a "standard one",
but it's not easy to find one that satisfies all the requirements
(e.g. ability to add Emacs-specific elements like \_<, \s, and \c,
ability to operate on "two-part strings" (i.e. with a gap in the
middle), ...).


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]