Old syntax was too verbose with useless hash number.
Also this nicely reflects the standard way to write a URI <...>
(store-char-set special special-number-leaders handler:number)
(store-char initial #\( handler:list)
(store-char special #\( handler:vector)
+ (store-char special #\< handler:uri)
(store-char special #\[ handler:hashed-object)
(store-char initial #\) handler:close-parenthesis)
(store-char initial #\] handler:close-bracket)
((string-ci=? name "unspecific") unspecific)
(else (error:illegal-named-constant name)))))
+(define (handler:uri port db ctx char1 char2)
+ ctx char1 char2
+ (string->uri
+ (call-with-output-string
+ (lambda (port*)
+ (let loop ()
+ (let ((char (%read-char/no-eof port db)))
+ (if (not (char=? char #\>))
+ (begin
+ (%write-char char port*)
+ (loop)))))))))
+
(define (handler:special-arg port db ctx char1 char2)
ctx char1
(let loop ((n (char->digit char2 10)))
(map-reference-trap (lambda () (vector-ref vector index))))
(define (unparse/record record)
- (if (get-param:unparse-with-maximum-readability?)
- (*unparse-readable-hash record)
- (invoke-user-method unparse-record record)))
+ (cond ((uri? record)
+ (unparse/uri record))
+ ((get-param:unparse-with-maximum-readability?)
+ (*unparse-readable-hash record))
+ (else
+ (invoke-user-method unparse-record record))))
+
+(define (unparse/uri uri)
+ (*unparse-string "#<")
+ (*unparse-string (uri->string uri))
+ (*unparse-string ">"))
\f
(define (unparse/pair pair)
(cond ((unparse-list/prefix-pair? pair)
(fragment uri-fragment)
(string uri->string))
-(set-record-type-unparser-method! <uri>
- (simple-unparser-method 'uri
- (lambda (uri)
- (list (uri->string uri)))))
-
-(define uri-parser-method
- (simple-parser-method
- (lambda (objects)
- (and (pair? objects)
- (string->uri (car objects))))))
-
(define (make-uri scheme authority path query fragment)
(let ((path (if (equal? path '("")) '() path)))
(if scheme (guarantee-uri-scheme scheme 'MAKE-URI))
(set! url:char-set:unescaped
(char-set-union url:char-set:unreserved
(string->char-set ";/?:@&=")))
- (define-bracketed-object-parser-method 'URI uri-parser-method))
+ unspecific)
\f
;;;; Partial URIs