; sigma: (int * nf) list (* the computed substitution *)
; deltas: discriminating_set ref list (* collection of all branches *)
; initialSpecialK: int
+ ; label : string
+ ; var_names : string list (* names of the original free variables *)
; trail: discriminating_set list list
};;
| `N _ -> raise (Parser.ParsingError " numbers in ps")
;;
-let problem_of_2 (label, div, conv, nums, var_names) =
+let tmp (label, div, conv, nums, var_names) =
(* DA SPOSTARE NEI TEST: *)
let ps = List.map append_zero nums in (* crea lista applicando zeri o dummies *)
let ps = sort_uniq ~compare:eta_compare (ps :> nf list) in
let dummy = `Var (max_int / 2, -666) in
[ ref (Array.to_list (Array.init (List.length ps) (fun i -> i, dummy))) ] in
let trail = [] in
- let p = {freshno; div; conv; ps; sigma=[] ; deltas; initialSpecialK=special_k; trail} in
+ let sigma = [] in
+ let p = {freshno; div; conv; ps; sigma; deltas; initialSpecialK=special_k; trail; var_names; label} in
p, check p
;;
| #i_n_var as y -> y
| _ -> raise (Parser.ParsingError "A term in num is not i_n_var")
) ps in
- problem_of_2("missing label", div, conv, ps, var_names)
-;;
-
-let problem_of_string_tmp s =
- let x = Parser.problem_of_string s in
- problem_of_2 x
+ tmp("missing label", div, conv, ps, var_names)
;;
;;\r
\r
let problem_of_string s =\r
+prerr_endline (s);\r
let lines = Str.split (Str.regexp "[\n\r\x0c\t;]+") s in\r
+ let lines = List.map String.trim lines in\r
let lines = List.filter ((<>) "") lines in\r
prerr_endline("number of lines" ^ string_of_int (List.length lines));\r
- let aux (name, div, conv, ps) line =\r
+ let aux (last, name, div, conv, ps) line =\r
let chr = String.sub line 0 1 in\r
let line = String.sub line 1 (String.length line - 1) in\r
- if chr = ":"\r
- then line, div, conv, ps\r
- else if chr = "D"\r
- then name, line, conv, ps\r
- else if chr = "C"\r
- then name, div, line::conv, ps\r
- else if chr = "N"\r
- then name, div, conv, line::ps\r
- else raise (ParsingError ("Unexpected at beginning of line: " ^ chr)) in\r
- let name, div, conv, ps = List.fold_left aux ("?", "", [], []) lines in\r
+ if line = "" then chr, name, div, conv, ps else\r
+ let rec aux' chr line =\r
+ if chr = "#"\r
+ then chr, line, div, conv, ps\r
+ else if chr = "D"\r
+ then chr, name, line, conv, ps\r
+ else if chr = "C"\r
+ then chr, name, div, line::conv, ps\r
+ else if chr = "N"\r
+ then chr, name, div, conv, line::ps\r
+ else if last = ""\r
+ then raise (ParsingError ("Unexpected at beginning of problem: " ^ chr))\r
+ else aux' last (chr ^ line) in\r
+ aux' chr line in\r
+ let _, name, div, conv, ps = List.fold_left aux ("#", "?", "", [], []) lines in\r
let div_provided = div <> "" in\r
let div = if div_provided then div else "BOT" in\r
let strs = [div] @ ps @ conv in\r
let ps = List.map (\r
function\r
| #i_n_var as y -> y\r
- | _ -> raise (ParsingError "A term in num is not i_n_var")\r
+ | _ as y -> raise (ParsingError ("A term in num is not i_n_var" ^ Num.string_of_nf y))\r
) ps in\r
-\r
name, div, conv, ps, free\r
;;\r