author | wenzelm |
Mon, 02 Apr 2012 19:10:52 +0200 | |
changeset 47274 | feef9b0b6031 |
parent 47251 | 13a770bd5544 |
child 47275 | fc95b8b6c260 |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: Pure/Isar/named_target.ML |
20894 | 2 |
Author: Makarius |
30437 | 3 |
Author: Florian Haftmann, TU Muenchen |
20894 | 4 |
|
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47061
diff
changeset
|
5 |
Targets for theory, locale, class -- at the bottom the nested structure. |
20894 | 6 |
*) |
7 |
||
38350
480b2de9927c
renamed Theory_Target to the more appropriate Named_Target
haftmann
parents:
38349
diff
changeset
|
8 |
signature NAMED_TARGET = |
20894 | 9 |
sig |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47061
diff
changeset
|
10 |
val peek: local_theory -> {target: string, is_locale: bool, is_class: bool} option |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
11 |
val init: (local_theory -> local_theory) -> string -> theory -> local_theory |
38388 | 12 |
val theory_init: theory -> local_theory |
38391
ba1cc1815ce1
named target is optional; explicit Name_Target.reinit
haftmann
parents:
38389
diff
changeset
|
13 |
val reinit: local_theory -> local_theory -> local_theory |
45488
6d71d9e52369
pass positions for named targets, for formal links in the document model;
wenzelm
parents:
45390
diff
changeset
|
14 |
val context_cmd: xstring * Position.T -> theory -> local_theory |
20894 | 15 |
end; |
16 |
||
38350
480b2de9927c
renamed Theory_Target to the more appropriate Named_Target
haftmann
parents:
38349
diff
changeset
|
17 |
structure Named_Target: NAMED_TARGET = |
20894 | 18 |
struct |
19 |
||
21006 | 20 |
(* context data *) |
21 |
||
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
22 |
datatype target = |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
23 |
Target of {target: string, is_locale: bool, is_class: bool, |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
24 |
before_exit: local_theory -> local_theory}; |
25012
448af76a1ba3
pass explicit target record -- more informative peek operation;
wenzelm
parents:
25002
diff
changeset
|
25 |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
26 |
fun make_target target is_locale is_class before_exit = |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
27 |
Target {target = target, is_locale = is_locale, is_class = is_class, |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
28 |
before_exit = before_exit}; |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
29 |
|
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
30 |
fun named_target _ "" before_exit = make_target "" false false before_exit |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
31 |
| named_target thy locale before_exit = |
38378 | 32 |
if Locale.defined thy locale |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
33 |
then make_target locale true (Class.is_class thy locale) before_exit |
38378 | 34 |
else error ("No such locale: " ^ quote locale); |
25012
448af76a1ba3
pass explicit target record -- more informative peek operation;
wenzelm
parents:
25002
diff
changeset
|
35 |
|
33519 | 36 |
structure Data = Proof_Data |
21006 | 37 |
( |
38391
ba1cc1815ce1
named target is optional; explicit Name_Target.reinit
haftmann
parents:
38389
diff
changeset
|
38 |
type T = target option; |
ba1cc1815ce1
named target is optional; explicit Name_Target.reinit
haftmann
parents:
38389
diff
changeset
|
39 |
fun init _ = NONE; |
21006 | 40 |
); |
41 |
||
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
42 |
val peek = |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
43 |
Data.get #> Option.map (fn Target {target, is_locale, is_class, ...} => |
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
44 |
{target = target, is_locale = is_locale, is_class = is_class}); |
21006 | 45 |
|
46 |
||
47246
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
47 |
(* consts in locale *) |
24838 | 48 |
|
47246
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
49 |
fun locale_const (Target {target, is_class, ...}) (prmode as (mode, _)) ((b, mx), rhs) = |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
50 |
Generic_Target.locale_declaration target true (fn phi => |
45352 | 51 |
let |
52 |
val b' = Morphism.binding phi b; |
|
53 |
val rhs' = Morphism.term phi rhs; |
|
54 |
val arg = (b', Term.close_schematic_term rhs'); |
|
55 |
val same_shape = Term.aconv_untyped (rhs, rhs'); |
|
38297 | 56 |
|
45352 | 57 |
(* FIXME workaround based on educated guess *) |
58 |
val prefix' = Binding.prefix_of b'; |
|
59 |
val is_canonical_class = is_class andalso |
|
60 |
(Binding.eq_name (b, b') |
|
61 |
andalso not (null prefix') |
|
62 |
andalso List.last prefix' = (Class.class_prefix target, false) |
|
63 |
orelse same_shape); |
|
64 |
in |
|
65 |
not is_canonical_class ? |
|
66 |
(Context.mapping_result |
|
67 |
(Sign.add_abbrev Print_Mode.internal arg) |
|
68 |
(Proof_Context.add_abbrev Print_Mode.internal arg) |
|
69 |
#-> (fn (lhs' as Const (d, _), _) => |
|
70 |
same_shape ? |
|
71 |
(Context.mapping |
|
72 |
(Sign.revert_abbrev mode d) (Proof_Context.revert_abbrev mode d) #> |
|
47247 | 73 |
Morphism.form (Proof_Context.generic_notation true prmode [(lhs', mx)])))) |
45352 | 74 |
end); |
38305 | 75 |
|
38297 | 76 |
|
38318
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
77 |
(* define *) |
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
78 |
|
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
79 |
fun locale_foundation ta (((b, U), mx), (b_def, rhs)) (type_params, term_params) = |
38341
72dba5bd5f63
moved theory-level target operation fragements to Generic_Target; adjusted bootstrap order
haftmann
parents:
38339
diff
changeset
|
80 |
Generic_Target.theory_foundation (((b, U), NoSyn), (b_def, rhs)) (type_params, term_params) |
45352 | 81 |
#-> (fn (lhs, def) => locale_const ta Syntax.mode_default ((b, mx), lhs) |
38318
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
82 |
#> pair (lhs, def)) |
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
83 |
|
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
84 |
fun class_foundation (ta as Target {target, ...}) |
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
85 |
(((b, U), mx), (b_def, rhs)) (type_params, term_params) = |
38341
72dba5bd5f63
moved theory-level target operation fragements to Generic_Target; adjusted bootstrap order
haftmann
parents:
38339
diff
changeset
|
86 |
Generic_Target.theory_foundation (((b, U), NoSyn), (b_def, rhs)) (type_params, term_params) |
45352 | 87 |
#-> (fn (lhs, def) => locale_const ta Syntax.mode_default ((b, NoSyn), lhs) |
38619
25e401d53900
tuned: less formal noise in Named_Target, more coherence in Class
haftmann
parents:
38392
diff
changeset
|
88 |
#> Class.const target ((b, mx), (type_params, lhs)) |
38318
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
89 |
#> pair (lhs, def)) |
1fade69519ab
different foundations for different targets; simplified syntax handling of abbreviations
haftmann
parents:
38314
diff
changeset
|
90 |
|
39639 | 91 |
fun target_foundation (ta as Target {is_locale, is_class, ...}) = |
38349 | 92 |
if is_class then class_foundation ta |
93 |
else if is_locale then locale_foundation ta |
|
94 |
else Generic_Target.theory_foundation; |
|
38303
ad4b59e9d0f9
factored out foundation of `define` into separate function
haftmann
parents:
38302
diff
changeset
|
95 |
|
24939 | 96 |
|
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
97 |
(* notes *) |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
98 |
|
39639 | 99 |
fun target_notes (Target {target, is_locale, ...}) = |
47250
6523a21076a8
clarified Generic_Target.notes: always perform Attrib.partial_evaluation;
wenzelm
parents:
47247
diff
changeset
|
100 |
if is_locale then Generic_Target.locale_notes target |
6523a21076a8
clarified Generic_Target.notes: always perform Attrib.partial_evaluation;
wenzelm
parents:
47247
diff
changeset
|
101 |
else Generic_Target.theory_notes; |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
102 |
|
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
103 |
|
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
104 |
(* abbrev *) |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
105 |
|
38757
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
106 |
fun locale_abbrev ta prmode ((b, mx), t) xs = |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
107 |
Local_Theory.background_theory_result |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
108 |
(Sign.add_abbrev Print_Mode.internal (b, t)) #-> |
45352 | 109 |
(fn (lhs, _) => locale_const ta prmode |
38757
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
110 |
((b, mx), Term.list_comb (Logic.unvarify_global lhs, xs))); |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
111 |
|
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
112 |
fun target_abbrev (ta as Target {target, is_locale, is_class, ...}) |
38312
9dd57db3c0f2
moved extra_tfrees check for mixfix syntax to Generic_Target
haftmann
parents:
38311
diff
changeset
|
113 |
prmode (b, mx) (global_rhs, t') xs lthy = |
38757
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
114 |
if is_locale then |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
115 |
lthy |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
116 |
|> locale_abbrev ta prmode ((b, if is_class then NoSyn else mx), global_rhs) xs |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
117 |
|> is_class ? Class.abbrev target prmode ((b, mx), t') |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
118 |
else |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
119 |
lthy |
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
wenzelm
parents:
38619
diff
changeset
|
120 |
|> Generic_Target.theory_abbrev prmode ((b, mx), global_rhs); |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
121 |
|
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
122 |
|
47246
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
123 |
(* declaration *) |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
124 |
|
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
125 |
fun target_declaration (Target {target, ...}) {syntax, pervasive} decl lthy = |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
126 |
if target = "" then Generic_Target.standard_declaration decl lthy |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
127 |
else |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
128 |
lthy |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
129 |
|> pervasive ? Generic_Target.background_declaration decl |
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
130 |
|> Generic_Target.locale_declaration target syntax decl |
47250
6523a21076a8
clarified Generic_Target.notes: always perform Attrib.partial_evaluation;
wenzelm
parents:
47247
diff
changeset
|
131 |
|> (fn lthy' => lthy' |> Local_Theory.map_contexts (fn level => fn ctxt => |
6523a21076a8
clarified Generic_Target.notes: always perform Attrib.partial_evaluation;
wenzelm
parents:
47247
diff
changeset
|
132 |
if level = 0 then ctxt |
6523a21076a8
clarified Generic_Target.notes: always perform Attrib.partial_evaluation;
wenzelm
parents:
47247
diff
changeset
|
133 |
else Context.proof_map (Local_Theory.standard_form lthy' ctxt decl) ctxt)); |
47246
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
134 |
|
2bbab021c0e6
clarified Named_Target.target_declaration: propagate through other levels as well;
wenzelm
parents:
47081
diff
changeset
|
135 |
|
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
136 |
(* pretty *) |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
137 |
|
39639 | 138 |
fun pretty (Target {target, is_locale, is_class, ...}) ctxt = |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
139 |
let |
42360 | 140 |
val thy = Proof_Context.theory_of ctxt; |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
141 |
val target_name = |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
142 |
[Pretty.command (if is_class then "class" else "locale"), |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
143 |
Pretty.str (" " ^ Locale.extern thy target)]; |
45353 | 144 |
val fixes = |
145 |
map (fn (x, T) => (Binding.name x, SOME T, NoSyn)) |
|
146 |
(#1 (Proof_Context.inferred_fixes ctxt)); |
|
147 |
val assumes = |
|
148 |
map (fn A => (Attrib.empty_binding, [(Thm.term_of A, [])])) |
|
149 |
(Assumption.all_assms_of ctxt); |
|
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
150 |
val elems = |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
151 |
(if null fixes then [] else [Element.Fixes fixes]) @ |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
152 |
(if null assumes then [] else [Element.Assumes assumes]); |
40782 | 153 |
val body_elems = |
154 |
if not is_locale then [] |
|
39639 | 155 |
else if null elems then [Pretty.block target_name] |
156 |
else [Pretty.block (Pretty.fbreaks (Pretty.block (target_name @ [Pretty.str " ="]) :: |
|
40782 | 157 |
map (Pretty.chunks o Element.pretty_ctxt ctxt) elems))]; |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
158 |
in |
39639 | 159 |
Pretty.block [Pretty.command "theory", Pretty.brk 1, |
42360 | 160 |
Pretty.str (Context.theory_name (Proof_Context.theory_of ctxt))] :: body_elems |
38308
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
161 |
end; |
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
162 |
|
0e4649095739
try to uniformly follow define/note/abbrev/declaration order as close as possible
haftmann
parents:
38307
diff
changeset
|
163 |
|
38378 | 164 |
(* init *) |
25291 | 165 |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
166 |
fun init_context (Target {target, is_locale, is_class, ...}) = |
42360 | 167 |
if not is_locale then Proof_Context.init_global |
29576 | 168 |
else if not is_class then Locale.init target |
38379
67d71449e85b
more convenient split of class modules: class and class_declaration
haftmann
parents:
38378
diff
changeset
|
169 |
else Class.init target; |
25269 | 170 |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
171 |
fun init before_exit target thy = |
39639 | 172 |
let |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
173 |
val ta = named_target thy target before_exit; |
47061
355317493f34
clarified Local_Theory.init: avoid hardwired naming policy, discontinued odd/unused group argument (cf. 5ee13e0428d2);
wenzelm
parents:
47000
diff
changeset
|
174 |
val naming = Sign.naming_of thy |
355317493f34
clarified Local_Theory.init: avoid hardwired naming policy, discontinued odd/unused group argument (cf. 5ee13e0428d2);
wenzelm
parents:
47000
diff
changeset
|
175 |
|> Name_Space.mandatory_path (Long_Name.base_name target); |
39639 | 176 |
in |
177 |
thy |
|
178 |
|> init_context ta |
|
179 |
|> Data.put (SOME ta) |
|
47061
355317493f34
clarified Local_Theory.init: avoid hardwired naming policy, discontinued odd/unused group argument (cf. 5ee13e0428d2);
wenzelm
parents:
47000
diff
changeset
|
180 |
|> Local_Theory.init naming |
39639 | 181 |
{define = Generic_Target.define (target_foundation ta), |
182 |
notes = Generic_Target.notes (target_notes ta), |
|
183 |
abbrev = Generic_Target.abbrev (target_abbrev ta), |
|
45291
57cd50f98fdc
uniform Local_Theory.declaration with explicit params;
wenzelm
parents:
45290
diff
changeset
|
184 |
declaration = target_declaration ta, |
39639 | 185 |
pretty = pretty ta, |
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
186 |
exit = Local_Theory.target_of o before_exit} |
39639 | 187 |
end; |
38247 | 188 |
|
41585
45d7da4e4ccf
added before_exit continuation for named targets (locale, class etc.), e.g. for final check/cleanup as in VC management;
wenzelm
parents:
40782
diff
changeset
|
189 |
val theory_init = init I ""; |
25269 | 190 |
|
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47061
diff
changeset
|
191 |
val reinit = |
47069 | 192 |
Local_Theory.assert_bottom true #> Data.get #> the #> |
47066
8a6124d09ff5
basic support for nested contexts including bundles;
wenzelm
parents:
47061
diff
changeset
|
193 |
(fn Target {target, before_exit, ...} => Local_Theory.exit_global #> init before_exit target); |
38391
ba1cc1815ce1
named target is optional; explicit Name_Target.reinit
haftmann
parents:
38389
diff
changeset
|
194 |
|
47274 | 195 |
fun context_cmd ("-", _) thy = theory_init thy |
45488
6d71d9e52369
pass positions for named targets, for formal links in the document model;
wenzelm
parents:
45390
diff
changeset
|
196 |
| context_cmd target thy = init I (Locale.check thy target) thy; |
33282 | 197 |
|
20894 | 198 |
end; |