PrimitiveTactics.intros_tac ~mk_fresh_name_callback:(namer_of names) ()
| TacticAst.Intros (_, Some num, names) ->
(* TODO Zack implement intros length *)
- PrimitiveTactics.intros_tac ~howmany:num ~mk_fresh_name_callback:(namer_of names) ()
+ PrimitiveTactics.intros_tac ~howmany:num
+ ~mk_fresh_name_callback:(namer_of names) ()
| TacticAst.Reflexivity _ -> Tactics.reflexivity
| TacticAst.Assumption _ -> Tactics.assumption
| TacticAst.Contradiction _ -> Tactics.contradiction
UriManager.uri_of_string (MatitaMisc.qualify status name ^ ".con")
in
let metasenv = MatitaMisc.get_proof_metasenv status in
- debug_print ("XXXXXXXXXX" ^ CicPp.ppterm body);
let (body_type, ugraph) =
CicTypeChecker.type_of_aux' metasenv [] body CicUniv.empty_ugraph
in
in
aux
+let add_trailing_slash =
+ let rex = Pcre.regexp "/$" in
+ fun s ->
+ if Pcre.pmatch ~rex s then s
+ else s ^ "/"
+
+let strip_blanks =
+ let rex = Pcre.regexp "^\\s*([^\\s]*)\\s*$" in
+ fun s ->
+ (Pcre.extract ~rex s).(1)
+
(** inherit from this class if you want to access current script *)
class scriptAccessor =
object (self)
=
let term_RE = Pcre.regexp "^term:(.*)" in
let whelp_RE = Pcre.regexp "^\\s*whelp" in
+ let uri_RE =
+ Pcre.regexp
+ "^cic:/(\\w+/)*\\w+\\.(con|ind|var)(#xpointer\\(\\d+(/\\d+)+\\))?$"
+ in
+ let dir_RE = Pcre.regexp "^cic:((/(\\w+/)*\\w+(/)?)|/|)$" in
let whelp_query_RE = Pcre.regexp "^\\s*whelp\\s+([^\\s]+)\\s+(.*)$" in
let trailing_slash_RE = Pcre.regexp "/$" in
let has_xpointer_RE = Pcre.regexp "#xpointer\\(\\d+/\\d+(/\\d+)?\\)$" in
method private _loadDir dir =
let content = Http_getter.ls dir in
- let l = List.map (function
- | Http_getter_types.Ls_section sec -> "dir", sec
- | Http_getter_types.Ls_object obj -> "obj", obj.Http_getter_types.uri
- ) content
+ let l =
+ List.map
+ (function
+ | Http_getter_types.Ls_section s -> "dir", s
+ | Http_getter_types.Ls_object o -> "obj", o.Http_getter_types.uri)
+ content
in
self#_loadList l
(** { public methods, all must call _load!! } *)
- method load uri =
- handle_error (fun () -> self#_load uri);
- self#_historyAdd uri
+ method load entry =
+ handle_error (fun () -> self#_load entry; self#_historyAdd entry)
(** this is what the browser does when you enter a string an hit enter *)
- method loadInput txt =
- let add_terminating_slash s =
- if not(Pcre.pmatch ~rex:trailing_slash_RE s) &&
- not(Pcre.pmatch ~rex:has_xpointer_RE s) then s^"/" else s
- in
- let is_uri txt =
- try
- let u = UriManager.strip_xpointer (UriManager.uri_of_string txt) in
- ignore (Http_getter.resolve' u);
- true
- with
- | Http_getter_types.Key_not_found _
- | Http_getter_types.Unresolvable_URI _
- | UriManager.IllFormedUri ("cic:/" | "cic:") -> false
- | UriManager.IllFormedUri u -> failwith ("Malformed URI '" ^ u ^ "'")
- in
+ method loadInput txt =
+ let txt = strip_blanks txt in
let is_whelp txt = Pcre.pmatch ~rex:whelp_RE txt in
- if is_whelp txt then
- begin
- set_whelp_query txt;
-
-
- (MatitaScript.instance ())#advance ~statement:(txt^".") ()
- end
- else
- begin
- let entry =
- if is_uri txt then
- (`Uri txt)
- else
- (`Dir (add_terminating_slash txt))
- in
- self#_load entry;
- self#_historyAdd entry
- end
-
-
+ let is_uri txt = Pcre.pmatch ~rex:uri_RE txt in
+ let is_dir txt = Pcre.pmatch ~rex:dir_RE txt in
+ let fix_uri txt =
+ UriManager.string_of_uri
+ (UriManager.strip_xpointer (UriManager.uri_of_string txt))
+ in
+ if is_whelp txt then begin
+ set_whelp_query txt;
+ (MatitaScript.instance ())#advance ~statement:(txt ^ ".") ()
+ end else begin
+ let entry =
+ match txt with
+ | txt when is_uri txt -> `Uri (fix_uri txt)
+ | txt when is_dir txt -> `Dir (add_trailing_slash txt)
+ | _ -> raise (Browser_failure (sprintf "unsupported uri: %s" txt))
+ in
+ self#_load entry;
+ self#_historyAdd entry
+ end
+
(** {2 methods used by constructor only} *)
method win = win