X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/topic-maps.git/blobdiff_plain/0573c4f710982dab1c3f2c9284adf459caaf73e9..9c196ddc16cf5cd727fcde81ad7835edefa0f787:/src/ctm/lexer.lisp diff --git a/src/ctm/lexer.lisp b/src/ctm/lexer.lisp index b4e56ab..15125a3 100644 --- a/src/ctm/lexer.lisp +++ b/src/ctm/lexer.lisp @@ -171,14 +171,16 @@ A dot followed by a digit can belong to a decimal; a terminal dot stays punctuat ((char= c #\%) ;; Production [71] has a literal terminal followed by an identifier; ;; unlike Role separators it does not require intervening whitespace. - (if (starts-with "%prefix" (subseq text start)) - (progn (setf (lexer-cursor lexer) (+ start 7)) - (make-token :kind :directive :value "prefix" :position start)) - (progn - (scan-name lexer) - (problem 'ctm-unsupported :unsupported-directive start - (format nil "Directive %~A is outside the implemented subset." - (subseq text (1+ start) (lexer-cursor lexer))))))) + (let ((name (find-if (lambda (name) (starts-with (concatenate 'string "%" name) (subseq text start))) + '("prefix" "mergemap" "include")))) + (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." + (subseq text (1+ start) (lexer-cursor lexer)))))))) ((char= c #\$) (unless (name-start-p (peek-character lexer)) (problem 'ctm-rejection :invalid-variable start "A variable requires an identifier."))