| 7 |
open Pxp_types |
open Pxp_types |
| 8 |
open Value |
open Value |
| 9 |
|
|
| 10 |
let string s q = |
let is_ws s = |
| 11 |
let rec check_ws i = (i < 0) || |
let rec check i = |
| 12 |
|
(i < 0) || |
| 13 |
(match s.[i] with |
(match s.[i] with |
| 14 |
| ' ' | '\t' | '\n' | '\r' -> check_ws (i - 1) |
| ' ' | '\t' | '\n' | '\r' -> check (i - 1) |
| 15 |
| _ -> false) in |
| _ -> false) in |
| 16 |
if check_ws (String.length s - 1) then q |
check (String.length s - 1) |
| 17 |
else String (0,String.length s,s,q) |
|
| 18 |
|
|
| 19 |
|
let string s q = |
| 20 |
|
String (0,String.length s,s,q) |
| 21 |
|
|
| 22 |
let run s = |
let run s = |
| 23 |
let config = { default_config with |
let config = { default_config with |
| 39 |
let rec parse_elt name att = |
let rec parse_elt name att = |
| 40 |
let att = List.map (fun (l,v) -> Types.LabelPool.mk l, string v nil) att in |
let att = List.map (fun (l,v) -> Types.LabelPool.mk l, string v nil) att in |
| 41 |
let att = SortedMap.from_list (fun _ _ -> assert false) att in |
let att = SortedMap.from_list (fun _ _ -> assert false) att in |
| 42 |
let child = parse_seq () in |
let child = parse_seq true in |
| 43 |
|
|
| 44 |
let elt = Xml |
let elt = Xml |
| 45 |
(Atom (Types.AtomPool.mk name), |
(Atom (Types.AtomPool.mk name), |
| 51 |
elt |
elt |
| 52 |
|
|
| 53 |
|
|
| 54 |
and parse_seq () = |
and parse_seq dropws = |
| 55 |
match !curr with |
match !curr with |
| 56 |
| E_start_tag (name,att,_) -> |
| E_start_tag (name,att,_) -> |
| 57 |
get (); |
get (); |
| 58 |
let e1 = parse_elt name att in |
let e1 = parse_elt name att in |
| 59 |
let rest = parse_seq () in |
let rest = parse_seq true in |
| 60 |
Pair (e1, rest) |
Pair (e1, rest) |
| 61 |
| E_char_data data -> |
| E_char_data data -> |
| 62 |
get (); |
get (); |
| 63 |
let rest = parse_seq () in |
if dropws && (is_ws data) |
| 64 |
string data rest |
then parse_seq true |
| 65 |
|
else string data (parse_seq false) |
| 66 |
| E_end_tag (_,_) -> |
| E_end_tag (_,_) -> |
| 67 |
nil |
nil |
| 68 |
| _ -> failwith "Expect start_tag, char_data, or end_tag" |
| _ -> failwith "Expect start_tag, char_data, or end_tag" |