X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2FcicNotationMatcher.ml;h=204e945fc0c8b700388b30502709afcee1b8631b;hb=5d5e328a05ed70fcf565aef8f92b7ec87b2740f2;hp=f8f73e66bf9cba5dd2aadabb71feed686dcdcd91;hpb=bf6144a808a16d4e576e56593bbcd63b8db5fe4c;p=helm.git diff --git a/helm/ocaml/cic_notation/cicNotationMatcher.ml b/helm/ocaml/cic_notation/cicNotationMatcher.ml index f8f73e66b..204e945fc 100644 --- a/helm/ocaml/cic_notation/cicNotationMatcher.ml +++ b/helm/ocaml/cic_notation/cicNotationMatcher.ml @@ -117,14 +117,12 @@ struct let variable_closure k = (fun matched_terms terms -> - prerr_endline "variable_closure"; match terms with | hd :: tl -> k (hd :: matched_terms) tl | _ -> assert false) let constructor_closure ks k = (fun matched_terms terms -> - prerr_endline "constructor_closure"; match terms with | t :: tl -> (try @@ -187,7 +185,7 @@ struct | Pt.Variable _ -> Variable | Pt.Magic _ | Pt.Layout _ - | Pt.Literal _ -> assert false + | Pt.Literal _ as t -> assert false | _ -> Constructor let tag_of_pattern = CicNotationTag.get_tag let tag_of_term = CicNotationTag.get_tag @@ -203,7 +201,7 @@ struct Pt.Variable (Pt.TermVar name) in let rec aux = function - | Pt.AttributedTerm (_, t) -> aux t + | Pt.AttributedTerm (_, t) -> assert false | Pt.Literal _ | Pt.Layout _ -> assert false | Pt.Variable v -> Pt.Variable v @@ -226,9 +224,6 @@ struct | _ -> assert false) pl tl - let decls_of_pattern p = - List.map Env.declaration_of_var (Util.variables_of_term p) - let rec compiler rows = let rows', magic_maps = List.split @@ -261,7 +256,6 @@ struct candidates in let match_cb rows = - prerr_endline (sprintf "match_cb on %d row(s)" (List.length rows)); let candidates = List.map (fun (pl, pid) -> @@ -273,14 +267,13 @@ struct in magichooser candidates in - M.compiler rows match_cb (fun _ -> None) + M.compiler rows' match_cb (fun _ -> None) and compile_magic = function | Pt.Fold (kind, p_base, names, p_rec) -> - let p_rec_decls = decls_of_pattern p_rec in + let p_rec_decls = Env.declarations_of_term p_rec in let acc_name = try List.hd names with Failure _ -> assert false in - let t_magic = [p_base, 0; p_rec, 1] in - let compiled = compiler t_magic in + let compiled = compiler [p_base, 0; p_rec, 1] in (fun term env -> let rec aux term = match compiled term with @@ -301,6 +294,15 @@ struct | None -> None | Some (base_env, rec_envl) -> Some (base_env @ Env.coalesce_env p_rec_decls rec_envl)) + | Pt.Default (p_some, p_none) -> (* p_none can't bound names *) + let p_some_decls = Env.declarations_of_term p_some in + let none_env = List.map Env.opt_binding_of_name p_some_decls in + let compiled = compiler [p_some, 0] in + (fun term env -> + match compiled term with + | None -> Some none_env + | Some (env', 0) -> Some (List.map Env.opt_binding_some env' @ env) + | _ -> assert false) | _ -> assert false end @@ -310,7 +312,7 @@ struct struct type cic_mask_t = Blob - | Uri of string + | Uri of UriManager.uri | Appl of cic_mask_t list let uri_of_term t = CicUtil.uri_of_term (Deannotate.deannotate_term t) @@ -328,7 +330,7 @@ struct Hashtbl.hash mask, tl let mask_of_appl_pattern = function - | Pt.UriPattern s -> Uri s, [] + | Pt.UriPattern uri -> Uri uri, [] | Pt.VarPattern _ -> Blob, [] | Pt.ApplPattern pl -> Appl (List.map (fun _ -> Blob) pl), pl @@ -348,7 +350,6 @@ struct let compiler rows = let match_cb rows = - prerr_endline (sprintf "match_cb on %d row(s)" (List.length rows)); let pl, pid = try List.hd rows with Not_found -> assert false in (fun matched_terms -> let env =