fix xml/plist, which doesn't use xexprs
svn: r13324
This commit is contained in:
parent
65f3ec4656
commit
cebd9282b1
|
@ -15,6 +15,29 @@
|
||||||
; an array : (list 'array value ...)
|
; an array : (list 'array value ...)
|
||||||
; (we're ignoring data & date)
|
; (we're ignoring data & date)
|
||||||
|
|
||||||
|
(define (plist-dict? v)
|
||||||
|
(and (list? v)
|
||||||
|
(pair? v)
|
||||||
|
(eq? (car v) 'dict)
|
||||||
|
(andmap (lambda (v)
|
||||||
|
(and (list? v)
|
||||||
|
(= 3 (length v))
|
||||||
|
(eq? (car v) 'assoc-pair)
|
||||||
|
(string? (cadr v))
|
||||||
|
(let pl-value? ([v (caddr v)])
|
||||||
|
(or (string? v)
|
||||||
|
(and (pair? v)
|
||||||
|
(case (car v)
|
||||||
|
[(true) (null? (cdr v))]
|
||||||
|
[(false) (null? (cdr v))]
|
||||||
|
[(integer) (and (= (length v) 2)
|
||||||
|
(exact-integer? (cadr v)))]
|
||||||
|
[(real) (and (= (length v) 2)
|
||||||
|
(real? (cadr v)))]
|
||||||
|
[(array) (andmap pl-value? (cdr v))]
|
||||||
|
[else (plist-dict? v)]))))))
|
||||||
|
(cdr v))))
|
||||||
|
|
||||||
|
|
||||||
; raise-plist-exn : string mark-set xexpr symbol -> ???
|
; raise-plist-exn : string mark-set xexpr symbol -> ???
|
||||||
(define (raise-plist-exn tag mark-set xexpr type)
|
(define (raise-plist-exn tag mark-set xexpr type)
|
||||||
|
@ -191,5 +214,5 @@
|
||||||
|
|
||||||
;; END OF TEST
|
;; END OF TEST
|
||||||
|
|
||||||
(provide read-plist)
|
(provide plist-dict? read-plist)
|
||||||
(provide/contract [write-plist (xexpr/c output-port? . -> . void?)]))
|
(provide/contract [write-plist (plist-dict? output-port? . -> . void?)]))
|
||||||
|
|
|
@ -359,9 +359,8 @@ used to store dictionaries of string--value associations. This format
|
||||||
is used by Mac OS X (both the operating system and its applications)
|
is used by Mac OS X (both the operating system and its applications)
|
||||||
to store all kinds of data.
|
to store all kinds of data.
|
||||||
|
|
||||||
A @deftech{dictionary X-expression} is an @tech{X-expression} that
|
A @deftech{plist dictionary} is a value that could be created by an
|
||||||
could be create by an expression matching the following
|
expression matching the following @scheme[_dict-expr] grammar:
|
||||||
@scheme[_dict-expr] grammar:
|
|
||||||
|
|
||||||
@schemegrammar*[
|
@schemegrammar*[
|
||||||
#:literals (list)
|
#:literals (list)
|
||||||
|
@ -376,16 +375,18 @@ could be create by an expression matching the following
|
||||||
(list 'array pl-value ...)]
|
(list 'array pl-value ...)]
|
||||||
]
|
]
|
||||||
|
|
||||||
@defproc[(read-plist [in input-port?]) xexpr/c]{
|
@defproc[(plist-dict? [any/c v]) boolean?]{
|
||||||
|
|
||||||
Reads a plist from a port, and produces a @tech{dictionary
|
Returns @scheme[#t] if @scheme[v] is a @tech{plist dictionary},
|
||||||
X-expression}.}
|
@scheme[#f] otherwise.}
|
||||||
|
|
||||||
@defproc[(write-plist [dict xexpr/c] [out output-port?]) void?]{
|
@defproc[(read-plist [in input-port?]) plist-dict?]{
|
||||||
|
|
||||||
Write a plist to the given port. If @scheme[dict] is not a
|
Reads a plist from a port, and produces a @tech{plist dictionary}.}
|
||||||
@tech{dictionary X-expression}, the @scheme[exn:fail:contract]
|
|
||||||
exception is raised.}
|
@defproc[(write-plist [dict plist-dict?] [out output-port?]) void?]{
|
||||||
|
|
||||||
|
Write a @tech{plist dictionary} to the given port.}
|
||||||
|
|
||||||
@examples[
|
@examples[
|
||||||
#:eval plist-eval
|
#:eval plist-eval
|
||||||
|
|
Loading…
Reference in New Issue
Block a user