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
commitb36715dcbd82372bc59d53d6f8fa4d3c46f50586 (patch)
tree2a73857694190ec02d7f6049bc9bd1ec7fec8a1c
parent284aa1cdac9ed826f8c990ee31a9212886d36460 (diff)
downloadtxr-b36715dcbd82372bc59d53d6f8fa4d3c46f50586.tar.gz
txr-b36715dcbd82372bc59d53d6f8fa4d3c46f50586.tar.bz2
txr-b36715dcbd82372bc59d53d6f8fa4d3c46f50586.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))