Page
Library
Module
Module type
Parameter
Class
Class type
Source
Plist_xml
Sourcetype error = [
| `Expected_tag of string
| `Expected_start
| `Expected_end
| `Expected_start_or_end
| `Expected_data
| `Malformed_base64 of string
| `Malformed_date of string
| `Malformed_int of string
| `Malformed_real of string
| `Unknown_tag of string
]
Error ((line, col), msg)
indicates a syntax error at line number line
and column number col
. The line and column numbers start from 1
.
The simple interface provides functions for reading plist documents into a tree data structure.
type t = [
| `Bool of bool
| `Data of string
| `Date of float * float option
(timestamp, timezone)
*)| `Float of float
| `Int of int
| `String of string
| `Array of t list
Array
*)| `Dict of (string * t) list
Dictionary
*) ]
Plist values.
parse source
reads an XML representation of a plist value by repeatedly calling source
, which supplies the next byte of input. The input should include the XML header.
from_channel in_channel
reads a plist from in_channel
. See parse
.
print sink t
outputs an XML representation of plist value t
by repeatedly calling sink
with each byte of output. The output includes the XML header and DTD.
to_channel out_channel t
outputs t
to out_channel
. See print
.
The streaming interface provides lower-level signal parsing and printing functions, which do not build up a tree in memory.
type token = [
| `Array_start
| `Array_end
| `Data of string
| `Date of float * float option
| `Dict_start
| `Dict_end
| `False
| `Int of int
| `Key of string
| `Real of float
| `String of string
| `True
]
A token of the logical syntax of a plist value. The logical syntax is an abstraction around an underlying format, such as XML.
A token sequence is well-formed iff it parses to a plist nonterminal:
plist ::= `Array_start plist* `Array_end | `Dict_start kv* `Dict_end | `False | `Data | `Date | `Int | `Real | `String | `True kv ::= `Key plist
Furthermore, a signal is either a token or an `EOI
marker. A well-formed signal sequence consists of a well-formed token sequence followed by `EOI
and represents a plist document.
doc ::= plist `EOI
decode source sink
reads bytes of input by repeatedly calling source
and calls sink
upon reading enough to determine the next signal. The emitted signal sequence is guaranteed to be a well-formed document.
encode source sink
reads signals by repeatedly calling source
and outputs their XML representation to sink
byte-by-byte.