all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
[parent not found: <mailman.4622.1154145591.9609.help-gnu-emacs@gnu.org>]
* regexp to match a sexp?
@ 2006-07-29  1:55 Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-07-29  1:55 UTC (permalink / raw)


This is a job description for a regexp.

I'm looking for a regexp that will match (only) a sexp. Ideally, by using
syntax classes, it might be able to adapt to (some) other languages, but a
regexp that worked for only Emacs-Lisp sexps would be a great start.

For Lisp, for example, here are some considerations I can think of (are
there others?):

1. It would need to match either a list sexp or an atomic sexp. The former
would be something like \s(.*\s), but `.' would need to be refined here
(how?). The latter would have to account for symbols, as in \s_+, but also
arbitrary numbers and strings. (Is anything else a readable Emacs-Lisp
atom?)

2. Strings and the possible escaping of `"' would be one headache that would
need to be dealt with carefully, as always.

3. It would need to be effectively recursive or some approximation thereof,
for example, with some limit placed on nesting. That is, it would need to
allow for nested sexps.

4. It would need to deal properly with quoting, `''. Dealing with backquote
syntax, ``', would be a plus.

Can something like this be done in a reasonable way? What's a good regexp
that you could use, e.g., to search for one or more sexps?

I'm not looking for a way to search for or scan a sexp *without* using a
regexp; I know there are ways to do that. I'm wondering what can be done
*with* a regexp. IOW, imagine that all you have is `C-M-s' (but don't worry
about the expression being too complex to type interactively).

I'm less interested in hearing "it can't be done" than in attempts to do the
job, even if in a rough way.

Any ideas?

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

end of thread, other threads:[~2006-07-29  4:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4621.1154138203.9609.help-gnu-emacs@gnu.org>
2006-07-29  2:24 ` regexp to match a sexp? Pascal Bourguignon
2006-07-29  3:59   ` Drew Adams
     [not found] <mailman.4622.1154145591.9609.help-gnu-emacs@gnu.org>
2006-07-29  4:22 ` Pascal Bourguignon
2006-07-29  1:55 Drew Adams

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.