30 val prf_asm: string |
30 val prf_asm: string |
31 val prf_asm_goal: string |
31 val prf_asm_goal: string |
32 val prf_script: string |
32 val prf_script: string |
33 val prf_script_goal: string |
33 val prf_script_goal: string |
34 val prf_script_asm_goal: string |
34 val prf_script_asm_goal: string |
|
35 val quasi_command: string |
35 type spec = (string * string list) * string list |
36 type spec = (string * string list) * string list |
36 val no_spec: spec |
37 val no_spec: spec |
|
38 val quasi_command_spec: spec |
37 type keywords |
39 type keywords |
38 val minor_keywords: keywords -> Scan.lexicon |
40 val minor_keywords: keywords -> Scan.lexicon |
39 val major_keywords: keywords -> Scan.lexicon |
41 val major_keywords: keywords -> Scan.lexicon |
40 val no_command_keywords: keywords -> keywords |
42 val no_command_keywords: keywords -> keywords |
41 val empty_keywords: keywords |
43 val empty_keywords: keywords |
103 val prf_asm = "prf_asm"; |
105 val prf_asm = "prf_asm"; |
104 val prf_asm_goal = "prf_asm_goal"; |
106 val prf_asm_goal = "prf_asm_goal"; |
105 val prf_script = "prf_script"; |
107 val prf_script = "prf_script"; |
106 val prf_script_goal = "prf_script_goal"; |
108 val prf_script_goal = "prf_script_goal"; |
107 val prf_script_asm_goal = "prf_script_asm_goal"; |
109 val prf_script_asm_goal = "prf_script_asm_goal"; |
108 |
110 val quasi_command = "quasi_command"; |
109 val kinds = |
111 |
|
112 val command_kinds = |
110 [diag, document_heading, document_body, document_raw, thy_begin, thy_end, thy_load, thy_decl, |
113 [diag, document_heading, document_body, document_raw, thy_begin, thy_end, thy_load, thy_decl, |
111 thy_decl_block, thy_goal, qed, qed_script, qed_block, qed_global, prf_goal, prf_block, |
114 thy_decl_block, thy_goal, qed, qed_script, qed_block, qed_global, prf_goal, prf_block, |
112 next_block, prf_open, prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script, |
115 next_block, prf_open, prf_close, prf_chain, prf_decl, prf_asm, prf_asm_goal, prf_script, |
113 prf_script_goal, prf_script_asm_goal]; |
116 prf_script_goal, prf_script_asm_goal]; |
114 |
117 |
116 (* specifications *) |
119 (* specifications *) |
117 |
120 |
118 type spec = (string * string list) * string list; |
121 type spec = (string * string list) * string list; |
119 |
122 |
120 val no_spec: spec = (("", []), []); |
123 val no_spec: spec = (("", []), []); |
|
124 val quasi_command_spec: spec = ((quasi_command, []), []); |
121 |
125 |
122 type entry = |
126 type entry = |
123 {pos: Position.T, |
127 {pos: Position.T, |
124 id: serial, |
128 id: serial, |
125 kind: string, |
129 kind: string, |
126 files: string list, (*extensions of embedded files*) |
130 files: string list, (*extensions of embedded files*) |
127 tags: string list}; |
131 tags: string list}; |
128 |
132 |
129 fun check_spec pos ((kind, files), tags) : entry = |
133 fun check_spec pos ((kind, files), tags) : entry = |
130 if not (member (op =) kinds kind) then |
134 if not (member (op =) command_kinds kind) then |
131 error ("Unknown outer syntax keyword kind " ^ quote kind) |
135 error ("Unknown outer syntax keyword kind " ^ quote kind) |
132 else if not (null files) andalso kind <> thy_load then |
136 else if not (null files) andalso kind <> thy_load then |
133 error ("Illegal specification of files for " ^ quote kind) |
137 error ("Illegal specification of files for " ^ quote kind) |
134 else {pos = pos, id = serial (), kind = kind, files = files, tags = tags}; |
138 else {pos = pos, id = serial (), kind = kind, files = files, tags = tags}; |
135 |
139 |
169 Scan.merge_lexicons (major1, major2), |
173 Scan.merge_lexicons (major1, major2), |
170 Symtab.merge (K true) (commands1, commands2)); |
174 Symtab.merge (K true) (commands1, commands2)); |
171 |
175 |
172 val add_keywords = |
176 val add_keywords = |
173 fold (fn ((name, pos), spec as ((kind, _), _)) => map_keywords (fn (minor, major, commands) => |
177 fold (fn ((name, pos), spec as ((kind, _), _)) => map_keywords (fn (minor, major, commands) => |
174 if kind = "" then |
178 if kind = "" orelse kind = quasi_command then |
175 let |
179 let |
176 val minor' = Scan.extend_lexicon (Symbol.explode name) minor; |
180 val minor' = Scan.extend_lexicon (Symbol.explode name) minor; |
177 in (minor', major, commands) end |
181 in (minor', major, commands) end |
178 else |
182 else |
179 let |
183 let |