|
From: | Perry Smith |
Subject: | Re: multiline regex mode? |
Date: | Sat, 25 Nov 2006 10:32:20 -0600 |
On Nov 25, 2006, at 7:14 AM, Peter Dyballa wrote:
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 ) |
[Prev in Thread] | Current Thread | [Next in Thread] |