help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern M


From: Nordlöw
Subject: Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching
Date: Wed, 08 Dec 2010 15:34:09 -0000
User-agent: G2/1.0

I have a suggestion for an improvement of the Emacs's pattern matching
capabilities using an extra flag to re-search-forward/backward which I
think should be called TREE-MATCH/FLAG.

This flags makes patterns like for example \( \( RE1? \) \( RE2? \)
\)  result in the match-data:
(1 3 (MD1) (MD2) #<buffer *scratch*>)
instead of
(1 3 MD1 MD2 #<buffer *scratch*>)

where MD1/2 are the match-data for RE2/RE2 respetively.

That is for each level of match-parens we create a sub-list containing
possible BEG-END values and in the end delete sub-lists containing no
BEG-END-pairs.

This enables us to pack sets of different regular expressions into one
unified regexp without knowing their individual structure (number of
sub-matchers etc) send them to re-search-f/b and alikes and then
traverse the combined result in a standard way. This is not possible
today because we cannot in the general case know which BEG-END pairs
belongs to which matcher.

For example font-locking and language-parsing would be greatly enhance
with this extension which I guess would not be that much work to
implement. The tree structure is already present in regular expression
which I guess is parsed into some expression tree (AST) before being
used.

Comments on that?
/Per Nordlöw


reply via email to

[Prev in Thread] Current Thread [Next in Thread]