From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: Compiling Elisp to a native code with a GCC plugin Date: Wed, 15 Sep 2010 17:46:15 +0200 Message-ID: References: <87bp805ecr.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1284565606 12293 80.91.229.12 (15 Sep 2010 15:46:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Sep 2010 15:46:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 15 17:46:45 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OvuC2-00060D-Gb for ged-emacs-devel@m.gmane.org; Wed, 15 Sep 2010 17:46:42 +0200 Original-Received: from localhost ([127.0.0.1]:39168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvuC1-0000Du-MR for ged-emacs-devel@m.gmane.org; Wed, 15 Sep 2010 11:46:41 -0400 Original-Received: from [140.186.70.92] (port=37819 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvuBr-0000Cf-PO for emacs-devel@gnu.org; Wed, 15 Sep 2010 11:46:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvuBn-00010X-4o for emacs-devel@gnu.org; Wed, 15 Sep 2010 11:46:31 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:43557) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvuBm-00010P-QD for emacs-devel@gnu.org; Wed, 15 Sep 2010 11:46:27 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OvuBm-0005nt-3i for emacs-devel@gnu.org; Wed, 15 Sep 2010 17:46:26 +0200 Original-Received: from dial-181118.pool.broadband44.net ([212.46.181.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Sep 2010 17:46:26 +0200 Original-Received: from eller.helmut by dial-181118.pool.broadband44.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Sep 2010 17:46:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: dial-181118.pool.broadband44.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:Bb30KAfuumJw18Swt3jCheuD9SQ= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130217 Archived-At: * Stefan Monnier [2010-09-15 14:59] writes: >>> - The main problem with Emacs regexps right now is that they have >>> pathological cases where the match-time is enormous (potentially >>> exponential explosion in the size of the input string). To be >>> worthwhile a replacement should address this problem, which basically >>> needs it should not be based on backtracking. >> Is it possible (theoretically) to implement all of Emacs regexps without >> backtracking? In particular those with back-references (\N) seem >> problematic. Or is it necessary to recognize "optimizable" regexps >> before using a different regexp engine? > > IIRC regexps without back-refs can be matched (and searched) in O(N) > where N is the length of the input. With back-refs, I think (not sure) > the theoretical bound is O(N^2), which requires > a non-backtracking algorithm. > > So yes, we'd need to handle back-refs specially. Several regexp engines > do that already (they have a few different inner engines and choose > which one to use based on the particular regexp at hand). After googleing a bit I found this page http://swtch.com/~rsc/regexp/regexp1.html which again links to this http://perl.plover.com/NPC/NPC-3SAT.html which says that regexp matching with backreferences is NP-complete. Cox (the first page) seems to say that backtracking-with-memoization is linear time at the expense of O(N) space. Helmut