From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Re: multiline regex mode? Date: Sat, 25 Nov 2006 10:32:20 -0600 Message-ID: <184E9345-5926-47E0-B30E-A860A00F24E9@easesoftware.com> References: <87u00o1r9r.fsf@hans.local.net> <87lkm01b6y.fsf@hans.local.net> <6EFCA005-F27F-43D1-9005-EE8127118334@Web.DE> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: multipart/mixed; boundary="===============0253371551==" X-Trace: sea.gmane.org 1164472392 26708 80.91.229.2 (25 Nov 2006 16:33:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Nov 2006 16:33:12 +0000 (UTC) Cc: Dieter Wilhelm , GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 25 17:33:06 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 1Go0SW-0004fx-TZ for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 17:32:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Go0SW-0006xn-CP for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Nov 2006 11:32:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Go0SF-0006w5-56 for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 11:32:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Go0SE-0006vZ-FP for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 11:32:38 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Go0SE-0006vN-47 for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 11:32:38 -0500 Original-Received: from [64.192.143.210] (helo=easeserver.easesoftware.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Go0SD-0003Nd-Nz for help-gnu-emacs@gnu.org; Sat, 25 Nov 2006 11:32:38 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by easeserver.easesoftware.com (Postfix) with ESMTP id BCBE954E9FA; Sat, 25 Nov 2006 10:32:32 -0600 (CST) Original-Received: from easeserver.easesoftware.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22540-01; Sat, 25 Nov 2006 10:32:28 -0600 (CST) Original-Received: from [64.192.143.210] (easeserver.easesoftware.com [64.192.143.210]) by easeserver.easesoftware.com (Postfix) with ESMTP id A7D8554E9CD; Sat, 25 Nov 2006 10:32:28 -0600 (CST) In-Reply-To: <6EFCA005-F27F-43D1-9005-EE8127118334@Web.DE> Original-To: Peter Dyballa X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: by amavisd-new at easesoftware.net 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:38978 Archived-At: --===============0253371551== Content-Type: multipart/alternative; boundary=Apple-Mail-7--665936461 --Apple-Mail-7--665936461 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed On Nov 25, 2006, at 7:14 AM, Peter Dyballa wrote: > Am 25.11.2006 um 04:01 schrieb Dieter Wilhelm: >>> So "{[^}]*}" stands for 'a region that starts with `{=B4 and has no =20= >>> `}=B4 >>> until the final `}=B4 is hit; between both braces any number = (starting >>> with 0) of any character except `}=B4 can appear.' >> >> Thanks Peter for the hassle. Maybe I expressed myself in a confusing >> manner: The period and the character alternatives I understand. What >> I really wanted to know is where to look for a possibility of >> searching for *balanced* brackets like { { } } because I'll need this >> in my own Elisp stuff. It's clear that there is some code in Emacs >> for it (e. g. C-M-f etc.) but I have a hunch that there might be >> something else out there. Maybe a regexp extension in Perl or ... > > I think you can't use one regular expression for a variety of =20 > nested "*balanced* brackets like { { } }". Correct. For the curious: regular expressions create what is called a =20 deterministic finite automata (DFA). Also known as a state machine. =20= They can not "count" which is what you ask asking for. A simple =20 "reason" is because the count can be infinite (although that =20 explanation leaves out much). The next level up in language parsing theory is a push down automata =20 (PDA). This is, roughly speaking, a DFA coupled with a stack. The =20 stack is infinite. So, it now has the power to count. The easiest way to do a PDA in lisp is with recursive decent and a =20 rather simple lisp function can call itself when it hits a second =20 { and return when it hits a }. When the last function returns, you =20 have hit the matching } of the first {. All that aside, emacs has code written to balance parens, braces, =20 brackets, etc. You can look at forward-sexp as a starting point. =20 And, in the case of emacs, it is pretty flexible. By specifying =20 syntax tables, you can tell it what characters match each other. =20 Look at modify-syntax-entry for that piece of the puzzle. Hope this helps... Perry Smith ( pedz@easesoftware.com ) Ease Software, Inc. ( http://www.easesoftware.com ) Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems --Apple-Mail-7--665936461 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1
On Nov 25, 2006, at = 7:14 AM, Peter Dyballa wrote:
Am 25.11.2006 um 04:01 schrieb Dieter = Wilhelm:
So "{[^}]*}" stands for 'a region that starts with = `{=B4 and has no `}=B4
until the final `}=B4 is = hit; between both braces any number (starting
with 0) of any character except `}=B4 can = appear.'
Thanks Peter for the = hassle.=A0 Maybe I = expressed myself in a confusing
manner: The = period and the character alternatives I understand.=A0 What
I really wanted to know is where to look for a = possibility of
searching for *balanced* = brackets like { { } } because I'll need this
in my own Elisp stuff.=A0 It's clear that there is some = code in Emacs
for it (e. g. C-M-f etc.) but I = have a hunch that there might be
something = else out there.=A0 Maybe a = regexp extension in Perl or ...

I think = you can't use one regular expression for a variety of nested "*balanced* = brackets like { { } }".

Correct.

For the curious: = regular expressions create what is called a deterministic finite = automata (DFA).=A0 Also known as a state machine.=A0 They can not = "count" which is what you ask asking for.=A0 A simple "reason" is = because the count can be infinite (although that explanation leaves out = much).

The = next level up in language parsing theory is a push down automata (PDA).=A0= This is, roughly speaking, a DFA coupled with a stack.=A0 The stack is = infinite.=A0 So, it now has the power to count.

The easiest way to do a PDA = in lisp is with recursive decent and a rather simple lisp function can = call itself when it hits a second { and return when it hits a }.=A0 When = the last function returns, you have hit the matching } of the first = {.

All that = aside, emacs has code written to balance parens, braces, brackets, etc.=A0= You can look at forward-sexp as a starting point.=A0 And, in the case = of emacs, it is pretty flexible.=A0 By specifying syntax tables, you can = tell it what characters match each other.=A0 Look at modify-syntax-entry = for that piece of the puzzle.

Hope this = helps...

=
Perry Smith = (=A0pedz@easesoftware.com = )
Ease Software, Inc. (=A0http://www.easesoftware.com = )

Low = cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems

=

= --Apple-Mail-7--665936461-- --===============0253371551== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0253371551==--