X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fcontent_pres%2FtermContentPres.ml;h=00f6c978982b5f7904f30a098c2eb699a401cd94;hb=11b2157bacf59cfc561c2ef6f92ee41ee2c1a006;hp=29845af1ded26666ec2467cd0e1bf22d17862364;hpb=8dba6e7197dc2badcf0451acf64435dfb7eb5386;p=helm.git diff --git a/helm/software/components/content_pres/termContentPres.ml b/helm/software/components/content_pres/termContentPres.ml index 29845af1d..00f6c9789 100644 --- a/helm/software/components/content_pres/termContentPres.ml +++ b/helm/software/components/content_pres/termContentPres.ml @@ -93,6 +93,13 @@ let string_of_sort_kind = function | `Set -> "Set" | `CProp _ -> "CProp" | `Type _ -> "Type" + | `NType s -> "Type[" ^ s ^ "]" + | `NCProp s -> "CProp[" ^ s ^ "]" + +let map_space f l = + HExtlib.list_concat + ~sep:[space] (List.map (fun x -> [f x]) l) +;; let pp_ast0 t k = let rec aux = @@ -144,16 +151,16 @@ let pp_ast0 t k = let mk_case_pattern = function Ast.Pattern (head, href, vars) -> - hvbox true false (ident_w_href href head :: List.map aux_var vars) + hvbox true true (ident_w_href href head :: + List.flatten (List.map (fun x -> [break;x]) (map_space aux_var vars))) | Ast.Wildcard -> builtin_symbol "_" in let patterns' = List.map (fun (lhs, rhs) -> remove_level_info - (hvbox false true [ - hbox false true [ - mk_case_pattern lhs; builtin_symbol "\\Rightarrow" ]; + (hovbox false true [ + mk_case_pattern lhs; break; builtin_symbol "\\Rightarrow"; break; top_pos (k rhs) ])) patterns in @@ -204,8 +211,8 @@ let pp_ast0 t k = match rec_kind with `Inductive -> "rec" | `CoInductive -> "corec" in let mk_fun (args, (name,ty), body, rec_param) = - List.map aux_var args ,k name, HExtlib.map_option k ty, k body, - fst (List.nth args rec_param) + List.flatten (List.map (fun x -> [aux_var x; space]) args), + k name, HExtlib.map_option k ty, k body, fst (List.nth args rec_param) in let mk_funs = List.map mk_fun in let fst_fun, tl_funs = @@ -218,9 +225,10 @@ let pp_ast0 t k = space; keyword rec_op; space; - name] @ + name; + space] @ params @ - [space; keyword "on" ; space ; rec_param ;space ] @ + [keyword "on" ; space ; rec_param ;space ] @ (match ty with None -> [] | Some ty -> [builtin_symbol ":"; ty]) @ [ builtin_symbol "\\def"; break; @@ -281,11 +289,32 @@ let pp_ast0 t k = (* persistent state *) -let level1_patterns21 = Hashtbl.create 211 - +let initial_level1_patterns21 () = Hashtbl.create 211 +let level1_patterns21 = ref (initial_level1_patterns21 ()) let compiled21 = ref None - let pattern21_matrix = ref [] +let counter = ref ~-1 + +let stack = ref [];; + +let push () = + stack := (!counter,!level1_patterns21,!compiled21,!pattern21_matrix)::!stack; + counter := ~-1; + level1_patterns21 := initial_level1_patterns21 (); + compiled21 := None; + pattern21_matrix := [] +;; + +let pop () = + match !stack with + [] -> assert false + | (ocounter,olevel1_patterns21,ocompiled21,opatterns21_matrix)::old -> + stack := old; + counter := ocounter; + level1_patterns21 := olevel1_patterns21; + compiled21 := ocompiled21; + pattern21_matrix := opatterns21_matrix +;; let get_compiled21 () = match !compiled21 with @@ -441,7 +470,7 @@ let rec pp_ast1 term = in let l1 = try - Hashtbl.find level1_patterns21 pid + Hashtbl.find !level1_patterns21 pid with Not_found -> assert false in instantiate21 idrefs (ast_env_of_env env) l1) @@ -470,11 +499,6 @@ let fill_pos_info l1_pattern = l1_pattern in aux true l1_pattern *) -let counter = ref ~-1 -let reset () = - counter := ~-1; - Hashtbl.clear level1_patterns21 -;; let fresh_id = fun () -> incr counter; @@ -484,14 +508,14 @@ let add_pretty_printer l2 (CicNotationParser.CL1P (l1,precedence)) = let id = fresh_id () in let l1' = add_level_info precedence (fill_pos_info l1) in let l2' = CicNotationUtil.strip_attributes l2 in - Hashtbl.add level1_patterns21 id l1'; + Hashtbl.add !level1_patterns21 id l1'; pattern21_matrix := (l2', id) :: !pattern21_matrix; load_patterns21 !pattern21_matrix; id let remove_pretty_printer id = (try - Hashtbl.remove level1_patterns21 id; + Hashtbl.remove !level1_patterns21 id; with Not_found -> raise Pretty_printer_not_found); pattern21_matrix := List.filter (fun (_, id') -> id <> id') !pattern21_matrix; load_patterns21 !pattern21_matrix @@ -582,6 +606,8 @@ let instantiate_level2 env term = | Ast.Magic magic -> aux_magic env magic | Ast.Variable var -> aux_variable env var + | Ast.Cast (t, ty) -> Ast.Cast (aux env t, aux env ty) + | _ -> assert false and aux_opt env = function | Some term -> Some (aux env term)