X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/17dd58775e25ab495e3c83deb4b5a36f5e5a124b..8741d155d948c7317945eee423a977940cad995e:/src/ctm/reader.lisp diff --git a/src/ctm/reader.lisp b/src/ctm/reader.lisp index 7433b1d..f73c242 100644 --- a/src/ctm/reader.lisp +++ b/src/ctm/reader.lisp @@ -85,9 +85,25 @@ ;; canonically; qualified quoted strings retain their lexical value. (values (topic-maps.tmdm:canonical-integer-lexical-form (token-value token)) (topic-maps.tmdm:integer-datatype))) + (:decimal + (consume parser) + ;; Same value-representation policy as bare integers; token spelling is + ;; retained by the lexer, qualified strings remain lexical model data. + (values (topic-maps.tmdm:canonical-decimal-lexical-form (token-value token)) + (topic-maps.tmdm:decimal-datatype))) + (:date + (consume parser) + (values (topic-maps.tmdm:canonical-date-lexical-form (token-value token)) (topic-maps.tmdm:date-datatype))) + (:datetime + (consume parser) + (multiple-value-bind (value reason) (topic-maps.tmdm:canonical-datetime-lexical-form (token-value token)) + (unless value (problem 'ctm-unsupported + (if (eq reason :unsupported-timezone) :datetime-timezone-canonicalization :datetime-leap-second-context) + (token-position token) "DateTime value normalization requires an unsupported timezone/leap context.")) + (values value (topic-maps.tmdm:datetime-datatype)))) (:excluded-literal (problem 'ctm-unsupported :occurrence-literal-datatype (token-position token) - "Decimal/date/dateTime and the separate CTM '*' literal are outside this slice.")) + "The separate CTM '*' literal is outside this slice.")) (:string (consume parser) (if (punctuation-p parser #\^) @@ -101,6 +117,18 @@ (not (topic-maps.tmdm:integer-lexical-p (token-value token)))) (problem 'ctm-rejection :invalid-integer-value (token-position token) "Quoted value is not an xsd:integer lexical form.")) + (when (and (string= datatype (topic-maps.tmdm:decimal-datatype)) + (not (topic-maps.tmdm:decimal-lexical-p (token-value token)))) + (problem 'ctm-rejection :invalid-decimal-value (token-position token) + "Quoted value is not an xsd:decimal lexical form.")) + (when (and (string= datatype (topic-maps.tmdm:date-datatype)) + (not (topic-maps.tmdm:date-lexical-p (token-value token)))) + (problem 'ctm-rejection :invalid-date-value (token-position token) + "Quoted value is not a valid XSD 1.0 date lexical form.")) + (when (and (string= datatype (topic-maps.tmdm:datetime-datatype)) + (not (topic-maps.tmdm:datetime-lexical-p (token-value token)))) + (problem 'ctm-rejection :invalid-datetime-value (token-position token) + "Quoted value is not a valid XSD 1.0 dateTime.")) ;; TMDM 4.4 requires absolute anyURI content; quoted content is ;; lexical data, never an IRI reference to resolve against the document. (when (and (string= datatype (topic-maps.tmdm:iri-datatype)) @@ -111,7 +139,7 @@ (values (token-value token) (topic-maps.tmdm:string-datatype)))) ((:iri :qname) (values (literal-iri-reference parser) (topic-maps.tmdm:iri-datatype))) (otherwise (problem 'ctm-rejection :expected-occurrence-value (token-position token) - "Expected an integer, quoted string or IRI-form Occurrence value."))))) + "Expected an integer, decimal, date, dateTime, quoted string or IRI-form Occurrence value."))))) (defun read-identity-tail (parser map topic) (let ((start (look parser)))