all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching
@ 2010-11-02  8:24 Nordlöw
  2010-11-03  2:53 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2010-11-02  8:24 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching
  2010-11-02  8:24 Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching Nordlöw
@ 2010-11-03  2:53 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2010-11-03  2:53 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.

That's a good idea.  I think the benefits are probably too small, sadly,
to justify changing it now.  But if/when someone reimplements the regexp
engine, it might be worthwhile to try and add such a feature.


        Stefan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-03  2:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-02  8:24 Suggestion for Enhancement to re-search-.* enabling Tree-Based Pattern Matching Nordlöw
2010-11-03  2:53 ` Stefan Monnier

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.