author | wenzelm |
Fri, 07 Nov 2014 17:31:01 +0100 | |
changeset 58931 | 3097ec653547 |
parent 58928 | 23d0ffd48006 |
child 58999 | ed09ae4ea2d8 |
permissions | -rw-r--r-- |
36949
080e85d46108
renamed structure OuterKeyword to Keyword and OuterParse to Parse, keeping the old names as legacy aliases for some time;
wenzelm
parents:
36681
diff
changeset
|
1 |
(* Title: Pure/Isar/keyword.ML |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
3 |
|
58900 | 4 |
Isar keyword classification. |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
5 |
*) |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
6 |
|
36949
080e85d46108
renamed structure OuterKeyword to Keyword and OuterParse to Parse, keeping the old names as legacy aliases for some time;
wenzelm
parents:
36681
diff
changeset
|
7 |
signature KEYWORD = |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
8 |
sig |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
9 |
val diag: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
10 |
val heading: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
11 |
val thy_begin: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
12 |
val thy_end: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
13 |
val thy_decl: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
14 |
val thy_decl_block: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
15 |
val thy_load: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
16 |
val thy_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
17 |
val qed: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
18 |
val qed_script: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
19 |
val qed_block: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
20 |
val qed_global: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
21 |
val prf_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
22 |
val prf_block: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
23 |
val prf_open: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
24 |
val prf_close: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
25 |
val prf_chain: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
26 |
val prf_decl: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
27 |
val prf_asm: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
28 |
val prf_asm_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
29 |
val prf_asm_goal_script: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
30 |
val prf_script: string |
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
31 |
type spec = (string * string list) * string list |
58903 | 32 |
type keywords |
33 |
val minor_keywords: keywords -> Scan.lexicon |
|
34 |
val major_keywords: keywords -> Scan.lexicon |
|
58920 | 35 |
val no_command_keywords: keywords -> keywords |
58903 | 36 |
val empty_keywords: keywords |
37 |
val merge_keywords: keywords * keywords -> keywords |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
38 |
val add_keywords: (string * spec option) list -> keywords -> keywords |
58931 | 39 |
val is_keyword: keywords -> string -> bool |
40 |
val is_command: keywords -> string -> bool |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
41 |
val is_literal: keywords -> string -> bool |
58923 | 42 |
val command_files: keywords -> string -> Path.T -> Path.T list |
43 |
val command_tags: keywords -> string -> string list |
|
44 |
val is_diag: keywords -> string -> bool |
|
45 |
val is_heading: keywords -> string -> bool |
|
46 |
val is_theory_begin: keywords -> string -> bool |
|
47 |
val is_theory_load: keywords -> string -> bool |
|
48 |
val is_theory: keywords -> string -> bool |
|
49 |
val is_theory_body: keywords -> string -> bool |
|
50 |
val is_proof: keywords -> string -> bool |
|
51 |
val is_proof_body: keywords -> string -> bool |
|
52 |
val is_theory_goal: keywords -> string -> bool |
|
53 |
val is_proof_goal: keywords -> string -> bool |
|
54 |
val is_qed: keywords -> string -> bool |
|
55 |
val is_qed_global: keywords -> string -> bool |
|
56 |
val is_printed: keywords -> string -> bool |
|
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
57 |
end; |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
58 |
|
36949
080e85d46108
renamed structure OuterKeyword to Keyword and OuterParse to Parse, keeping the old names as legacy aliases for some time;
wenzelm
parents:
36681
diff
changeset
|
59 |
structure Keyword: KEYWORD = |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
60 |
struct |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
61 |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
62 |
(** keyword classification **) |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
63 |
|
58918 | 64 |
(* kinds *) |
65 |
||
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
66 |
val diag = "diag"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
67 |
val heading = "heading"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
68 |
val thy_begin = "thy_begin"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
69 |
val thy_end = "thy_end"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
70 |
val thy_decl = "thy_decl"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
71 |
val thy_decl_block = "thy_decl_block"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
72 |
val thy_load = "thy_load"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
73 |
val thy_goal = "thy_goal"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
74 |
val qed = "qed"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
75 |
val qed_script = "qed_script"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
76 |
val qed_block = "qed_block"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
77 |
val qed_global = "qed_global"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
78 |
val prf_goal = "prf_goal"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
79 |
val prf_block = "prf_block"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
80 |
val prf_open = "prf_open"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
81 |
val prf_close = "prf_close"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
82 |
val prf_chain = "prf_chain"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
83 |
val prf_decl = "prf_decl"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
84 |
val prf_asm = "prf_asm"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
85 |
val prf_asm_goal = "prf_asm_goal"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
86 |
val prf_asm_goal_script = "prf_asm_goal_script"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
87 |
val prf_script = "prf_script"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
88 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
89 |
val kinds = |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
90 |
[diag, heading, thy_begin, thy_end, thy_load, thy_decl, thy_decl_block, thy_goal, |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
91 |
qed, qed_script, qed_block, qed_global, prf_goal, prf_block, prf_open, prf_close, |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
92 |
prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_asm_goal_script, prf_script]; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
93 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
94 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
95 |
(* specifications *) |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
96 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
97 |
type T = |
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
98 |
{kind: string, |
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
99 |
files: string list, (*extensions of embedded files*) |
58918 | 100 |
tags: string list}; |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
101 |
|
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
102 |
type spec = (string * string list) * string list; |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
103 |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
104 |
fun check_spec ((kind, files), tags) : T = |
58918 | 105 |
if not (member (op =) kinds kind) then |
106 |
error ("Unknown outer syntax keyword kind " ^ quote kind) |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
107 |
else if not (null files) andalso kind <> thy_load then |
58918 | 108 |
error ("Illegal specification of files for " ^ quote kind) |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
109 |
else {kind = kind, files = files, tags = tags}; |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
46958
diff
changeset
|
110 |
|
46938
cda018294515
some support for outer syntax keyword declarations within theory header;
wenzelm
parents:
46924
diff
changeset
|
111 |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
112 |
|
58903 | 113 |
(** keyword tables **) |
114 |
||
115 |
(* type keywords *) |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
116 |
|
48874
ff9cd47be39b
refined Thy_Load.check_thy: find more uses in body text, based on keywords;
wenzelm
parents:
48872
diff
changeset
|
117 |
datatype keywords = Keywords of |
58903 | 118 |
{minor: Scan.lexicon, |
119 |
major: Scan.lexicon, |
|
58906 | 120 |
commands: T Symtab.table}; |
58903 | 121 |
|
122 |
fun minor_keywords (Keywords {minor, ...}) = minor; |
|
123 |
fun major_keywords (Keywords {major, ...}) = major; |
|
124 |
||
58906 | 125 |
fun make_keywords (minor, major, commands) = |
126 |
Keywords {minor = minor, major = major, commands = commands}; |
|
46957
0c15caf47040
clarified Keyword.is_keyword: union of minor and major;
wenzelm
parents:
46950
diff
changeset
|
127 |
|
58906 | 128 |
fun map_keywords f (Keywords {minor, major, commands}) = |
129 |
make_keywords (f (minor, major, commands)); |
|
58903 | 130 |
|
58920 | 131 |
val no_command_keywords = |
132 |
map_keywords (fn (minor, _, _) => (minor, Scan.empty_lexicon, Symtab.empty)); |
|
133 |
||
134 |
||
135 |
(* build keywords *) |
|
136 |
||
58903 | 137 |
val empty_keywords = |
138 |
make_keywords (Scan.empty_lexicon, Scan.empty_lexicon, Symtab.empty); |
|
48874
ff9cd47be39b
refined Thy_Load.check_thy: find more uses in body text, based on keywords;
wenzelm
parents:
48872
diff
changeset
|
139 |
|
58903 | 140 |
fun merge_keywords |
58906 | 141 |
(Keywords {minor = minor1, major = major1, commands = commands1}, |
142 |
Keywords {minor = minor2, major = major2, commands = commands2}) = |
|
58903 | 143 |
make_keywords |
144 |
(Scan.merge_lexicons (minor1, minor2), |
|
145 |
Scan.merge_lexicons (major1, major2), |
|
58906 | 146 |
Symtab.merge (K true) (commands1, commands2)); |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
147 |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
148 |
val add_keywords = |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
149 |
fold (fn (name, opt_spec) => map_keywords (fn (minor, major, commands) => |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
150 |
(case opt_spec of |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
151 |
NONE => |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
152 |
let |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
153 |
val minor' = Scan.extend_lexicon (Symbol.explode name) minor; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
154 |
in (minor', major, commands) end |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
155 |
| SOME spec => |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
156 |
let |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
157 |
val kind = check_spec spec; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
158 |
val major' = Scan.extend_lexicon (Symbol.explode name) major; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
159 |
val commands' = Symtab.update (name, kind) commands; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
160 |
in (minor, major', commands') end))); |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
161 |
|
58903 | 162 |
|
58931 | 163 |
(* keyword status *) |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
164 |
|
58931 | 165 |
fun is_keyword keywords s = Scan.is_literal (minor_keywords keywords) (Symbol.explode s); |
166 |
fun is_command (Keywords {commands, ...}) = Symtab.defined commands; |
|
167 |
fun is_literal keywords = is_keyword keywords orf is_command keywords; |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
168 |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
169 |
|
58931 | 170 |
(* command kind *) |
171 |
||
172 |
fun command_kind (Keywords {commands, ...}) = Symtab.lookup commands; |
|
54523 | 173 |
|
58923 | 174 |
fun command_files keywords name path = |
58931 | 175 |
(case command_kind keywords name of |
54523 | 176 |
NONE => [] |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
177 |
| SOME {kind, files, ...} => |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
178 |
if kind <> thy_load then [] |
54523 | 179 |
else if null files then [path] |
180 |
else map (fn ext => Path.ext ext path) files); |
|
181 |
||
58923 | 182 |
fun command_tags keywords name = |
58931 | 183 |
(case command_kind keywords name of |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
184 |
SOME {tags, ...} => tags |
58918 | 185 |
| NONE => []); |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
186 |
|
27433 | 187 |
|
28431 | 188 |
(* command categories *) |
27433 | 189 |
|
51225 | 190 |
fun command_category ks = |
58923 | 191 |
let |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
192 |
val tab = Symtab.make_set ks; |
58923 | 193 |
fun pred keywords name = |
58931 | 194 |
(case command_kind keywords name of |
51225 | 195 |
NONE => false |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
196 |
| SOME {kind, ...} => Symtab.defined tab kind); |
58923 | 197 |
in pred end; |
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
198 |
|
29347 | 199 |
val is_diag = command_category [diag]; |
40397 | 200 |
|
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
201 |
val is_heading = command_category [heading]; |
29347 | 202 |
|
203 |
val is_theory_begin = command_category [thy_begin]; |
|
204 |
||
48867
e9beabf045ab
some support for inlining file content into outer syntax token language;
wenzelm
parents:
48864
diff
changeset
|
205 |
val is_theory_load = command_category [thy_load]; |
e9beabf045ab
some support for inlining file content into outer syntax token language;
wenzelm
parents:
48864
diff
changeset
|
206 |
|
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
207 |
val is_theory = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
208 |
[thy_begin, thy_end, thy_load, thy_decl, thy_decl_block, thy_goal]; |
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
209 |
|
56944
578dc6b4be89
no reset for 'end' -- e.g. relevant for 'notepad';
wenzelm
parents:
56895
diff
changeset
|
210 |
val is_theory_body = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
211 |
[thy_load, thy_decl, thy_decl_block, thy_goal]; |
56944
578dc6b4be89
no reset for 'end' -- e.g. relevant for 'notepad';
wenzelm
parents:
56895
diff
changeset
|
212 |
|
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
213 |
val is_proof = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
214 |
[qed, qed_script, qed_block, qed_global, prf_goal, prf_block, prf_open, prf_close, |
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
215 |
prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_asm_goal_script, prf_script]; |
28431 | 216 |
|
51225 | 217 |
val is_proof_body = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
218 |
[diag, heading, prf_block, prf_open, prf_close, prf_chain, prf_decl, prf_asm, |
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
219 |
prf_asm_goal, prf_asm_goal_script, prf_script]; |
51225 | 220 |
|
51274
cfc83ad52571
discontinued pointless command category "thy_schematic_goal" -- this is checked dynamically;
wenzelm
parents:
51225
diff
changeset
|
221 |
val is_theory_goal = command_category [thy_goal]; |
53371
47b23c582127
more explicit indication of 'guess' as improper Isar (aka "script") element;
wenzelm
parents:
52440
diff
changeset
|
222 |
val is_proof_goal = command_category [prf_goal, prf_asm_goal, prf_asm_goal_script]; |
53571
e58ca0311c0f
more explicit indication of 'done' as proof script element;
wenzelm
parents:
53371
diff
changeset
|
223 |
val is_qed = command_category [qed, qed_script, qed_block]; |
28431 | 224 |
val is_qed_global = command_category [qed_global]; |
27520 | 225 |
|
58923 | 226 |
fun is_printed keywords = is_theory_goal keywords orf is_proof keywords; |
227 |
||
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
228 |
end; |
36949
080e85d46108
renamed structure OuterKeyword to Keyword and OuterParse to Parse, keeping the old names as legacy aliases for some time;
wenzelm
parents:
36681
diff
changeset
|
229 |