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