Commit fbbd82b7 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-22 17:09:52 by cvscast] Tail-recursive load_xml improved

Original author: cvscast
Date: 2003-05-22 17:09:52+00:00
parent 2094b634
......@@ -84,24 +84,21 @@ let load_xml_aux s =
and parse_seq stack =
match get() with
| E_start_tag (name,att,_) ->
if only_ws txt.buffer txt.pos then
let () = txt.pos <- 0 in
parse_seq (Start (name,att) :: stack)
else
let s = String.sub txt.buffer 0 txt.pos in
let () = txt.pos <- 0 in
parse_seq (Start (name,att) :: String s :: stack)
let stack =
if only_ws txt.buffer txt.pos then stack
else String (String.sub txt.buffer 0 txt.pos) :: stack in
txt.pos <- 0;
parse_seq (Start (name,att) :: stack)
| E_char_data data ->
add_string txt data;
parse_seq stack
| E_end_tag (_,_) ->
if only_ws txt.buffer txt.pos then
(txt.pos <- 0;
create_elt nil stack)
else
let s = String.sub txt.buffer 0 txt.pos in
txt.pos <- 0;
create_elt (string s nil) stack
let accu =
if only_ws txt.buffer txt.pos
then nil
else string (String.sub txt.buffer 0 txt.pos) nil in
txt.pos <- 0;
create_elt accu stack
| _ -> failwith "Expect start_tag, char_data, or end_tag"
in
let rec parse_doc () =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment