equal
deleted
inserted
replaced
45 val parse_comments: string list -> unit * string list |
45 val parse_comments: string list -> unit * string list |
46 val parse_string : string -> string option |
46 val parse_string : string -> string option |
47 val parse_element: string list -> tree * string list |
47 val parse_element: string list -> tree * string list |
48 val parse_document: string list -> tree * string list |
48 val parse_document: string list -> tree * string list |
49 val parse: string -> tree |
49 val parse: string -> tree |
|
50 val cache: unit -> tree -> tree |
50 exception XML_ATOM of string |
51 exception XML_ATOM of string |
51 exception XML_BODY of body |
52 exception XML_BODY of body |
52 structure Encode: XML_DATA_OPS |
53 structure Encode: XML_DATA_OPS |
53 structure Decode: XML_DATA_OPS |
54 structure Decode: XML_DATA_OPS |
54 end; |
55 end; |
226 | (_, ys) => error ("XML parsing error: Unprocessed input\n" ^ Symbol.beginning 100 ys)); |
227 | (_, ys) => error ("XML parsing error: Unprocessed input\n" ^ Symbol.beginning 100 ys)); |
227 |
228 |
228 end; |
229 end; |
229 |
230 |
230 |
231 |
|
232 (** cache for partial sharing (strings only) **) |
|
233 |
|
234 fun cache () = |
|
235 let |
|
236 val strings = Unsynchronized.ref (Symtab.empty: unit Symtab.table); |
|
237 |
|
238 fun string s = |
|
239 (case Symtab.lookup_key (! strings) s of |
|
240 SOME (s', ()) => s' |
|
241 | NONE => (Unsynchronized.change strings (Symtab.update (s, ())); s)); |
|
242 |
|
243 fun tree (Elem ((name, props), body)) = |
|
244 Elem ((string name, map (pairself string) props), map tree body) |
|
245 | tree (Text s) = Text (string s); |
|
246 in tree end; |
|
247 |
|
248 |
231 |
249 |
232 (** XML as data representation language **) |
250 (** XML as data representation language **) |
233 |
251 |
234 exception XML_ATOM of string; |
252 exception XML_ATOM of string; |
235 exception XML_BODY of tree list; |
253 exception XML_BODY of tree list; |