+(defun read-variant (parser map name)
+ "CTM 3.12: required explicit Scope, then union with the current Parent Scope."
+ (consume parser) ; (
+ (multiple-value-bind (value datatype) (read-literal parser :variant)
+ (unless (punctuation-p parser #\@)
+ (problem 'ctm-rejection :expected-variant-scope (token-position (look parser))
+ "A Variant requires an explicit '@' Scope."))
+ (let* ((scope-position (token-position (look parser))) (themes (read-scope parser map))
+ (scope (append (topic-maps.tmdm:topic-name-scope name) themes)))
+ (unless (punctuation-p parser #\))
+ (problem 'ctm-rejection :missing-variant-close (token-position (look parser))
+ "Expected ')' after the Variant Scope."))
+ (consume parser)
+ (handler-case (topic-maps.tmdm:add-variant name value :datatype datatype :scope scope)
+ (topic-maps.tmdm:variant-error (c)
+ (problem 'ctm-rejection (topic-maps.tmdm:variant-error-code c) scope-position (princ-to-string c)))))))
+