[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiline regex mode?
From: |
Harald Hanche-Olsen |
Subject: |
Re: multiline regex mode? |
Date: |
Sat, 25 Nov 2006 15:11:14 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (berkeley-unix) |
+ Peter Dyballa <Peter_Dyballa@Web.DE>:
| 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 <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
- Re: multiline regex mode?, (continued)
- Re: multiline regex mode?, Dieter Wilhelm, 2006/11/24
- Re: multiline regex mode?, Peter Dyballa, 2006/11/24
- Re: multiline regex mode?, Dieter Wilhelm, 2006/11/25
- Re: multiline regex mode?, Peter Dyballa, 2006/11/25
- Re: multiline regex mode?, Perry Smith, 2006/11/25
- Re: multiline regex mode?, Dieter Wilhelm, 2006/11/25
- Message not available
- [OT] Re: multiline regex mode?, Harald Hanche-Olsen, 2006/11/25
- Message not available
- Re: multiline regex mode?,
Harald Hanche-Olsen <=
- Re: multiline regex mode?, Dieter Wilhelm, 2006/11/25
- Message not available
- Re: multiline regex mode?, Harald Hanche-Olsen, 2006/11/25