X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=ocaml%2Fparser.ml;h=f5b7d7d1173097feffd36cf74bb14dbb921cff08;hb=db562ac015ffc6c1a08c226b4eef7790b21661cd;hp=ac692516a68cc1786e4b46c08435992236b8e478;hpb=15c305b0d106b39616bdeea9aec9febc7539c2c1;p=fireball-separation.git diff --git a/ocaml/parser.ml b/ocaml/parser.ml index ac69251..f5b7d7d 100644 --- a/ocaml/parser.ml +++ b/ocaml/parser.ml @@ -182,7 +182,9 @@ prerr_endline (s); if line = "" then chr, name, div, conv, ps else let rec aux' chr line = if chr = "#" - then chr, line, div, conv, ps + then chr, name, div, conv, ps + else if chr = "$" + then "#", line, div, conv, ps else if chr = "D" then chr, name, line, conv, ps else if chr = "C" @@ -246,3 +248,18 @@ let ps = List.map ( ) ps in name, div, conv, ps, free ;; + + +let from_file path = + let lines = ref [] in + let chan = open_in path in + let _ = try + while true; do + lines := input_line chan :: !lines + done + with End_of_file -> + close_in chan in + let txt = String.concat "\n" (List.rev !lines) in + let problems = Str.split (Str.regexp "\n\\$") txt in + List.map problem_of_string (List.tl (List.map ((^) "$") problems)) +;;