forked from scheme-requests-for-implementation/srfi-122
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-links.scm
63 lines (59 loc) · 1.65 KB
/
check-links.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(define srfi-names
(with-input-from-file "srfi-179.scm"
(lambda ()
(let loop ((obj (read)))
(if (not (and (list? obj)
(not (null? obj))
(eq? (car obj)
'with-output-to-file)))
(loop (read))
(let ((result '()))
(define (process obj)
(if (list? obj)
(cond ((and (not (null? obj))
(eq? (car obj)
'format-lambda-list))
(set! result (cons (car (cadadr obj))
result)))
((and (not (null? obj))
(eq? (car obj)
'format-global-variable))
(set! result (cons (cadadr obj) result)))
(else
(for-each process obj)))))
(process obj)
result))))))
(define links
(with-input-from-file "srfi-179.scm"
(lambda ()
(let loop ((obj (read)))
(if (not (and (list? obj)
(not (null? obj))
(eq? (car obj)
'with-output-to-file)))
(loop (read))
(let ((result '()))
(define (process obj)
(if (list? obj)
(if (and (not (null? obj))
(eq? (car obj) '<a>)
(eq? (cadr obj) href:)
(string? (caddr obj))
(positive? (string-length (caddr obj)))
(eqv? (string-ref (caddr obj) 0) #\#)
)
(set! result (cons (substring (caddr obj) 1 (string-length (caddr obj)))
result))
(for-each process obj))))
(process obj)
(map string->symbol result)))))))
(define (in-a-not-in-b a b)
(do ((a a (cdr a))
(result '() (if (memq (car a) b)
result
(cons (car a) result))))
((null? a) result)))
(newline)(pp "SRFI names without links: ")
(pp (in-a-not-in-b srfi-names links))
(newline)(pp "links without srfi-names: ")
(pp (in-a-not-in-b links srfi-names))