Commit 34237e20 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-12-02 23:22:25 by cvscast] Empty log message

Original author: cvscast
Date: 2002-12-02 23:22:25+00:00
parent 4728d2b7
......@@ -21,7 +21,6 @@ val descr: node -> descr
val equal_descr: descr -> descr -> bool
val hash_descr: descr -> int
module DescrHash: Hashtbl.S with type key = descr
module DescrMap: Map.S with type key = descr
......@@ -37,6 +36,8 @@ val neg : descr -> descr
val empty : descr
val any : descr
val any_node : node
(** Constructors **)
type pair_kind = [ `Normal | `XML ]
......
......@@ -374,24 +374,22 @@ and pat_aux seen s = match s.descr' with
raise (Patterns.Error "Difference not allowed in patterns")
| `Times (s1,s2) -> Patterns.times (pat_node s1) (pat_node s2)
| `Xml (s1,s2) -> Patterns.xml (pat_node s1) (pat_node s2)
| `Record (false,_) ->
(* TODO: handle this case with a type constraint ... *)
raise
(Patterns.Error "Closed records are not allowed in record patterns");
| `Record (true,r) ->
let l =
List.map
(fun (l,o,s) ->
if o then
raise
(Patterns.Error
"Optional field not allowed in record patterns");
Patterns.record l (pat_node s)
) r
in
(match l with
| [] -> Patterns.constr Types.Record.any
| h::t -> List.fold_left Patterns.cap h t)
| `Record (o,r) ->
let pats = ref [] in
let aux (l,o,s) =
if StringSet.is_empty (fv s) then (l,(o,type_node s))
else
if o then
raise
(Patterns.Error
"Optional field not allowed in record patterns")
else (
pats := Patterns.record l (pat_node s) :: !pats;
(l,(false,Types.any_node))
) in
let constr = Types.record' (o,List.map aux r) in
List.fold_left Patterns.cap (Patterns.constr constr) !pats
(* TODO: can avoid constr when o=true, and all fields have fv *)
| `Capture x -> Patterns.capture x
| `Constant (x,c) -> Patterns.constant x c
| `Arrow _ ->
......
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