-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-links.scm
83 lines (79 loc) · 3.57 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(define srfi-names
(with-input-from-file "srfi-231.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 (if (= (length obj) 3)
(cadr (caddr obj))
(car (cadadr obj)))
result)))
((and (not (null? obj))
(eq? (car obj)
'format-global-variable))
(set! result (cons (cadadr obj) result)))
((and (not (null? obj))
(eq? (car obj)
'format-parameter))
(set! result (cons (cadadr obj) result)))
((and (not (null? obj))
(memq (car obj) '(<a> <br>))
(memq id: obj))
=> (lambda (tail)
(let ((name (cadr tail)))
(set! result
(cons (if (string? name)
(string->symbol name)
(if (list? name)
(cadr name) ;; quote
name))
result)))))
(else
(for-each process obj)))))
(process obj)
result))))))
(define links
(with-input-from-file "srfi-231.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) '<a>)
(memq href: obj))
=> (lambda (tail)
(let ((name (cadr tail)))
(if (and (string? name)
(positive? (string-length name))
(eqv? (string-ref name 0) #\#))
(set! result (cons (substring name 1 (string-length name))
result))))))
(else
(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))