1 ;;;============================================================================
3 ;;; File: "check-consistency.scm", Time-stamp: <2008-11-26 20:24:28 feeley>
5 ;;; Copyright (c) 2008 by Marc Feeley, All Rights Reserved.
7 ;;;============================================================================
9 ;; Check that the lib/gambit#.scm file is consistent with the
10 ;; compiler's public procedures and special forms.
14 (define pretend-defined-by-gambit '(
32 (define (keep keep? lst)
33 (cond ((null? lst) '())
34 ((keep? (car lst)) (cons (car lst) (keep keep? (cdr lst))))
35 (else (keep keep? (cdr lst)))))
37 (define (sort-list lst <?)
39 (define (mergesort lst)
41 (define (merge lst1 lst2)
42 (cond ((null? lst1) lst2)
45 (let ((e1 (car lst1)) (e2 (car lst2)))
47 (cons e1 (merge (cdr lst1) lst2))
48 (cons e2 (merge lst1 (cdr lst2))))))))
51 (if (or (null? lst) (null? (cdr lst)))
53 (cons (car lst) (split (cddr lst)))))
55 (if (or (null? lst) (null? (cdr lst)))
57 (let* ((lst1 (mergesort (split lst)))
58 (lst2 (mergesort (split (cdr lst)))))
63 (define (symbol-table->list st)
66 (let loop ((s s) (lst '()))
68 (loop (##vector-ref s 2) (cons s lst))
72 (define (public-procedure? s)
73 (if (let ((str (symbol->string s)))
74 (or (memv #\# (string->list str))
76 (and (>= (string-length str) 2)
77 (equal? (substring str 0 2) "##"))
78 (and (>= (string-length str) 1)
79 (equal? (substring str 0 1) " "))))
82 (let ((val (##global-var-ref (##make-global-var s))))
85 (define (extract-macros cte)
86 (cond ((##cte-top? cte)
89 (cons (##cte-macro-name cte)
90 (extract-macros (##cte-parent-cte cte))))
92 (extract-macros (##cte-parent-cte cte)))))
94 (define (read-namespace-names filename)
95 (let ((ns (assq '##namespace (with-input-from-file filename read-all))))
100 (define (gambit-macros)
101 (extract-macros (##cte-top-cte ##interaction-cte)))
103 (define (sort-symbols lst)
106 (lambda (x y) (string<? (symbol->string x) (symbol->string y)))))
108 (let* ((public-procedures
109 (keep public-procedure?
110 (symbol-table->list (##symbol-table))))
115 (append public-macros
117 pretend-defined-by-gambit)))
119 (read-namespace-names "../lib/r4rs#.scm"))
123 (read-namespace-names "../lib/r5rs#.scm")))
127 (read-namespace-names "../lib/gambit#.scm")))
128 (missing-from-gambit-public-names
130 (not (memq name gambit-public-names)))
131 sorted-public-names))
132 (extras-in-gambit-public-names
134 (not (memq name sorted-public-names)))
135 gambit-public-names)))
137 (if (or (not (null? extras-in-gambit-public-names))
138 (not (null? missing-from-gambit-public-names)))
140 (display "************ file lib/gambit#.scm needs to be edited ************\n")
142 (if (not (null? extras-in-gambit-public-names))
144 (display "==== these names should be REMOVED ====\n")
145 (for-each pp extras-in-gambit-public-names)
147 (if (not (null? missing-from-gambit-public-names))
149 (display "==== these names should be ADDED ====\n")
150 (for-each pp missing-from-gambit-public-names)))
156 ;;;============================================================================