85 else split_lines #> map verbatim #> space_implode "\\isasep\\isanewline%\n")) |
91 else split_lines #> map verbatim #> space_implode "\\isasep\\isanewline%\n")) |
86 end); |
92 end); |
87 |
93 |
88 in |
94 in |
89 |
95 |
90 val _ = index_ml "index_ML" "" ml_val; |
96 val index_ml_setup = |
91 val _ = index_ml "index_ML_type" "type" ml_type; |
97 index_ml @{binding index_ML} "" ml_val #> |
92 val _ = index_ml "index_ML_exn" "exception" ml_exn; |
98 index_ml @{binding index_ML_type} "type" ml_type #> |
93 val _ = index_ml "index_ML_structure" "structure" ml_structure; |
99 index_ml @{binding index_ML_exn} "exception" ml_exn #> |
94 val _ = index_ml "index_ML_functor" "functor" ml_functor; |
100 index_ml @{binding index_ML_structure} "structure" ml_structure #> |
|
101 index_ml @{binding index_ML_functor} "functor" ml_functor; |
95 |
102 |
96 end; |
103 end; |
97 |
104 |
98 |
105 |
99 (* named theorems *) |
106 (* named theorems *) |
100 |
107 |
101 val _ = Thy_Output.antiquotation "named_thms" |
108 val named_thms_setup = |
102 (Scan.repeat (Attrib.thm -- Scan.lift (Args.parens Args.name))) |
109 Thy_Output.antiquotation @{binding named_thms} |
103 (fn {context = ctxt, ...} => |
110 (Scan.repeat (Attrib.thm -- Scan.lift (Args.parens Args.name))) |
104 map (apfst (Thy_Output.pretty_thm ctxt)) |
111 (fn {context = ctxt, ...} => |
105 #> (if Config.get ctxt Thy_Output.quotes then map (apfst Pretty.quote) else I) |
112 map (apfst (Thy_Output.pretty_thm ctxt)) |
106 #> (if Config.get ctxt Thy_Output.display |
113 #> (if Config.get ctxt Thy_Output.quotes then map (apfst Pretty.quote) else I) |
107 then |
114 #> (if Config.get ctxt Thy_Output.display |
108 map (fn (p, name) => |
115 then |
109 Output.output (Pretty.string_of (Pretty.indent (Config.get ctxt Thy_Output.indent) p)) ^ |
116 map (fn (p, name) => |
110 "\\rulename{" ^ Output.output (Pretty.str_of (Thy_Output.pretty_text ctxt name)) ^ "}") |
117 Output.output (Pretty.string_of (Pretty.indent (Config.get ctxt Thy_Output.indent) p)) ^ |
111 #> space_implode "\\par\\smallskip%\n" |
118 "\\rulename{" ^ Output.output (Pretty.str_of (Thy_Output.pretty_text ctxt name)) ^ "}") |
112 #> enclose "\\begin{isabelle}%\n" "%\n\\end{isabelle}" |
119 #> space_implode "\\par\\smallskip%\n" |
113 else |
120 #> enclose "\\begin{isabelle}%\n" "%\n\\end{isabelle}" |
114 map (fn (p, name) => |
121 else |
115 Output.output (Pretty.str_of p) ^ |
122 map (fn (p, name) => |
116 "\\rulename{" ^ Output.output (Pretty.str_of (Thy_Output.pretty_text ctxt name)) ^ "}") |
123 Output.output (Pretty.str_of p) ^ |
117 #> space_implode "\\par\\smallskip%\n" |
124 "\\rulename{" ^ Output.output (Pretty.str_of (Thy_Output.pretty_text ctxt name)) ^ "}") |
118 #> enclose "\\isa{" "}")); |
125 #> space_implode "\\par\\smallskip%\n" |
|
126 #> enclose "\\isa{" "}")); |
119 |
127 |
120 |
128 |
121 (* theory file *) |
129 (* theory file *) |
122 |
130 |
123 val _ = Thy_Output.antiquotation "thy_file" (Scan.lift Args.name) |
131 val thy_file_setup = |
124 (fn {context = ctxt, ...} => |
132 Thy_Output.antiquotation @{binding thy_file} (Scan.lift Args.name) |
125 fn name => (Thy_Load.check_thy Path.current name; Thy_Output.output ctxt [Pretty.str name])); |
133 (fn {context = ctxt, ...} => |
|
134 fn name => (Thy_Load.check_thy Path.current name; Thy_Output.output ctxt [Pretty.str name])); |
126 |
135 |
127 |
136 |
128 (* Isabelle/Isar entities (with index) *) |
137 (* Isabelle/Isar entities (with index) *) |
129 |
138 |
130 local |
139 local |
140 |
149 |
141 val arg = enclose "{" "}" o clean_string; |
150 val arg = enclose "{" "}" o clean_string; |
142 |
151 |
143 fun entity check markup kind index = |
152 fun entity check markup kind index = |
144 Thy_Output.antiquotation |
153 Thy_Output.antiquotation |
145 (translate (fn " " => "_" | c => c) kind ^ |
154 (Binding.name (translate (fn " " => "_" | c => c) kind ^ |
146 (case index of NONE => "" | SOME true => "_def" | SOME false => "_ref")) |
155 (case index of NONE => "" | SOME true => "_def" | SOME false => "_ref"))) |
147 (Scan.lift (Scan.optional (Args.parens Args.name) "" -- Args.name)) |
156 (Scan.lift (Scan.optional (Args.parens Args.name) "" -- Args.name)) |
148 (fn {context = ctxt, ...} => fn (logic, name) => |
157 (fn {context = ctxt, ...} => fn (logic, name) => |
149 let |
158 let |
150 val hyper_name = |
159 val hyper_name = |
151 "{" ^ Long_Name.append kind (Long_Name.append logic (clean_name name)) ^ "}"; |
160 "{" ^ Long_Name.append kind (Long_Name.append logic (clean_name name)) ^ "}"; |
168 else hyper o enclose "\\mbox{\\isa{" "}}")) |
177 else hyper o enclose "\\mbox{\\isa{" "}}")) |
169 else error ("Bad " ^ kind ^ " " ^ quote name) |
178 else error ("Bad " ^ kind ^ " " ^ quote name) |
170 end); |
179 end); |
171 |
180 |
172 fun entity_antiqs check markup kind = |
181 fun entity_antiqs check markup kind = |
173 ((entity check markup kind NONE); |
182 entity check markup kind NONE #> |
174 (entity check markup kind (SOME true)); |
183 entity check markup kind (SOME true) #> |
175 (entity check markup kind (SOME false))); |
184 entity check markup kind (SOME false); |
176 |
185 |
177 in |
186 in |
178 |
187 |
179 val _ = entity_antiqs no_check "" "syntax"; |
188 val entity_setup = |
180 val _ = entity_antiqs (K (is_some o Keyword.command_keyword)) "isacommand" "command"; |
189 entity_antiqs no_check "" "syntax" #> |
181 val _ = entity_antiqs (K Keyword.is_keyword) "isakeyword" "keyword"; |
190 entity_antiqs (K (is_some o Keyword.command_keyword)) "isacommand" "command" #> |
182 val _ = entity_antiqs (K Keyword.is_keyword) "isakeyword" "element"; |
191 entity_antiqs (K Keyword.is_keyword) "isakeyword" "keyword" #> |
183 val _ = entity_antiqs (thy_check Method.intern Method.defined) "" "method"; |
192 entity_antiqs (K Keyword.is_keyword) "isakeyword" "element" #> |
184 val _ = entity_antiqs (thy_check Attrib.intern Attrib.defined) "" "attribute"; |
193 entity_antiqs (thy_check Method.intern Method.defined) "" "method" #> |
185 val _ = entity_antiqs no_check "" "fact"; |
194 entity_antiqs (thy_check Attrib.intern Attrib.defined) "" "attribute" #> |
186 val _ = entity_antiqs no_check "" "variable"; |
195 entity_antiqs no_check "" "fact" #> |
187 val _ = entity_antiqs no_check "" "case"; |
196 entity_antiqs no_check "" "variable" #> |
188 val _ = entity_antiqs (K Thy_Output.defined_command) "" "antiquotation"; |
197 entity_antiqs no_check "" "case" #> |
189 val _ = entity_antiqs (K Thy_Output.defined_option) "" "antiquotation option"; |
198 entity_antiqs (thy_check Thy_Output.intern_command Thy_Output.defined_command) |
190 val _ = entity_antiqs (fn _ => fn name => is_some (OS.Process.getEnv name)) "isatt" "setting"; |
199 "" "antiquotation" #> |
191 val _ = entity_antiqs no_check "" "inference"; |
200 entity_antiqs (thy_check Thy_Output.intern_option Thy_Output.defined_option) |
192 val _ = entity_antiqs no_check "isatt" "executable"; |
201 "" "antiquotation option" #> |
193 val _ = entity_antiqs (K check_tool) "isatt" "tool"; |
202 entity_antiqs (fn _ => fn name => is_some (OS.Process.getEnv name)) "isatt" "setting" #> |
194 val _ = entity_antiqs (K (can Thy_Info.get_theory)) "" "theory"; |
203 entity_antiqs no_check "" "inference" #> |
195 val _ = |
204 entity_antiqs no_check "isatt" "executable" #> |
196 entity_antiqs |
205 entity_antiqs (K check_tool) "isatt" "tool" #> |
197 (thy_check ML_Context.intern_antiq ML_Context.defined_antiq) "" Markup.ML_antiquotationN; |
206 entity_antiqs (K (can Thy_Info.get_theory)) "" "theory" #> |
198 |
207 entity_antiqs (thy_check ML_Context.intern_antiq ML_Context.defined_antiq) |
199 end; |
208 "" Markup.ML_antiquotationN; |
200 |
209 |
201 end; |
210 end; |
|
211 |
|
212 |
|
213 (* theory setup *) |
|
214 |
|
215 val setup = |
|
216 verbatim_setup #> |
|
217 index_ml_setup #> |
|
218 named_thms_setup #> |
|
219 thy_file_setup #> |
|
220 entity_setup; |
|
221 |
|
222 end; |