v6.0-exception
Matthew Butterick 6 years ago
parent a3b407e59c
commit 7790f57b0d

@ -19,20 +19,21 @@
(define (my-xexpr? x) (define (my-xexpr? x)
((disjoin txexpr? xexpr? my-valid-char?) x)) ((disjoin txexpr? xexpr? my-valid-char?) x))
(define+provide+safe (txexpr? x [short-only #f]) (define+provide+safe (txexpr? x [allow-long #t])
predicate/c predicate/c
(match x (match x
[(cons (? txexpr-tag?) rest) [(cons (? txexpr-tag?) rest)
(=> resume) (=> resume)
(let loop ([rest rest])
(match rest (match rest
[(list (? my-xexpr?) ...) #true] [(list (? my-xexpr?) ...) #true]
[(list (? txexpr-attrs?) (? my-xexpr?) ...) #:when (not short-only) #true] [(list (? txexpr-attrs?) elems ...) #:when allow-long (loop elems)]
[_ (resume)])] [_ (resume)]))]
[_ #false])) [_ #false]))
(define+provide+safe (txexpr-short? x) (define+provide+safe (txexpr-short? x)
predicate/c predicate/c
(txexpr? x 'short-only)) (txexpr? x #false))
(define+provide+safe (txexpr-tag? x) (define+provide+safe (txexpr-tag? x)
predicate/c predicate/c

Loading…
Cancel
Save