(************************************************************ graphParser.ml Created : Fri Jun 21 12:03:40 2002 Last modified: Fri Jun 21 12:20:42 2002 Compile: ocamlopt str.cmxa graphParser.ml -o g # ************************************************************) let test_data = "a: b\nb: c d\nd: k\n" (*let line_regexp = Str.regexp "\([a-zA-Z0-9]\)+: *\(\([a-zA-Z0-9]\)+ +\)"*) type depend = Depend of string * (string list) let match_test = let test_data = "a: b c d e" in match Str.split (Str.regexp ":") test_data with [] -> raise Not_found | t::f::[] -> begin match Str.split (Str.regexp " ") f with [] -> raise Not_found | lst -> Depend(t,lst) end | _ -> raise Not_found let _ = match match_test with Depend(t,lst) -> begin print_string (t^"\n"); List.iter (fun x -> print_string (x^" ")) lst; print_string "\n"; end