all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Perry Smith <pedz@easesoftware.com>
Cc: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>,
	GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: multiline regex mode?
Date: Sat, 25 Nov 2006 10:32:20 -0600	[thread overview]
Message-ID: <184E9345-5926-47E0-B30E-A860A00F24E9@easesoftware.com> (raw)
In-Reply-To: <6EFCA005-F27F-43D1-9005-EE8127118334@Web.DE>


[-- Attachment #1.1: Type: text/plain, Size: 2232 bytes --]

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 `{´ and has no  
>>> `}´
>>> until the final `}´ is hit; between both braces any number (starting
>>> with 0) of any character except `}´ 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  
> nested "*balanced* brackets like { { } }".

Correct.

For the curious: regular expressions create what is called a  
deterministic finite automata (DFA).  Also known as a state machine.   
They can not "count" which is what you ask asking for.  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).  This is, roughly speaking, a DFA coupled with a stack.  The  
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  
rather simple lisp function can call itself when it hits a second  
{ and return when it hits a }.  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.  You can look at forward-sexp as a starting point.   
And, in the case of emacs, it is pretty flexible.  By specifying  
syntax tables, you can tell it what characters match each other.   
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



[-- Attachment #1.2: Type: text/html, Size: 7748 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

  reply	other threads:[~2006-11-25 16:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-09 12:57 multiline regex mode? Giles Chamberlin
2006-10-13 20:02 ` Dieter Wilhelm
     [not found] ` <mailman.8131.1160774366.9609.help-gnu-emacs@gnu.org>
2006-10-16 10:20   ` Giles Chamberlin
2006-10-16 11:24     ` Michaël Cadilhac
     [not found]     ` <mailman.8206.1160997864.9609.help-gnu-emacs@gnu.org>
2006-10-16 15:42       ` Giles Chamberlin
2006-11-23 19:25 ` Stefan Monnier
2006-11-24 21:14   ` Dieter Wilhelm
2006-11-24 22:51     ` Peter Dyballa
2006-11-25  3:01       ` Dieter Wilhelm
2006-11-25 13:14         ` Peter Dyballa
2006-11-25 16:32           ` Perry Smith [this message]
2006-11-25 18:33             ` Dieter Wilhelm
     [not found]           ` <mailman.1100.1164472360.2155.help-gnu-emacs@gnu.org>
2006-11-25 17:23             ` [OT] " Harald Hanche-Olsen
     [not found]         ` <mailman.1092.1164460454.2155.help-gnu-emacs@gnu.org>
2006-11-25 14:11           ` Harald Hanche-Olsen
2006-11-25 18:27             ` Dieter Wilhelm
     [not found]             ` <mailman.1107.1164479289.2155.help-gnu-emacs@gnu.org>
2006-11-25 19:29               ` Harald Hanche-Olsen
2006-11-25  3:32       ` Perry Smith
2006-11-25 10:11         ` Quoting style of arguments etc. [was: multiline regex mode?] Dieter Wilhelm
2006-11-25 10:23         ` multiline regex mode? Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=184E9345-5926-47E0-B30E-A860A00F24E9@easesoftware.com \
    --to=pedz@easesoftware.com \
    --cc=dieter@duenenhof-wilhelm.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.