]> dreyeck.freedombox.rocks Git - topic-maps.git/blobdiff - src/ctm/lexer.lisp
feat(ctm): support the CTM integer star literal
[topic-maps.git] / src / ctm / lexer.lisp
index 7b5af30d629dac9a1a83130b63a9665746296526..ebc030188072c93bc042f98a590de25fe934c65a 100644 (file)
                  (return))))
           (t (return)))))
 
-(defun excluded-literal-p (text)
+(defun ctm-integer-literal-p (text)
   (string= text "*"))
 
 (defun read-number-token (lexer start)
-  "One token path for Integer, Decimal, Date and DateTime; * remains excluded.
+  "One token path for Integer, Decimal, Date, DateTime and the exact * literal.
 A dot followed by a digit can belong to a decimal; a terminal dot stays punctuation."
   (setf (lexer-cursor lexer) start)
   (loop for c = (peek-character lexer)
@@ -98,7 +98,7 @@ A dot followed by a digit can belong to a decimal; a terminal dot stays punctuat
            (multiple-value-bind (parts reason) (topic-maps.tmdm::datetime-parts value)
              (unless parts (problem 'ctm-rejection reason start "Expected a valid XSD 1.0 dateTime."))
              (make-token :kind :datetime :value value :position start)))
-          ((excluded-literal-p value) (make-token :kind :excluded-literal :value value :position start))
+          ((ctm-integer-literal-p value) (make-token :kind :ctm-integer :value value :position start))
           ((position #\- value :start (if (and (plusp (length value)) (find (char value 0) "+-")) 1 0))
            (multiple-value-bind (a date-end end reason) (topic-maps.tmdm::date-lexical-bounds value)
              (unless (and a (= date-end end))
@@ -172,14 +172,14 @@ A dot followed by a digit can belong to a decimal; a terminal dot stays punctuat
        ;; Production [71] has a literal terminal followed by an identifier;
        ;; unlike Role separators it does not require intervening whitespace.
        (let ((name (find-if (lambda (name) (starts-with (concatenate 'string "%" name) (subseq text start)))
-                            '("prefix" "mergemap"))))
+                            '("prefix" "mergemap" "include" "encoding" "version"))))
          (if name
              (progn (setf (lexer-cursor lexer) (+ start 1 (length name)))
                     (make-token :kind :directive :value name :position start))
              (progn
                (scan-name lexer)
-               (problem 'ctm-unsupported :unsupported-directive start
-                        (format nil "Directive %~A is outside the implemented subset."
+               (problem 'ctm-rejection :unknown-directive start
+                        (format nil "Unknown CTM directive %~A."
                                 (subseq text (1+ start) (lexer-cursor lexer))))))))
       ((char= c #\$)
        (unless (name-start-p (peek-character lexer))