80889
|
1 |
(* Title: Pure/markup_expression.ML
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Formally defined kind for Markup.expression.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature MARKUP_EXPRESSION =
|
|
8 |
sig
|
|
9 |
val check_kind: Proof.context -> xstring * Position.T -> string
|
|
10 |
val setup_kind: binding -> theory -> string * theory
|
80902
|
11 |
val check: Proof.context -> xstring * Position.T -> Markup.T
|
80889
|
12 |
val setup: binding -> Markup.T
|
80912
|
13 |
val markup_type: Markup.T
|
|
14 |
val markup_type_application: Markup.T
|
|
15 |
val markup_term: Markup.T
|
|
16 |
val markup_term_application: Markup.T
|
80915
|
17 |
val markup_term_abstraction: Markup.T
|
80912
|
18 |
val markup_prop: Markup.T
|
|
19 |
val markup_prop_application: Markup.T
|
80915
|
20 |
val markup_prop_abstraction: Markup.T
|
80889
|
21 |
end;
|
|
22 |
|
|
23 |
structure Markup_Expression: MARKUP_EXPRESSION =
|
|
24 |
struct
|
|
25 |
|
|
26 |
(* theory data *)
|
|
27 |
|
|
28 |
structure Data = Theory_Data
|
|
29 |
(
|
|
30 |
type T = unit Name_Space.table;
|
|
31 |
val empty : T = Name_Space.empty_table "markup_expression_kind";
|
|
32 |
fun merge data : T = Name_Space.merge_tables data;
|
|
33 |
);
|
|
34 |
|
80902
|
35 |
|
|
36 |
(* kind *)
|
|
37 |
|
80889
|
38 |
fun check_kind ctxt =
|
|
39 |
Name_Space.check (Context.Proof ctxt) (Data.get (Proof_Context.theory_of ctxt)) #> #1;
|
|
40 |
|
|
41 |
fun setup_kind binding thy =
|
|
42 |
let
|
|
43 |
val context = Name_Space.map_naming (K Name_Space.global_naming) (Context.Theory thy);
|
|
44 |
val (name, data') = Name_Space.define context true (binding, ()) (Data.get thy);
|
|
45 |
in (name, Data.put data' thy) end;
|
|
46 |
|
80902
|
47 |
|
|
48 |
(* markup *)
|
|
49 |
|
|
50 |
fun check ctxt = check_kind ctxt #> Markup.expression;
|
|
51 |
|
80889
|
52 |
fun setup binding =
|
|
53 |
Context.>>> (Context.map_theory_result (setup_kind binding #>> Markup.expression));
|
|
54 |
|
80912
|
55 |
|
|
56 |
(* concrete markup *)
|
|
57 |
|
|
58 |
val markup_type = setup (Binding.make ("type", \<^here>));
|
|
59 |
val markup_type_application = setup (Binding.make ("type_application", \<^here>));
|
|
60 |
|
|
61 |
val markup_term = setup (Binding.make ("term", \<^here>));
|
|
62 |
val markup_term_application = setup (Binding.make ("term_application", \<^here>));
|
80915
|
63 |
val markup_term_abstraction = setup (Binding.make ("term_abstraction", \<^here>));
|
80912
|
64 |
|
|
65 |
val markup_prop = setup (Binding.make ("prop", \<^here>));
|
|
66 |
val markup_prop_application = setup (Binding.make ("prop_application", \<^here>));
|
80915
|
67 |
val markup_prop_abstraction = setup (Binding.make ("prop_abstraction", \<^here>));
|
80912
|
68 |
|
80889
|
69 |
end;
|