summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-03 06:42:53 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-03 06:42:53 -0700
commit3ed21c522b7914a7eed0cf4dffff66e009406213 (patch)
tree2a73857694190ec02d7f6049bc9bd1ec7fec8a1c
parent4eea106b17da71b27b69f0856a3cb4e0c2d93132 (diff)
downloadtxr-3ed21c522b7914a7eed0cf4dffff66e009406213.tar.gz
txr-3ed21c522b7914a7eed0cf4dffff66e009406213.tar.bz2
txr-3ed21c522b7914a7eed0cf4dffff66e009406213.zip
tags: grok Lisp definitions inside @(do ...).
* tags.tl (unexpand): New function. (process-clause): Walk the forms enclosed in a @(do ...) directive that appears at the top level. Because all Lisp is macro-expanded right inside the TXR parser, we need to "unexpand" the forms by chasing their macro-ancestor chain, gaining access to the original forms like defun and defstruct. We can then turn these forms into tags using the process-form function.
-rwxr-xr-xtags.tl10
1 files changed, 9 insertions, 1 deletions
diff --git a/tags.tl b/tags.tl
index 66561d08..68a8527c 100755
--- a/tags.tl
+++ b/tags.tl
@@ -124,6 +124,11 @@
(name
(add (ntag slot-tag name struct-name struct-obj))))))))))))
+(defun unexpand (form)
+ (whilet ((anc (macro-ancestor form)))
+ (set form anc))
+ form)
+
(defun process-clause (path lines clause)
(when (consp clause)
(let ((elem (car clause)))
@@ -137,7 +142,10 @@
(add (ntag fun-tag (car args)))))
(bind (let ((syms (flatten (cadr elem))))
(each ((sym syms))
- (add (ntag fun-tag sym))))))))))))
+ (add (ntag fun-tag sym)))))
+ (do (let ((forms [mapcar unexpand (cdr elem)]))
+ (each ((form forms))
+ (pend (process-form path lines form))))))))))))
(defun collect-tags-tl (path)
(let* ((text (file-get-string path))