From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Nordl=F6w?= Newsgroups: gmane.emacs.help Subject: Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching Date: Tue, 2 Nov 2010 01:24:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <59d13ede-9f6e-4dcb-8826-fae2a178c8d7@32g2000yqz.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291879286 13901 80.91.229.12 (9 Dec 2010 07:21:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 07:21:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 08:21:22 2010 Return-path: Envelope-to: geh-help-gnu-emacs@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 1PQaob-0003Bp-TS for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 08:21:22 +0100 Original-Received: from localhost ([127.0.0.1]:43115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQaob-0005Ck-4O for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 02:21:21 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!32g2000yqz.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: 150.227.15.253 Original-X-Trace: posting.google.com 1288686270 2514 127.0.0.1 (2 Nov 2010 08:24:30 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 2 Nov 2010 08:24:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 32g2000yqz.googlegroups.com; posting-host=150.227.15.253; posting-account=ytJKAgoAAAA1tg4ScoRszebXiIldA5vg User-Agent: G2/1.0 X-HTTP-Via: 1.1 ip1-w.foi.se:8080 (IronPort-WSA/6.3.5-015) X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Ubuntu/10.10 Chromium/9.0.570.0 Chrome/9.0.570.0 Safari/534.11, gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:182153 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76820 Archived-At: I have a suggestion for an improvement of the Emacs's pattern matching capabilities using an extra flag to re-search-forward/backward which I think should be called TREE-MATCH/FLAG. This flags makes patterns like for example \( \( RE1? \) \( RE2? \) \) result in the match-data: (1 3 (MD1) (MD2) #) instead of (1 3 MD1 MD2 #) where MD1/2 are the match-data for RE2/RE2 respetively. That is for each level of match-parens we create a sub-list containing possible BEG-END values and in the end delete sub-lists containing no BEG-END-pairs. This enables us to pack sets of different regular expressions into one unified regexp without knowing their individual structure (number of sub-matchers etc) send them to re-search-f/b and alikes and then traverse the combined result in a standard way. This is not possible today because we cannot in the general case know which BEG-END pairs belongs to which matcher. For example font-locking and language-parsing would be greatly enhance with this extension which I guess would not be that much work to implement. The tree structure is already present in regular expression which I guess is parsed into some expression tree (AST) before being used. Comments on that? /Per Nordl=F6w