From: Nordlöw <per.nordlow@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching
Date: Tue, 2 Nov 2010 01:24:30 -0700 (PDT) [thread overview]
Message-ID: <59d13ede-9f6e-4dcb-8826-fae2a178c8d7@32g2000yqz.googlegroups.com> (raw)
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
next reply other threads:[~2010-11-02 8:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-02 8:24 Nordlöw [this message]
2010-11-03 2:53 ` Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching Stefan Monnier
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=59d13ede-9f6e-4dcb-8826-fae2a178c8d7@32g2000yqz.googlegroups.com \
--to=per.nordlow@gmail.com \
--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.