Function: rng-compute-data-deriv
rng-compute-data-deriv is a byte-compiled function defined in
rng-match.el.gz.
Signature
(rng-compute-data-deriv IPATTERN VALUE)
Source Code
;; Defined in /usr/src/emacs/lisp/nxml/rng-match.el.gz
(defun rng-compute-data-deriv (ipattern value)
(let ((type (rng--ipattern-type ipattern)))
(cond ((eq type 'text) ipattern)
((eq type 'choice)
(rng-transform-choice (lambda (p) (rng-data-deriv p value))
ipattern))
((eq type 'group)
(rng-transform-group-nullable
(lambda (p) (rng-data-deriv p value))
(lambda (x y) (rng-intern-group (cons x y)))
ipattern))
((eq type 'one-or-more)
(rng-intern-group (list (rng-data-deriv
(rng--ipattern-child ipattern)
value)
(rng-intern-optional ipattern))))
((eq type 'after)
(let ((child (rng--ipattern-child ipattern)))
(if (or (rng--ipattern-nullable
(rng-data-deriv child value))
(and (rng--ipattern-nullable child)
(string-blank-p value)))
(rng--ipattern-after ipattern)
rng-not-allowed-ipattern)))
((eq type 'data)
(if (rng-dt-make-value (rng--ipattern-datatype ipattern)
value)
rng-empty-ipattern
rng-not-allowed-ipattern))
((eq type 'data-except)
(if (and (rng-dt-make-value (rng--ipattern-datatype ipattern)
value)
(not (rng--ipattern-nullable
(rng-data-deriv
(rng--ipattern-child ipattern)
value))))
rng-empty-ipattern
rng-not-allowed-ipattern))
((eq type 'value)
(if (equal (rng-dt-make-value (rng--ipattern-datatype ipattern)
value)
(rng--ipattern-value-object ipattern))
rng-empty-ipattern
rng-not-allowed-ipattern))
((eq type 'list)
(let ((tokens (split-string value))
(state (rng--ipattern-child ipattern)))
(while (and tokens
(not (eq state rng-not-allowed-ipattern)))
(setq state (rng-data-deriv state (car tokens)))
(setq tokens (cdr tokens)))
(if (rng--ipattern-nullable state)
rng-empty-ipattern
rng-not-allowed-ipattern)))
;; don't think interleave can occur
;; since we do text-only-deriv first
(t rng-not-allowed-ipattern))))