|
|
|
@ -131,19 +131,15 @@
|
|
|
|
|
;; todo: rewrite this recurively so errors can be pinpointed (for debugging)
|
|
|
|
|
(define+provide+safe (validate-txexpr x)
|
|
|
|
|
(any/c . -> . txexpr?)
|
|
|
|
|
(define-syntax-rule (validate-txexpr-attrs-with-context e)
|
|
|
|
|
(validate-txexpr-attrs e #:context x))
|
|
|
|
|
(define-syntax-rule (validate-txexpr-element-with-context e)
|
|
|
|
|
(validate-txexpr-element e #:context x))
|
|
|
|
|
(cond
|
|
|
|
|
[(txexpr-short? x) x]
|
|
|
|
|
[(txexpr? x) (and
|
|
|
|
|
(validate-txexpr-attrs-with-context (get-attrs x))
|
|
|
|
|
(andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)]
|
|
|
|
|
(validate-txexpr-attrs (get-attrs x) #:context x)
|
|
|
|
|
(andmap (λ (e) (validate-txexpr-element e #:context x)) (get-elements x)) x)]
|
|
|
|
|
[(and (list? x) (symbol? (car x)))
|
|
|
|
|
(and
|
|
|
|
|
(andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x))
|
|
|
|
|
(validate-txexpr-attrs-with-context (get-attrs x)))]
|
|
|
|
|
(andmap (λ (e) (validate-txexpr-element e #:context x)) (get-elements x))
|
|
|
|
|
(validate-txexpr-attrs (get-attrs x) #:context x))]
|
|
|
|
|
[(list? x) (error 'validate-txexpr (format "~v is a list but it doesn't start with a symbol" x))]
|
|
|
|
|
[else (error 'validate-txexpr (format "~v: not an X-expression" x))]))
|
|
|
|
|
|
|
|
|
|