diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-07-19 21:46:27 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-07-19 21:46:27 +0200 |
commit | 06d7cf553bbb2df7615724d765c0e28b508444b1 (patch) | |
tree | 01701c896bb64ac1b57e2f7a441539ce5f029567 /geiser/doc.scm | |
parent | c732ede0663e2f014176b14d0ddd0d8970f38b65 (diff) | |
download | geiser-guile-06d7cf553bbb2df7615724d765c0e28b508444b1.tar.gz geiser-guile-06d7cf553bbb2df7615724d765c0e28b508444b1.tar.bz2 |
Guile: taking advantage of the patterns property in macro transformers.
Diffstat (limited to 'geiser/doc.scm')
-rw-r--r-- | geiser/doc.scm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/geiser/doc.scm b/geiser/doc.scm index e1e27c1..4bd063b 100644 --- a/geiser/doc.scm +++ b/geiser/doc.scm @@ -52,10 +52,13 @@ (let ((args-list (map mkargs (if (list? args-list) args-list '())))) (list id (cons 'args args-list)))) +(define default-macro-args '(((required ...)))) + (define (obj-args obj) (cond ((not obj) #f) ((or (procedure? obj) (program? obj)) (arguments obj)) - ((macro? obj) '(((required ...)))) + ((and (macro? obj) (macro-transformer obj)) => macro-args) + ((macro? obj) default-macro-args) (else 'variable))) (define (arguments proc) @@ -79,6 +82,16 @@ `((required . ,(car formals)) (rest . ,(cdr formals)))) (else #f)))) +(define (macro-args tf) + (cond ((procedure-property tf 'patterns) => + (lambda (pats) + (filter identity + (map (lambda (p) + (and (every symbol? p) + (list (cons 'required p)))) + pats)))) + (else default-macro-args))) + (define (arity->args art) (define (gen-arg-names count) (map (lambda (x) '_) (iota (max count 0)))) |