author | wenzelm |
Mon, 11 Jul 2016 16:36:29 +0200 | |
changeset 63441 | 4c3fa4dba79f |
parent 63430 | 9c5fcd355a2d |
child 67139 | 8fe0aba577af |
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 |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
10 |
val document_heading: string |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
11 |
val document_body: string |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
12 |
val document_raw: string |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
13 |
val thy_begin: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
14 |
val thy_end: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
15 |
val thy_decl: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
16 |
val thy_decl_block: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
17 |
val thy_load: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
18 |
val thy_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
19 |
val qed: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
20 |
val qed_script: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
21 |
val qed_block: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
22 |
val qed_global: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
23 |
val prf_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
24 |
val prf_block: string |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
25 |
val next_block: string |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
26 |
val prf_open: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
27 |
val prf_close: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
28 |
val prf_chain: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
29 |
val prf_decl: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
30 |
val prf_asm: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
31 |
val prf_asm_goal: string |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
32 |
val prf_script: string |
60624 | 33 |
val prf_script_goal: string |
34 |
val prf_script_asm_goal: string |
|
63441 | 35 |
val before_command: string |
63430 | 36 |
val quasi_command: string |
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
37 |
type spec = (string * string list) * string list |
63429 | 38 |
val no_spec: spec |
63441 | 39 |
val before_command_spec: spec |
63430 | 40 |
val quasi_command_spec: spec |
58903 | 41 |
type keywords |
42 |
val minor_keywords: keywords -> Scan.lexicon |
|
43 |
val major_keywords: keywords -> Scan.lexicon |
|
58920 | 44 |
val no_command_keywords: keywords -> keywords |
58903 | 45 |
val empty_keywords: keywords |
46 |
val merge_keywords: keywords * keywords -> keywords |
|
63429 | 47 |
val add_keywords: ((string * Position.T) * spec) list -> keywords -> keywords |
58931 | 48 |
val is_keyword: keywords -> string -> bool |
49 |
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
|
50 |
val is_literal: keywords -> string -> bool |
61618
27af754f50ca
more thorough check_command, including completion;
wenzelm
parents:
60694
diff
changeset
|
51 |
val dest_commands: keywords -> string list |
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
52 |
val command_markup: keywords -> string -> Markup.T option |
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
53 |
val command_kind: keywords -> string -> string option |
58923 | 54 |
val command_files: keywords -> string -> Path.T -> Path.T list |
55 |
val command_tags: keywords -> string -> string list |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
56 |
val is_vacuous: keywords -> string -> bool |
58923 | 57 |
val is_diag: keywords -> string -> bool |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
58 |
val is_document_heading: keywords -> string -> bool |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
59 |
val is_document_body: keywords -> string -> bool |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
60 |
val is_document_raw: keywords -> string -> bool |
59033 | 61 |
val is_document: keywords -> string -> bool |
59125 | 62 |
val is_theory_end: keywords -> string -> bool |
58923 | 63 |
val is_theory_load: keywords -> string -> bool |
64 |
val is_theory: keywords -> string -> bool |
|
65 |
val is_theory_body: keywords -> string -> bool |
|
66 |
val is_proof: keywords -> string -> bool |
|
67 |
val is_proof_body: keywords -> string -> bool |
|
68 |
val is_theory_goal: keywords -> string -> bool |
|
69 |
val is_proof_goal: keywords -> string -> bool |
|
70 |
val is_qed: keywords -> string -> bool |
|
71 |
val is_qed_global: keywords -> string -> bool |
|
60693
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
72 |
val is_proof_open: keywords -> string -> bool |
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
73 |
val is_proof_close: keywords -> string -> bool |
59125 | 74 |
val is_proof_asm: keywords -> string -> bool |
75 |
val is_improper: keywords -> string -> bool |
|
58923 | 76 |
val is_printed: keywords -> string -> bool |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
77 |
end; |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
78 |
|
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
|
79 |
structure Keyword: KEYWORD = |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
80 |
struct |
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
81 |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
82 |
(** keyword classification **) |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
83 |
|
58918 | 84 |
(* kinds *) |
85 |
||
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
86 |
val diag = "diag"; |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
87 |
val document_heading = "document_heading"; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
88 |
val document_body = "document_body"; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
89 |
val document_raw = "document_raw"; |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
90 |
val thy_begin = "thy_begin"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
91 |
val thy_end = "thy_end"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
92 |
val thy_decl = "thy_decl"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
93 |
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
|
94 |
val thy_load = "thy_load"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
95 |
val thy_goal = "thy_goal"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
96 |
val qed = "qed"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
97 |
val qed_script = "qed_script"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
98 |
val qed_block = "qed_block"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
99 |
val qed_global = "qed_global"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
100 |
val prf_goal = "prf_goal"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
101 |
val prf_block = "prf_block"; |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
102 |
val next_block = "next_block"; |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
103 |
val prf_open = "prf_open"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
104 |
val prf_close = "prf_close"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
105 |
val prf_chain = "prf_chain"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
106 |
val prf_decl = "prf_decl"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
107 |
val prf_asm = "prf_asm"; |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
108 |
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
|
109 |
val prf_script = "prf_script"; |
60624 | 110 |
val prf_script_goal = "prf_script_goal"; |
111 |
val prf_script_asm_goal = "prf_script_asm_goal"; |
|
63441 | 112 |
|
113 |
val before_command = "before_command"; |
|
63430 | 114 |
val quasi_command = "quasi_command"; |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
115 |
|
63430 | 116 |
val command_kinds = |
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
117 |
[diag, document_heading, document_body, document_raw, thy_begin, thy_end, thy_load, thy_decl, |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
118 |
thy_decl_block, thy_goal, qed, qed_script, qed_block, qed_global, prf_goal, prf_block, |
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
119 |
next_block, prf_open, prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script, |
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
120 |
prf_script_goal, prf_script_asm_goal]; |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
121 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
122 |
|
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
123 |
(* specifications *) |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
124 |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
125 |
type spec = (string * string list) * string list; |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
126 |
|
63429 | 127 |
val no_spec: spec = (("", []), []); |
63441 | 128 |
val before_command_spec: spec = ((before_command, []), []); |
63430 | 129 |
val quasi_command_spec: spec = ((quasi_command, []), []); |
63429 | 130 |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
131 |
type entry = |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
132 |
{pos: Position.T, |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
133 |
id: serial, |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
134 |
kind: string, |
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48709
diff
changeset
|
135 |
files: string list, (*extensions of embedded files*) |
58918 | 136 |
tags: string list}; |
17059
a001a3ebfcfd
Isar command keyword classification (from Isar/outer_syntax.ML);
wenzelm
parents:
diff
changeset
|
137 |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
138 |
fun check_spec pos ((kind, files), tags) : entry = |
63430 | 139 |
if not (member (op =) command_kinds kind) then |
58918 | 140 |
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
|
141 |
else if not (null files) andalso kind <> thy_load then |
58918 | 142 |
error ("Illegal specification of files for " ^ quote kind) |
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
143 |
else {pos = pos, id = serial (), 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
|
144 |
|
46938
cda018294515
some support for outer syntax keyword declarations within theory header;
wenzelm
parents:
46924
diff
changeset
|
145 |
|
58903 | 146 |
(** keyword tables **) |
147 |
||
148 |
(* type keywords *) |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
149 |
|
48874
ff9cd47be39b
refined Thy_Load.check_thy: find more uses in body text, based on keywords;
wenzelm
parents:
48872
diff
changeset
|
150 |
datatype keywords = Keywords of |
58903 | 151 |
{minor: Scan.lexicon, |
152 |
major: Scan.lexicon, |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
153 |
commands: entry Symtab.table}; |
58903 | 154 |
|
155 |
fun minor_keywords (Keywords {minor, ...}) = minor; |
|
156 |
fun major_keywords (Keywords {major, ...}) = major; |
|
157 |
||
58906 | 158 |
fun make_keywords (minor, major, commands) = |
159 |
Keywords {minor = minor, major = major, commands = commands}; |
|
46957
0c15caf47040
clarified Keyword.is_keyword: union of minor and major;
wenzelm
parents:
46950
diff
changeset
|
160 |
|
58906 | 161 |
fun map_keywords f (Keywords {minor, major, commands}) = |
162 |
make_keywords (f (minor, major, commands)); |
|
58903 | 163 |
|
58920 | 164 |
val no_command_keywords = |
165 |
map_keywords (fn (minor, _, _) => (minor, Scan.empty_lexicon, Symtab.empty)); |
|
166 |
||
167 |
||
168 |
(* build keywords *) |
|
169 |
||
58903 | 170 |
val empty_keywords = |
171 |
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
|
172 |
|
58903 | 173 |
fun merge_keywords |
58906 | 174 |
(Keywords {minor = minor1, major = major1, commands = commands1}, |
175 |
Keywords {minor = minor2, major = major2, commands = commands2}) = |
|
58903 | 176 |
make_keywords |
177 |
(Scan.merge_lexicons (minor1, minor2), |
|
178 |
Scan.merge_lexicons (major1, major2), |
|
58906 | 179 |
Symtab.merge (K true) (commands1, commands2)); |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
180 |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
181 |
val add_keywords = |
63429 | 182 |
fold (fn ((name, pos), spec as ((kind, _), _)) => map_keywords (fn (minor, major, commands) => |
63441 | 183 |
if kind = "" orelse kind = before_command orelse kind = quasi_command then |
63429 | 184 |
let |
185 |
val minor' = Scan.extend_lexicon (Symbol.explode name) minor; |
|
186 |
in (minor', major, commands) end |
|
187 |
else |
|
188 |
let |
|
189 |
val entry = check_spec pos spec; |
|
190 |
val major' = Scan.extend_lexicon (Symbol.explode name) major; |
|
191 |
val commands' = Symtab.update (name, entry) commands; |
|
192 |
in (minor, major', commands') end)); |
|
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
193 |
|
58903 | 194 |
|
58931 | 195 |
(* keyword status *) |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
196 |
|
58931 | 197 |
fun is_keyword keywords s = Scan.is_literal (minor_keywords keywords) (Symbol.explode s); |
198 |
fun is_command (Keywords {commands, ...}) = Symtab.defined commands; |
|
199 |
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
|
200 |
|
61618
27af754f50ca
more thorough check_command, including completion;
wenzelm
parents:
60694
diff
changeset
|
201 |
fun dest_commands (Keywords {commands, ...}) = Symtab.keys commands; |
27af754f50ca
more thorough check_command, including completion;
wenzelm
parents:
60694
diff
changeset
|
202 |
|
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
203 |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
204 |
(* command keywords *) |
58931 | 205 |
|
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
206 |
fun lookup_command (Keywords {commands, ...}) = Symtab.lookup commands; |
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
207 |
|
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
208 |
fun command_markup keywords name = |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
209 |
lookup_command keywords name |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
210 |
|> Option.map (fn {pos, id, ...} => |
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
211 |
Markup.properties (Position.entity_properties_of false id pos) |
59935 | 212 |
(Markup.entity Markup.command_keywordN name)); |
59934
b65c4370f831
more position information and PIDE markup for command keywords;
wenzelm
parents:
59735
diff
changeset
|
213 |
|
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
214 |
fun command_kind keywords = Option.map #kind o lookup_command keywords; |
54523 | 215 |
|
58923 | 216 |
fun command_files keywords name path = |
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
217 |
(case lookup_command keywords name of |
54523 | 218 |
NONE => [] |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
219 |
| SOME {kind, files, ...} => |
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
220 |
if kind <> thy_load then [] |
54523 | 221 |
else if null files then [path] |
222 |
else map (fn ext => Path.ext ext path) files); |
|
223 |
||
58923 | 224 |
fun command_tags keywords name = |
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
225 |
(case lookup_command keywords name of |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
226 |
SOME {tags, ...} => tags |
58918 | 227 |
| NONE => []); |
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
228 |
|
27433 | 229 |
|
28431 | 230 |
(* command categories *) |
27433 | 231 |
|
51225 | 232 |
fun command_category ks = |
58923 | 233 |
let |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
234 |
val tab = Symtab.make_set ks; |
58923 | 235 |
fun pred keywords name = |
59123
e68e44836d04
imitate command markup and rendering of Isabelle/jEdit in HTML output;
wenzelm
parents:
59033
diff
changeset
|
236 |
(case lookup_command keywords name of |
51225 | 237 |
NONE => false |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58924
diff
changeset
|
238 |
| SOME {kind, ...} => Symtab.defined tab kind); |
58923 | 239 |
in pred end; |
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
240 |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
241 |
val is_vacuous = command_category [diag, document_heading, document_body, document_raw]; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
242 |
|
29347 | 243 |
val is_diag = command_category [diag]; |
40397 | 244 |
|
58999
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
245 |
val is_document_heading = command_category [document_heading]; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
246 |
val is_document_body = command_category [document_body]; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
247 |
val is_document_raw = command_category [document_raw]; |
ed09ae4ea2d8
uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents:
58931
diff
changeset
|
248 |
val is_document = command_category [document_heading, document_body, document_raw]; |
29347 | 249 |
|
59125 | 250 |
val is_theory_end = command_category [thy_end]; |
29347 | 251 |
|
48867
e9beabf045ab
some support for inlining file content into outer syntax token language;
wenzelm
parents:
48864
diff
changeset
|
252 |
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
|
253 |
|
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
254 |
val is_theory = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
255 |
[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
|
256 |
|
56944
578dc6b4be89
no reset for 'end' -- e.g. relevant for 'notepad';
wenzelm
parents:
56895
diff
changeset
|
257 |
val is_theory_body = command_category |
58868
c5e1cce7ace3
uniform heading commands work in any context, even in theory header;
wenzelm
parents:
58853
diff
changeset
|
258 |
[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
|
259 |
|
27440
a1eda23752bd
replaced datatype category constructivism by is_theory/is_proof;
wenzelm
parents:
27433
diff
changeset
|
260 |
val is_proof = command_category |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
261 |
[qed, qed_script, qed_block, qed_global, prf_goal, prf_block, next_block, prf_open, |
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
262 |
prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script, prf_script_goal, |
60624 | 263 |
prf_script_asm_goal]; |
28431 | 264 |
|
51225 | 265 |
val is_proof_body = command_category |
60694
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
266 |
[diag, document_heading, document_body, document_raw, prf_block, next_block, prf_open, |
b3fa4a8cdb5f
clarified text folds: proof ... qed counts as extra block;
wenzelm
parents:
60693
diff
changeset
|
267 |
prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script, prf_script_goal, |
60624 | 268 |
prf_script_asm_goal]; |
51225 | 269 |
|
51274
cfc83ad52571
discontinued pointless command category "thy_schematic_goal" -- this is checked dynamically;
wenzelm
parents:
51225
diff
changeset
|
270 |
val is_theory_goal = command_category [thy_goal]; |
60624 | 271 |
val is_proof_goal = command_category [prf_goal, prf_asm_goal, prf_script_goal, prf_script_asm_goal]; |
53571
e58ca0311c0f
more explicit indication of 'done' as proof script element;
wenzelm
parents:
53371
diff
changeset
|
272 |
val is_qed = command_category [qed, qed_script, qed_block]; |
28431 | 273 |
val is_qed_global = command_category [qed_global]; |
27520 | 274 |
|
60693
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
275 |
val is_proof_open = |
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
276 |
command_category [prf_goal, prf_asm_goal, prf_script_goal, prf_script_asm_goal, prf_open]; |
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
277 |
val is_proof_close = command_category [qed, qed_script, qed_block, prf_close]; |
044f8bb3dd30
more accurate skip_proofs nesting, e.g. relevant for 'subgoal' command;
wenzelm
parents:
60624
diff
changeset
|
278 |
|
59125 | 279 |
val is_proof_asm = command_category [prf_asm, prf_asm_goal]; |
60624 | 280 |
val is_improper = command_category [qed_script, prf_script, prf_script_goal, prf_script_asm_goal]; |
59125 | 281 |
|
58923 | 282 |
fun is_printed keywords = is_theory_goal keywords orf is_proof keywords; |
283 |
||
27357
5b3a087ff292
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
17270
diff
changeset
|
284 |
end; |