(* interface functions ******************************************************)
let procedural_of_acic_object ~ids_to_inner_sorts ~ids_to_inner_types ?depth
- prefix anobj =
+ ?flavour prefix anobj =
let st = {
sorts = ids_to_inner_sorts;
types = ids_to_inner_types;
val procedural_of_acic_object:
ids_to_inner_sorts:(Cic.id, Cic2acic.sort_kind) Hashtbl.t ->
ids_to_inner_types:(Cic.id, Cic2acic.anntypes) Hashtbl.t ->
- ?depth:int -> string -> Cic.annobj ->
+ ?depth:int -> ?flavour:Cic.object_flavour -> string -> Cic.annobj ->
(Cic.annterm, Cic.annterm,
Cic.annterm GrafiteAst.reduction, Cic.annterm CicNotationPt.obj, string)
GrafiteAst.statement list
| T.Declarative -> G.Declarative
| T.Procedural -> G.Procedural None
in
- command_of_macro (G.Inline (floc, kind, uri, prefix))
+ command_of_macro (G.Inline (floc, kind, uri, prefix, None))
let out_alias och name uri =
Printf.fprintf och "alias id \"%s\" = \"%s\".\n\n" name uri
| Check of loc * 'term
| Hint of loc * bool
| AutoInteractive of loc * 'term auto_params
- | Inline of loc * presentation_style * string * string
- (* URI or base-uri, name prefix *)
+ | Inline of loc * presentation_style * string * string * Cic.object_flavour option
+ (* URI or base-uri, name prefix, flavour *)
(** To be increased each time the command type below changes, used for "safe"
* marshalling *)
let prefix_pp prefix =
if prefix = "" then "" else Printf.sprintf " \"%s\"" prefix
in
+ let flavour_pp = function
+ | None -> ""
+ | Some `Definition -> "as definition"
+ | Some `MutualDefinition -> "as mutual"
+ | Some `Fact -> "as fact"
+ | Some `Lemma -> "as lemma"
+ | Some `Remark -> "as remark"
+ | Some `Theorem -> "as theorem"
+ | Some `Variant -> "as variant"
+ | Some `Axiom -> "as axiom"
+ in
function
(* Whelp *)
| WInstance (_, term) -> "whelp instance " ^ term_pp term
| Hint (_, true) -> "hint rewrite"
| Hint (_, false) -> "hint"
| AutoInteractive (_,params) -> "auto " ^ pp_auto_params ~term_pp params
- | Inline (_, style, suri, prefix) ->
- Printf.sprintf "inline %s\"%s\"%s" (style_pp style) suri (prefix_pp prefix)
+ | Inline (_, style, suri, prefix, flavour) ->
+ Printf.sprintf "inline %s\"%s\"%s%s" (style_pp style) suri (prefix_pp prefix) (flavour_pp flavour)
let pp_associativity = function
| Gramext.LeftA -> "left associative"
| [ IDENT "theorem" ] -> `Theorem
]
];
+ inline_flavour: [
+ [ attr = theorem_flavour -> attr
+ | [ IDENT "axiom" ] -> `Axiom
+ | [ IDENT "mutual" ] -> `MutualDefinition
+ ]
+ ];
inductive_spec: [ [
fst_name = IDENT; params = LIST0 CicNotationParser.protected_binder_vars;
SYMBOL ":"; fst_typ = term; SYMBOL <:unicode<def>>; OPT SYMBOL "|";
GrafiteAst.Check (loc, t)
| [ IDENT "inline"];
style = OPT [ IDENT "procedural"; depth = OPT int -> depth ];
- suri = QSTRING; prefix = OPT QSTRING ->
+ suri = QSTRING; prefix = OPT QSTRING;
+ flavour = OPT [ IDENT "as"; attr = inline_flavour -> attr ]->
let style = match style with
| None -> GrafiteAst.Declarative
| Some depth -> GrafiteAst.Procedural depth
in
let prefix = match prefix with None -> "" | Some prefix -> prefix in
- GrafiteAst.Inline (loc,style,suri,prefix)
+ GrafiteAst.Inline (loc,style,suri,prefix, flavour)
| [ IDENT "hint" ]; rew = OPT (IDENT "rewrite") ->
if rew = None then GrafiteAst.Hint (loc, false) else GrafiteAst.Hint (loc,true)
| IDENT "auto"; params = auto_params ->
remove_closed_substs s
let txt_of_cic_object
- ~map_unicode_to_tex ?skip_thm_and_qed ?skip_initial_lambdas n style prefix obj
+ ~map_unicode_to_tex ?skip_thm_and_qed ?skip_initial_lambdas
+ n style ?flavour prefix obj
=
let get_aobj obj =
try
let script =
Acic2Procedural.procedural_of_acic_object
~ids_to_inner_sorts ~ids_to_inner_types
- ?depth prefix aobj
+ ?depth ?flavour prefix aobj
in
"\n\n" ^ String.concat "" (List.map aux script)
-let txt_of_inline_uri ~map_unicode_to_tex style suri prefix =
+let txt_of_inline_uri ~map_unicode_to_tex style ?flavour prefix suri =
let print_exc = function
| ProofEngineHelpers.Bad_pattern s as e ->
Printexc.to_string e ^ " " ^ Lazy.force s
let map uri =
try
txt_of_cic_object
- ~map_unicode_to_tex 78 style prefix
+ ~map_unicode_to_tex 78 style ?flavour prefix
(fst (CicEnvironment.get_obj CicUniv.empty_ugraph uri))
with
| e ->
in
String.concat "" (List.map map sorted_uris)
-let txt_of_inline_macro ~map_unicode_to_tex style name prefix =
+let txt_of_inline_macro ~map_unicode_to_tex style ?flavour prefix name =
let suri =
if Librarian.is_uri name then name else
let include_paths =
in
baseuri ^ "/"
in
- txt_of_inline_uri ~map_unicode_to_tex style suri prefix
+ txt_of_inline_uri ~map_unicode_to_tex style ?flavour prefix suri
(****************************************************************************)
(* procedural_txt_of_cic_term *)
map_unicode_to_tex:bool -> output_type:[`Pattern | `Term] -> int ->
Cic.metasenv -> Cic.conjecture -> string
-(* columns, rendering style, name prefix, object *)
+(* columns, rendering style, flavour, name prefix, object *)
val txt_of_cic_object:
map_unicode_to_tex:bool ->
- ?skip_thm_and_qed:bool ->
- ?skip_initial_lambdas:int ->
- int -> GrafiteAst.presentation_style -> string ->
- Cic.obj ->
+ ?skip_thm_and_qed:bool -> ?skip_initial_lambdas:int ->
+ int -> GrafiteAst.presentation_style -> ?flavour:Cic.object_flavour ->
+ string -> Cic.obj ->
string
-(* presentation_style, uri or baseuri, name prefix *)
+(* presentation_style, flavour, name prefix, uri or baseuri *)
val txt_of_inline_macro:
- map_unicode_to_tex:bool ->
- GrafiteAst.presentation_style -> string -> string -> string
+ map_unicode_to_tex:bool -> GrafiteAst.presentation_style ->
+ ?flavour:Cic.object_flavour -> string -> string ->
+ string
(* columns, rendering depth, context, term *)
val procedural_txt_of_cic_term:
ProofEngineTypes.Fail _ as exn ->
raise exn
(* [], comment parsed_text ^ "\nfail.\n", parsed_text_length *))
- | TA.Inline (_,style,suri,prefix) ->
+ | TA.Inline (_,style,suri,prefix,flavour) ->
let str =
ApplyTransformation.txt_of_inline_macro
~map_unicode_to_tex:(Helm_registry.get_bool
"matita.paste_unicode_as_tex")
- style suri prefix
+ style ?flavour prefix suri
in
[], str, String.length parsed_text
with MatitaEngine.EnrichedWithLexiconStatus
(GrafiteEngine.Macro (floc, f), lex_status) as exn ->
match f (get_macro_context (Some grafite_status)) with
- | _, GrafiteAst.Inline (_, style, suri, prefix) ->
+ | _, GrafiteAst.Inline (_, style, suri, prefix, flavour) ->
let str =
- ApplyTransformation.txt_of_inline_macro style suri prefix
- ~map_unicode_to_tex:(Helm_registry.get_bool
- "matita.paste_unicode_as_tex") in
+ ApplyTransformation.txt_of_inline_macro style prefix suri
+ ?flavour
+ ~map_unicode_to_tex:(Helm_registry.get_bool
+ "matita.paste_unicode_as_tex")
+ in
!out str;
aux_for_dump x
|_-> raise exn