I'd like to segment Lisp source code into a list of code segments. Each segment is either a top level S-expression, or whatever text between those S-expressions.
Initially I thought that I could use regular expression pattern to match top level S-expression, but I found that it's not as trivial to handle the matching parenthesis to at the top level only.
(I feel that it might be possible to work out a regular expression to match top level S-exp) by following example of this Using regular expressions to extract functions and function headers from source code
Next, I figure that I may scan the text to observe the first left parenthesis '(', and the last right parenthesis ')', and do the segmentation accordingly.
Before I do that I feel that given the ubiquitous nature of S-expression in emacs Lisp, there should have already existing solution to my requirements.
So I ask if you could teach me any solution?
Thanks,