exported pretty-format, a parameter maker for setting the pretty

format for various forms.  The pretty format structure is not
documented yet and there is no error-checking mechanism for
verifying proper input.
This commit is contained in:
Abdulaziz Ghuloum 2008-05-12 01:00:01 -04:00
parent f8b0e949d9
commit f05f171f28
5 changed files with 27 additions and 19 deletions

Binary file not shown.

View File

@ -15,10 +15,10 @@
(library (ikarus pretty-print)
(export pretty-print pretty-width)
(export pretty-print pretty-width pretty-format)
(import
(rnrs hashtables)
(except (ikarus) pretty-print pretty-width))
(except (ikarus) pretty-print pretty-width pretty-format))
(define (map1ltr f ls)
;;; ltr so that gensym counts get assigned properly
(cond
@ -609,6 +609,15 @@
(if (output-port? p)
(pretty x p)
(die 'pretty-print "not an output port" p))]))
(define pretty-format
(lambda (x)
(unless (symbol? x)
(die 'pretty-format "not a symbol" x))
(case-lambda
[() (getprop x '*pretty-format*)]
[(v) (putprop x '*pretty-format* v)])))
;;; standard formats
(set-fmt! 'quote '(read-macro . "'"))
(set-fmt! 'unquote '(read-macro . ","))

View File

@ -449,22 +449,20 @@
(define macro
(lambda (x h)
(define macro-forms
'([quote . "'"]
[quasiquote . "`"]
[unquote . ","]
[unquote-splicing . ",@"]
[syntax . "#'"]
[quasisyntax . "#`"]
[unsyntax . "#,"]
[unsyntax-splicing . "#,@"]
[|#primitive| . "#%"]))
(and (pair? x)
(let ([d ($cdr x)])
(and (pair? d)
(null? ($cdr d))
(not (hashtable-ref h x #f))))
(assq ($car x) macro-forms))))
(and
(pair? x)
(let ([a ($car x)])
(and
(symbol? a)
(let ([d ($cdr x)])
(and (pair? d)
(null? ($cdr d))
(not (hashtable-ref h x #f))))
(let ([p ((pretty-format a))])
(and (pair? p)
(eq? (car p) 'read-macro)
(string? (cdr p)))
p))))))
(define write-pair
(lambda (x p m h i)

View File

@ -1 +1 @@
1471
1472

View File

@ -1285,6 +1285,7 @@
[set-symbol-value! i symbols $boot]
[eval-core $boot]
[pretty-print i $boot]
[pretty-format i]
[pretty-width i]
[module i cm]
[library i]