Commit 71c8958c authored by Pietro Abate's avatar Pietro Abate

fix type printing parenthesis problem

parent 3903816f
......@@ -41,7 +41,7 @@ let tests_typer_list = [
"Test CDuce.typed.fun.partial 2",
"fun f x : 'A : 'A -> 2",
"let id ( y : 'A ) : 'B = y in id";
"let id ( y : 'A ) : 'A = y in id";
]
......
......@@ -1845,13 +1845,14 @@ struct
(* base types *)
prepare_boolvar BoolChars.get (Chars.equal Chars.full) (fun bdd ->
match Chars.is_char bdd with
| Some c -> [(Char c)]
| None -> [(Union(alloc (List.map (fun x -> (Atomic x)) (Chars.print bdd))))]
| Some c -> [Char c]
| None -> [Union(alloc (List.map (fun x -> (Atomic x)) (Chars.print bdd)))]
) not_seq.toplvars not_seq.chars;
prepare_boolvar BoolIntervals.get (Intervals.equal Intervals.full) (fun bdd ->
[(Union(alloc (List.map (fun x -> (Atomic x)) (Intervals.print bdd))))]
(* List.map (fun x -> (Atomic x)) (Intervals.print bdd) *)
match Intervals.print bdd with
|[x] -> [Atomic x]
|l -> [Union(alloc (List.map (fun x -> (Atomic x)) l))]
) not_seq.toplvars not_seq.ints;
let bool =
......@@ -1860,11 +1861,11 @@ struct
(Atoms.atom (Atoms.V.mk_ascii "true"))
in
prepare_boolvar BoolAtoms.get (Atoms.equal Atoms.full) (fun bdd ->
if Atoms.equal bool bdd then
match Atoms.print bdd with
|[x] when (Atoms.equal bool bdd) ->
[Atomic (fun ppf -> Format.fprintf ppf "Bool")]
else
[(Union(alloc (List.map (fun x -> (Atomic x)) (Atoms.print bdd))))]
(* List.map (fun x -> (Atomic x)) (Atoms.print bdd) *)
|[x] -> [Atomic x]
|l -> [Union(alloc (List.map (fun x -> (Atomic x)) l))]
) not_seq.toplvars not_seq.atoms;
(* pairs *)
......@@ -1961,7 +1962,7 @@ struct
| Name _ | Char _ | Atomic _ -> ()
| Regexp r -> assign_name_regexp r
| Pair (t1,t2) -> assign_name t1; assign_name t2
| Intersection t -> () (* assign_name t *)
| Intersection t -> () (* assign_name_rec t.def ??? *)
| Union t -> () (* assign_name t *)
| Xml (tag,t2,t3) ->
(match tag with `Type t -> assign_name t | _ -> ());
......@@ -1993,9 +1994,10 @@ struct
| [ h ] -> (do_print pri) ppf h
| h :: t -> Format.fprintf ppf "%a %s@ %a" (do_print pri) h sep aux t
in
if (pri >= 2) && (List.length def >= 2)
then Format.fprintf ppf "@[(%a)@]" aux def
else aux ppf def
if (pri >= 2) && (List.length def >= 2) then
Format.fprintf ppf "@[(%a)@]" aux def
else
aux ppf def
and do_print pri ppf =
function
| Neg { def = [] } -> Format.fprintf ppf "Any"
......@@ -2005,8 +2007,8 @@ struct
| Char c -> Chars.V.print ppf c
| Regexp r -> Format.fprintf ppf "@[[ %a ]@]" (do_print_regexp 0) r
| Atomic a -> a ppf
| Intersection a -> Format.fprintf ppf "@[%a@]" (do_print_slot ~sep:"&" 0) a
| Union a -> Format.fprintf ppf "@[%a@]" (do_print_slot ~sep:"|" 0) a
| Intersection a -> Format.fprintf ppf "@[%a@]" (do_print_slot ~sep:"&" 2) a
| Union a -> Format.fprintf ppf "@[%a@]" (do_print_slot ~sep:"|" 2) a
| Pair (t1,t2) ->
Format.fprintf ppf "@[(%a,%a)@]"
(do_print_slot 0) t1
......
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