45 val command_keyword: string -> T option |
45 val command_keyword: string -> T option |
46 val command_tags: string -> string list |
46 val command_tags: string -> string list |
47 val report: unit -> unit |
47 val report: unit -> unit |
48 val keyword: string -> unit |
48 val keyword: string -> unit |
49 val command: string -> T -> unit |
49 val command: string -> T -> unit |
50 datatype category = Theory | Proof | Other |
50 val is_theory: string -> bool |
51 val category_of: string -> category |
51 val is_proof: string -> bool |
52 end; |
52 end; |
53 |
53 |
54 structure OuterKeyword: OUTER_KEYWORD = |
54 structure OuterKeyword: OUTER_KEYWORD = |
55 struct |
55 struct |
56 |
56 |
88 val prf_script = kind "proof-script"; |
88 val prf_script = kind "proof-script"; |
89 |
89 |
90 val kinds = [control, diag, thy_begin, thy_switch, thy_end, thy_heading, thy_decl, thy_script, |
90 val kinds = [control, diag, thy_begin, thy_switch, thy_end, thy_heading, thy_decl, thy_script, |
91 thy_goal, qed, qed_block, qed_global, prf_heading, prf_goal, prf_block, prf_open, prf_close, |
91 thy_goal, qed, qed_block, qed_global, prf_heading, prf_goal, prf_block, prf_open, prf_close, |
92 prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script] |> map kind_of; |
92 prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script] |> map kind_of; |
93 |
|
94 val thy_kinds = |
|
95 [thy_begin, thy_switch, thy_end, thy_heading, thy_decl, thy_script, thy_goal] |> map kind_of; |
|
96 |
|
97 val prf_kinds = |
|
98 [qed, qed_block, qed_global, prf_heading, prf_goal, prf_block, prf_open, prf_close, |
|
99 prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script] |> map kind_of; |
|
100 |
93 |
101 |
94 |
102 (* tags *) |
95 (* tags *) |
103 |
96 |
104 fun update_tags t ts = t :: remove (op = : string * string -> bool) t ts; |
97 fun update_tags t ts = t :: remove (op = : string * string -> bool) t ts; |
174 Pretty.writeln (report_command (name, kind))); |
167 Pretty.writeln (report_command (name, kind))); |
175 |
168 |
176 |
169 |
177 (* overall category *) |
170 (* overall category *) |
178 |
171 |
179 datatype category = Theory | Proof | Other; |
172 fun command_category ks name = |
|
173 (case command_keyword name of |
|
174 NONE => false |
|
175 | SOME k => member (op =) ks (kind_of k)); |
180 |
176 |
181 fun category_of name = |
177 val is_theory = command_category |
182 (case command_keyword name of |
178 (map kind_of [thy_begin, thy_switch, thy_end, thy_heading, thy_decl, thy_script, thy_goal]); |
183 SOME kind => |
179 |
184 let val k = kind_of kind in |
180 val is_proof = command_category |
185 if member (op =) thy_kinds k then Theory |
181 (map kind_of [qed, qed_block, qed_global, prf_heading, prf_goal, prf_block, prf_open, prf_close, |
186 else if member (op =) prf_kinds k then Proof |
182 prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script]); |
187 else Other |
|
188 end |
|
189 | NONE => error ("Unknown command " ^ quote name)); |
|
190 |
183 |
191 end; |
184 end; |