method get_metasenv_and_term :
context:Cic.context ->
metasenv:Cic.metasenv -> Cic.metasenv * Cic.term
- method environment : DisambiguatingParser.Environment.t ref
+ method environment : DisambiguatingParser.EnvironmentP3.t ref
method reset : unit
method set_term : string -> unit
end
exception NoWellTypedInterpretation
-module Environment =
- struct
- type t = Disambiguate_types.environment
-
- let empty = Disambiguate_types.Environment.empty
-
- let to_string env =
-prerr_endline "TODO: implement and move away" ;
- Disambiguate_types.Environment.fold
- (fun i v s ->
- match i with
- | Disambiguate_types.Id id ->s ^ Printf.sprintf "alias %s %s\n" id (fst v)
- | _ -> "")
- env ""
-
- let of_string inputtext =
- let regexpr =
- let alfa = "[a-zA-Z_-]" in
- let digit = "[0-9]" in
- let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
- let blanks = "\( \|\t\|\n\)+" in
- let nonblanks = "[^ \t\n]+" in
- let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
- Str.regexp
- ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
- in
- let rec aux n =
- try
- let n' = Str.search_forward regexpr inputtext n in
- let id = Disambiguate_types.Id (Str.matched_group 2 inputtext) in
- let uri = "cic:" ^ (Str.matched_group 5 inputtext) in
- let resolve_id = aux (n' + 1) in
- if Disambiguate_types.Environment.mem id resolve_id then
- resolve_id
- else
- let term = Disambiguate.term_of_uri uri in
- (Disambiguate_types.Environment.add id (uri, (fun _ _ _ -> term))
- resolve_id)
- with
- Not_found -> Disambiguate_types.Environment.empty
- in
- aux 0
- end
-;;
+module EnvironmentP3 = Disambiguate_types.EnvironmentP3
module Make (C : Disambiguate_types.Callbacks) =
struct
exception NoWellTypedInterpretation
-module Environment :
+module EnvironmentP3 :
sig
type t
- val empty : t
+ val empty : string
val to_string : t -> string
val of_string : string -> t
end
Cic.context ->
Cic.metasenv ->
string ->
- Environment.t -> (* previous interpretation status *)
- Environment.t * (* new interpretation status *)
+ EnvironmentP3.t -> (* previous interpretation status *)
+ EnvironmentP3.t * (* new interpretation status *)
Cic.metasenv * (* new metasenv *)
Cic.term (* disambiguated term *)
end
(okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
ignore
(input#buffer#insert ~iter:(input#buffer#get_iter_at_char 0)
- (DisambiguatingParser.Environment.to_string !id_to_uris)) ;
+ (DisambiguatingParser.EnvironmentP3.to_string !id_to_uris)) ;
window#show () ;
GtkThread.main ();
if !chosen then
id_to_uris :=
- DisambiguatingParser.Environment.of_string (input#buffer#get_text ())
+ DisambiguatingParser.EnvironmentP3.of_string (input#buffer#get_text ())
;;
let proveit () =
method reset : unit
(* The input of set_term is unquoted *)
method set_term : string -> unit
- method environment : DisambiguatingParser.Environment.t ref
+ method environment : DisambiguatingParser.EnvironmentP3.t ref
end
module Make(C:Disambiguate_types.Callbacks) =
=
let environment =
match share_environment_with with
- None -> ref DisambiguatingParser.Environment.empty
+ None -> ref
+ (DisambiguatingParser.EnvironmentP3.of_string
+ DisambiguatingParser.EnvironmentP3.empty)
| Some obj -> obj#environment
in
let input = GText.view ~editable:true ?width ?height ?packing () in
metasenv:Cic.metasenv -> Cic.metasenv * Cic.term
method reset : unit
method set_term : string -> unit
- method environment : DisambiguatingParser.Environment.t ref
+ method environment : DisambiguatingParser.EnvironmentP3.t ref
end
module Make (C : Disambiguate_types.Callbacks) :