eval_add_constraint status [`Type,u1] [`Type,u2]
(* ex lexicon commands *)
| GrafiteAst.Interpretation (loc, dsc, (symbol, args), cic_appl_pattern) ->
- let rec disambiguate =
- function
- NotationPt.ApplPattern l ->
- NotationPt.ApplPattern (List.map disambiguate l)
- | NotationPt.VarPattern id
- when not
- (List.exists
- (function (NotationPt.IdentArg (_,id')) -> id'=id) args)
- ->
- let item = DisambiguateTypes.Id id in
- begin
- try
- match
- DisambiguateTypes.Environment.find item
- status#disambiguate_db.GrafiteDisambiguate.aliases
- with
- GrafiteAst.Ident_alias (_, uri) ->
- NotationPt.NRefPattern (NReference.reference_of_string uri)
- | _ -> assert false
- with Not_found ->
- prerr_endline
- ("LexiconEngine.eval_command: domain item not found: " ^
- (DisambiguateTypes.string_of_domain_item item));
- GrafiteDisambiguate.dump_aliases prerr_endline "" status;
- raise
- (Failure
- ((DisambiguateTypes.string_of_domain_item item) ^ " not found"))
- end
- | p -> p
+ let cic_appl_pattern =
+ GrafiteDisambiguate.disambiguate_cic_appl_pattern status args
+ cic_appl_pattern
in
- let cic_appl_pattern = disambiguate cic_appl_pattern in
eval_interpretation status (dsc,(symbol, args),cic_appl_pattern)
| GrafiteAst.Notation (loc, dir, l1, associativity, precedence, l2) ->
let l1 =
= fun o -> ((self#set_interp_status o)#set_disambiguate_db o#disambiguate_db)
end
+let eval_with_new_aliases status f =
+ let status =
+ status#set_disambiguate_db { status#disambiguate_db with new_aliases = [] } in
+ let res = f status in
+ let new_aliases = status#disambiguate_db.new_aliases in
+ new_aliases,res
+;;
+
let dump_aliases out msg status =
out (if msg = "" then "aliases dump:" else msg ^ ": aliases dump:");
DisambiguateTypes.Environment.iter (fun _ x -> out (GrafiteAstPp.pp_alias x))
in
estatus, cic
;;
+
+let disambiguate_cic_appl_pattern status args =
+ let rec disambiguate =
+ function
+ NotationPt.ApplPattern l ->
+ NotationPt.ApplPattern (List.map disambiguate l)
+ | NotationPt.VarPattern id
+ when not
+ (List.exists
+ (function (NotationPt.IdentArg (_,id')) -> id'=id) args)
+ ->
+ let item = DisambiguateTypes.Id id in
+ begin
+ try
+ match
+ DisambiguateTypes.Environment.find item
+ status#disambiguate_db.aliases
+ with
+ GrafiteAst.Ident_alias (_, uri) ->
+ NotationPt.NRefPattern (NReference.reference_of_string uri)
+ | _ -> assert false
+ with Not_found ->
+ prerr_endline
+ ("LexiconEngine.eval_command: domain item not found: " ^
+ (DisambiguateTypes.string_of_domain_item item));
+ dump_aliases prerr_endline "" status;
+ raise
+ (Failure
+ ((DisambiguateTypes.string_of_domain_item item) ^ " not found"))
+ end
+ | p -> p
+ in
+ disambiguate
+;;
* http://helm.cs.unibo.it/
*)
-type db = {
- aliases: GrafiteAst.alias_spec DisambiguateTypes.Environment.t;
- multi_aliases: GrafiteAst.alias_spec list DisambiguateTypes.Environment.t;
- new_aliases: (DisambiguateTypes.domain_item * GrafiteAst.alias_spec) list
-}
+type db
class type g_status =
object
method set_disambiguate_status: #g_status -> 'self
end
+val eval_with_new_aliases:
+ #status as 'status -> ('status -> 'a) ->
+ (DisambiguateTypes.domain_item * GrafiteAst.alias_spec) list * 'a
+
val set_proof_aliases:
#status as 'status ->
implicit_aliases:bool -> (* implicit ones are made explicit *)
val disambiguate_npattern:
GrafiteAst.npattern Disambiguate.disambiguator_input -> pattern
+
+val disambiguate_cic_appl_pattern:
+ #status ->
+ NotationPt.argument_pattern list ->
+ NotationPt.cic_appl_pattern -> NotationPt.cic_appl_pattern
let eval_ast ~include_paths ?do_heavy_checks status (text,prefix_len,ast) =
let baseuri = status#baseuri in
- let status =
- status#set_disambiguate_db { status#disambiguate_db with GrafiteDisambiguate.new_aliases = [] } in
- let status =
- GrafiteEngine.eval_ast ~include_paths ?do_heavy_checks status
- (text,prefix_len,ast) in
- let new_aliases = status#disambiguate_db.GrafiteDisambiguate.new_aliases in
+ let new_aliases,status =
+ GrafiteDisambiguate.eval_with_new_aliases status
+ (fun status ->
+ GrafiteEngine.eval_ast ~include_paths ?do_heavy_checks status
+ (text,prefix_len,ast)) in
let _,intermediate_states =
List.fold_left
(fun (status,acc) (k,value) ->