- (loop until (eq :eof (token-kind (look parser))) do
- (if (eq :directive (token-kind (look parser)))
- (read-prefix-directive parser)
- (let ((topic (identity-reference parser map)))
- (if (punctuation-p parser #\()
- (read-association parser map topic)
- (read-topic parser map topic)))))
- map)))
+ (handler-bind ((topic-maps.tmdm:variant-error
+ (lambda (c) (problem 'ctm-rejection (topic-maps.tmdm:variant-error-code c)
+ (lexer-cursor (parser-lexer parser)) (princ-to-string c))))
+ (topic-maps.tmdm:reification-error
+ (lambda (c) (problem 'ctm-rejection (topic-maps.tmdm:reification-error-code c)
+ (lexer-cursor (parser-lexer parser)) (princ-to-string c)))))
+ (loop while (eq :directive (token-kind (look parser))) do (read-prefix-directive parser))
+ (multiple-value-bind (r position) (read-reifier parser map) (attach-reifier map r position))
+ (loop until (eq :eof (token-kind (look parser))) do
+ (when (punctuation-p parser #\~)
+ (problem 'ctm-rejection :topic-map-reifier-position (token-position (look parser))
+ "Topic Map Reifier must precede all body declarations."))
+ (if (eq :directive (token-kind (look parser)))
+ (read-prefix-directive parser)
+ (let* ((embedded (punctuation-p parser #\[)) (topic (topic-reference parser map)))
+ (if (punctuation-p parser #\()
+ (read-association parser map topic)
+ (if embedded
+ (problem 'ctm-rejection :embedded-topic-at-top-level (token-position (look parser))
+ "An Embedded Topic at top level must be an Association Type, not a standalone declaration.")
+ (read-topic-tail parser map topic #\.)))))))
+ (values map (parser-wildcard-counter parser)))))