From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Ihor Radchenko <yantar92@posteo.net>
Newsgroups: gmane.emacs.bugs
Subject: bug#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in
 search.c)
Date: Thu, 04 May 2023 12:58:13 +0000
Message-ID: <875y98jlsq.fsf@localhost>
References: <63882A45-BD02-40D5-92FA-70175267BA3B@acm.org>
 <874jou7lsf.fsf@localhost>
 <37EED5F9-F1FE-46B6-B4FA-0B268B945123@gmail.com>
 <87wn1qqvj0.fsf@localhost>
 <34F4849A-CB39-4C96-9CC1-11ED723706DA@gmail.com>
 <87wn1psqny.fsf@localhost>
 <6DAF37F9-B236-4C33-8E30-0FCA47CCBCC5@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="38061"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 63225@debbugs.gnu.org
To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= <mattias.engdegard@gmail.com>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 04 14:56:33 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1puYVd-0009hi-EF
	for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 May 2023 14:56:33 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1puYVK-0008Cj-04; Thu, 04 May 2023 08:56:14 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1puYVF-0008CI-TW
 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 08:56:10 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1puYV7-0006nC-TX
 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 08:56:08 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1puYV7-0002t8-OA
 for bug-gnu-emacs@gnu.org; Thu, 04 May 2023 08:56:01 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Ihor Radchenko <yantar92@posteo.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Thu, 04 May 2023 12:56:01 +0000
Resent-Message-ID: <handler.63225.B63225.168320491010825@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 63225
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
Original-Received: via spool by 63225-submit@debbugs.gnu.org id=B63225.168320491010825
 (code B ref 63225); Thu, 04 May 2023 12:56:01 +0000
Original-Received: (at 63225) by debbugs.gnu.org; 4 May 2023 12:55:10 +0000
Original-Received: from localhost ([127.0.0.1]:48798 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1puYUH-0002oV-FI
 for submit@debbugs.gnu.org; Thu, 04 May 2023 08:55:09 -0400
Original-Received: from mout01.posteo.de ([185.67.36.65]:37889)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@posteo.net>) id 1puYUF-0002nb-Ro
 for 63225@debbugs.gnu.org; Thu, 04 May 2023 08:55:08 -0400
Original-Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id ADE2B2403CD
 for <63225@debbugs.gnu.org>; Thu,  4 May 2023 14:55:01 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1683204901; bh=/ICKVeAnMkZfkbdWTYlnhHqAn8ALp+Zs4befplYSwkk=;
 h=From:To:Cc:Subject:Date:From;
 b=FZfGOiBNbd0MLZxndErWvRBGaRPpgFqmyhRBf3cpUUjBxty42W5Kirob+EtGEmfxM
 z0GJn43N6tMohcGzlnuwI9qYhJ4CC+rWFd5Z/pDKGb2LGo9b/I9Mufp948cNwZXJc9
 kylhjHYGa7gRuWOvL+NAdZ6Y7yXuCSmzxfCpuxFuSpvGYr7mLGSuqIPJmm4265gwim
 DHZUFFUjz3fNTABR99wTgkR2HEWK12JeCzvHv7VVWIpTOOD5m9BIinfS7I6zbhD3sv
 o6PcXBSfuebA1p5gtL/Wa9x1W7gPESXwjRnQAKAGRqtiiLkfJNHyslPfUHFFdtOF7B
 lQbRWsd4F9VZQ==
Original-Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4QBv106kxQz6twC;
 Thu,  4 May 2023 14:55:00 +0200 (CEST)
In-Reply-To: <6DAF37F9-B236-4C33-8E30-0FCA47CCBCC5@gmail.com>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:261013
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/261013>

Mattias Engdeg=C3=A5rd <mattias.engdegard@gmail.com> writes:

>> Ideally, the compiler should do something similar to
>> what https://www.colm.net/open-source/ragel/ does.
>
> Yes, constructing a DFA would be more realistic when it's less in danger =
of being thrown away at any time.

I tried to look closer into regex-emacs.c and I note that the regexp
compiler basically generates a specialized bytecode to be executed by
regexp matcher later.

So, may the existing vector type be reused to store compiled regexp
pattern objects?

AFIU, pvec_type will need to have one more item and reader/printer will
need to be modified for a specialized print representation. The compiled
regexp itself will be stored as unibyte string, containing the
instructions.

This will also open a possibility to compile regexp patterns from Elisp,
if necessary.

--=20
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>