From 06d7cf553bbb2df7615724d765c0e28b508444b1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 19 Jul 2010 21:46:27 +0200 Subject: Guile: taking advantage of the patterns property in macro transformers. --- geiser/doc.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'geiser') 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)))) -- cgit v1.2.3