;; Documentation generation ;; The is to use the data present in the 'word' structure to generate ;; reference documentation. Most of this should also be accessible ;; from the command line. (module docgen mzscheme (require "pic18.ss" "ns.ss" "rep.ss" (lib "pretty.ss") (lib "match.ss") "list-utils.ss" ) (provide (all-defined)) (define (print-word w) (printf "~a\n" (word-semantics w)) (pretty-print (word-source w))) (define (primitives path) (ns-for-each path (lambda (n w) (printf "~a " n) (print-word w)))) (define (literal? lst) (match lst (('qw data) #t) (else #f))) (define (literals? lst) (or (null? lst) (and (literal? (car lst)) (literals? (cdr lst))))) (define (split-word pattern) (let ((r (reverse pattern))) (values (reverse (cdr r)) (car r)))) ;; Macro primitives. (define (primitive-types) (ns-for-each '(macro) (lambda (n w) (if (eq? 'asm-match: (word-semantics w)) ;; get the first matcher clause (let ((clause (car (word-source w)))) ;; (pretty-print clause) (let-values (((args word) (split-word (first clause))) ((expr) (second clause))) (when (and (literals? args) (literals? expr)) (pretty-print word) ))))))) (define (print-type word) (case (word-semantics word) ((asm-match:) (for-each (lambda (clause) ;; (pretty-print clause) (let-values (((args word) (split-word (first clause))) ((expr) (second clause))) (pretty-print (list (map car args) '=> (map car expr))))) (word-source word))))) )