~alias_only status
=
if not alias_only then
- let t = refresh_uri_in_term (status :> NCic.status) t in
+ let t = refresh_uri_in_term (status :> NCicEnvironment.status) t in
basic_eval_unification_hint (t,n) status
else
status
let basic_eval_input_notation (l1,l2) status =
GrafiteParser.extend status l1
(fun env loc ->
- let rec inner_loc default = function
- | [] -> default
- | (_,(NotationEnv.NoType,NotationEnv.LocValue l))::_ -> l
- | _::tl -> inner_loc default tl
+ let rec get_disamb = function
+ | [] -> Stdpp.dummy_loc,None,None
+ | (_,(NotationEnv.NoType,NotationEnv.DisambiguationValue dv))::_ -> dv
+ | _::tl -> get_disamb tl
in
- let inner_loc = inner_loc loc env in
- let l2' = TermContentPres.instantiate_level2 status env inner_loc l2 in
+ let l2' = TermContentPres.instantiate_level2 status env (get_disamb env) l2 in
prerr_endline ("new l2 ast : " ^ (NotationPp.pp_term status l2'));
NotationPt.AttributedTerm (`Loc loc,l2'))
;;
if not alias_only then
let l1 =
CicNotationParser.refresh_uri_in_checked_l1_pattern
- ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCic.status))
+ ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCicEnvironment.status))
~refresh_uri_in_reference l1 in
let l2 = NotationUtil.refresh_uri_in_term
- ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCic.status))
+ ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCicEnvironment.status))
~refresh_uri_in_reference l2
in
basic_eval_input_notation (l1,l2) status
if not alias_only then
let l1 =
CicNotationParser.refresh_uri_in_checked_l1_pattern
- ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCic.status))
+ ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCicEnvironment.status))
~refresh_uri_in_reference l1 in
let l2 = NotationUtil.refresh_uri_in_term
- ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCic.status))
+ ~refresh_uri_in_term:(refresh_uri_in_term (status:>NCicEnvironment.status))
~refresh_uri_in_reference l2
in
basic_eval_output_notation (l1,l2) status
let aux l ~refresh_uri_in_universe
~refresh_uri_in_term ~refresh_uri_in_reference ~alias_only status
=
- let refresh_uri_in_term = refresh_uri_in_term (status:>NCic.status) in
+ let refresh_uri_in_term = refresh_uri_in_term (status:>NCicEnvironment.status) in
if not alias_only then
basic_index_obj
(List.map
(* NCicLibrary.add_constraint adds the constraint to the NCicEnvironment
* and also to the storage (for undo/redo). During inclusion of compiled
* files the storage must not be touched. *)
- NCicEnvironment.add_lt_constraint u1 u2;
+ NCicEnvironment.add_lt_constraint status u1 u2;
status
else
status
GrafiteTypes.Serializer.require
~alias_only ~baseuri ~fname:fullpath status
| GrafiteAst.UnificationHint (loc, t, n) -> eval_unification_hint status t n
- | GrafiteAst.NCoercion (loc, name, t, ty, source, target) ->
+ | GrafiteAst.NCoercion (loc, name, None) ->
+ let status, t, ty, source, target =
+ let o_t = NotationPt.Ident (name,`Ambiguous) in
+ let metasenv,subst, status,t =
+ GrafiteDisambiguate.disambiguate_nterm
+ status None [] [] [] ("",0,o_t) in
+ assert( metasenv = [] && subst = []);
+ let ty = NCicTypeChecker.typeof status [] [] [] t in
+ let source, target =
+ let clean = function
+ | NCic.Appl (NCic.Const _ as r :: l) ->
+ NotationPt.Appl (NotationPt.NCic r ::
+ List.map (fun _ -> NotationPt.Implicit `JustOne)l)
+ | NCic.Const _ as r -> NotationPt.NCic r
+ | _ -> assert false in
+ let rec aux = function
+ | NCic.Prod (_,_, (NCic.Prod _ as rest)) -> aux rest
+ | NCic.Prod (name, src, tgt) -> (name, clean src), clean tgt
+ | _ -> assert false in aux ty in
+ status, o_t, NotationPt.NCic ty, source, target in
+ let status, composites =
+ NCicCoercDeclaration.eval_ncoercion status name t ty source target in
+ let mode = GrafiteAst.WithPreferences in (* MATITA 1.0: fixme *)
+ let aliases = GrafiteDisambiguate.aliases_for_objs status composites in
+ eval_alias status (mode,aliases)
+ | GrafiteAst.NCoercion (loc, name, Some (t, ty, source, target)) ->
let status, composites =
NCicCoercDeclaration.eval_ncoercion status name t ty source target in
let mode = GrafiteAst.WithPreferences in (* MATITA 1.0: fixme *)
let status = status#set_ng_mode `CommandMode in status)
status
(NCic.Prop::
- List.map (fun s -> NCic.Type s) (NCicEnvironment.get_universes ()))
+ List.map (fun s -> NCic.Type s)
+ (NCicEnvironment.get_universes status))
| _ -> status
in
let coercions =
if dir <> Some `RightToLeft then eval_input_notation status (l1,l2)
else status
in
+ let status =
if dir <> Some `LeftToRight then eval_output_notation status (l1,l2)
else status
+ in prerr_endline ("new grammar:\n" ^ (Print_grammar.ebnf_of_term status));
+ status
| GrafiteAst.Alias (loc, spec) ->
let diff =
(*CSC: Warning: this code should be factorized with the corresponding