From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harald Hanche-Olsen Newsgroups: gmane.emacs.help Subject: Re: multiline regex mode? Date: Sat, 25 Nov 2006 15:11:14 +0100 Organization: Norwegian university of science and technology Message-ID: References: <87u00o1r9r.fsf@hans.local.net> <87lkm01b6y.fsf@hans.local.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1164465685 8366 80.91.229.2 (25 Nov 2006 14:41:25 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Nov 2006 14:41:25 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 25 15:41:21 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GnyiH-0006mB-Fe for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 15:41:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GnyiH-0001Vi-1q for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 09:41:05 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!ntnu.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: fiinbeck.math.ntnu.no Original-X-Trace: orkan.itea.ntnu.no 1164462051 29697 129.241.15.140 (25 Nov 2006 13:40:51 GMT) Original-X-Complaints-To: usenet@itea.ntnu.no Original-NNTP-Posting-Date: Sat, 25 Nov 2006 13:40:51 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (berkeley-unix) Cancel-Lock: sha1:NL0A3pHVuJdXMPf815pUH6OcdiU= Original-Xref: shelby.stanford.edu gnu.emacs.help:143360 Original-To: help-gnu-emacs@gnu.org 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:38976 Archived-At: + Peter Dyballa : | I think you can't use one regular expression for a variety of nested | "*balanced* brackets like { { } }". You think rightly. In formal language theory, the regular languages are precisely the ones that can be defined by regular grammars. It is a theorem that they are precisely the languages that can be recognized by a finite state automaton (FSA). A regular expression is a way of specifying a regular grammar, i.e., a regular language, and so they are not powerful enough to recognize balanced parentheses. The reason is that you need to be able to count arbitrarily high, in order to be able to tell the difference between expressions like {{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}} and {{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}. A FSA with fifteen states cannot tell the difference between the two expressions above, since it would need to be able to count to sixteen in order to do so. So the paren mathcing algorithms in emacs need to be written in code. And indeed it is: At the bottom you'll find the function scan-sexps, which is written in C (for efficiency, no doubt). See also: http://en.wikipedia.org/wiki/Regular_grammar -- * Harald Hanche-Olsen - It is undesirable to believe a proposition when there is no ground whatsoever for supposing it is true. -- Bertrand Russell