Commit 3e2e5006 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Convert type error when (rif-)parsing command-line inputs.

parent c3dd7b26
......@@ -488,7 +488,7 @@ and
output_msg "\n*** Type error.\n*** ";
output_msg (formula_to_string f) ;
output_msg " ougth to be a numeric expression.\n";
exit 2
assert false
| Some (Liste l) ->
assert false
| None ->
......@@ -499,23 +499,20 @@ and
)
)
| Some(N(I(i))) ->
output_msg "\n*** Warning: type error, ";
let f = float_of_int i in
output_msg "\n*** Type error, ";
output_msg ((string_of_int i)
^ " is an int, but a float is expected.\n");
(Gne.make
(Ne.make str (F(float_of_int i)))
(Bdd.dtrue !bdd_manager)
false
)
^ " is an int, but a float is expected. I convert it to '"^
(string_of_float f)^"'\n");
assert false
| Some(B(f)) ->
output_msg "\n*** Warning: type error, ";
let ff = if f then 0.0 else 1.0 in
output_msg "\n*** Type error, ";
output_msg ((string_of_bool f)
^ " is a bool, but a float is expected.\n");
(Gne.make
(Ne.make str (F(0.0)))
(Bdd.dtrue !bdd_manager)
false
)
^ " is a bool, but a float is expected. I convert it to '"^
(string_of_float ff)^"'\n");
assert false
)
| Ival(i) ->
......
......@@ -262,6 +262,15 @@ let rec (build_poly_list_from_delayed_cstr : int -> range Util.StringMap.t ->
let (name_to_rank : string -> int) = Hashtbl.find rank_of_name_tbl
and (rank_to_name : int -> string) = Hashtbl.find name_of_rank_tbl
in
let lfind var tbl =
try StringMap.find var tbl
with Not_found ->
print_string ("Internal error: don't find the value of " ^ (var) ^ " in: " ^
(String.concat "," (StringMap.fold (fun v _ acc -> (v)::acc) tbl [])) ^
"\n");
flush stdout;
assert false
in
let (vntl0, poly0, cl_init) =
StringSet.fold
(fun var (vntl, poly, cl_init)->
......@@ -270,7 +279,7 @@ let rec (build_poly_list_from_delayed_cstr : int -> range Util.StringMap.t ->
for each variables in [vars_of_cl]
*)
let (ineq_min, ineq_max, vnt) =
match (StringMap.find var tbl) with
match (lfind var tbl) with
RangeI(min, max) ->
(
(Constraint.GeqZ
......
......@@ -169,15 +169,40 @@ and (parse_rif_stream : in_channel -> out_channel option -> vntl -> stream ->
(
Stream.junk stream ;
(* Hashtbl.add tbl (Var.name (hd vntl)) (N(F(f))) ; *)
let tbl = tbl@ [fst (hd vntl), F(f)] in
let v =
match snd (hd vntl) with
| "bool" -> B(f<>0.0)
| "real" -> F(f)
| "int" ->
let i = int_of_float f in
print_string "\n*** Warning: type error, ";
print_string ((string_of_float f)
^ " is an real, but an int is expected. I convert it to '"^
(string_of_int i)^"'\n");
I(i)
| e ->
print_string ("\n*** Error: unknown type: "^ e ^ "\n");
assert false
in
let tbl = tbl@ [fst (hd vntl), v] in
parse_rif_stream ic oc (tl vntl) stream tbl pragma
)
| (Genlex.Int (_,i))::_ -> (
Stream.junk stream ;
let v =
if (((snd (hd vntl))) = "bool") then (
if (i = 0) then B(false) else B(true)
) else I(i)
match snd (hd vntl) with
| "bool" -> B(i<>0)
| "int" -> I(i)
| "real" ->
let f = float_of_int i in
print_string "\n*** Warning: type error, ";
print_string ((string_of_int i)
^ " is an int, but a real is expected. I convert it to '"^
(string_of_float f)^"'\n");
F(f)
| e ->
print_string ("\n*** Error: unknown type: "^ e ^ "\n");
assert false
in
let tbl = tbl @[fst (hd vntl), v] in
parse_rif_stream ic oc (tl vntl) stream tbl pragma
......
Supports Markdown
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