equal
deleted
inserted
replaced
220 local |
220 local |
221 |
221 |
222 val before_command = |
222 val before_command = |
223 Scan.option (Parse.position (Parse.private >> K true || Parse.qualified >> K false)); |
223 Scan.option (Parse.position (Parse.private >> K true || Parse.qualified >> K false)); |
224 |
224 |
225 fun parse_command thy core_range markers = |
225 fun parse_command thy markers = |
226 Scan.ahead (before_command |-- Parse.position Parse.command) :|-- (fn (name, pos) => |
226 Scan.ahead (before_command |-- Parse.position Parse.command) :|-- (fn (name, pos) => |
227 let |
227 let |
228 val keywords = Thy_Header.get_keywords thy; |
228 val keywords = Thy_Header.get_keywords thy; |
229 val tr0 = |
229 val tr0 = |
230 Toplevel.empty |
230 Toplevel.empty |
231 |> Toplevel.name name |
231 |> Toplevel.name name |
232 |> Toplevel.positions pos core_range |
232 |> Toplevel.position pos |
233 |> Keyword.is_proof_open keywords name ? Toplevel.skip_proof_open |
233 |> Keyword.is_proof_open keywords name ? Toplevel.skip_proof_open |
234 |> Keyword.is_proof_close keywords name ? Toplevel.skip_proof_close; |
234 |> Keyword.is_proof_close keywords name ? Toplevel.skip_proof_close; |
235 val command_markers = |
235 val command_markers = |
236 Parse.command |-- Document_Source.old_tags >> |
236 Parse.command |-- Document_Source.old_tags >> |
237 (fn tags => Toplevel.markers (map Document_Marker.legacy_tag tags @ markers) tr0); |
237 (fn tags => Toplevel.markers (map Document_Marker.legacy_tag tags @ markers) tr0); |
261 |
261 |
262 val markers = map Token.input_of (filter Token.is_document_marker span); |
262 val markers = map Token.input_of (filter Token.is_document_marker span); |
263 fun parse () = |
263 fun parse () = |
264 filter Token.is_proper span |
264 filter Token.is_proper span |
265 |> Source.of_list |
265 |> Source.of_list |
266 |> Source.source Token.stopper |
266 |> Source.source Token.stopper (Scan.bulk (fn xs => Parse.!!! (parse_command thy markers) xs)) |
267 (Scan.bulk (fn xs => Parse.!!! (parse_command thy core_range markers) xs)) |
|
268 |> Source.exhaust; |
267 |> Source.exhaust; |
269 in |
268 in |
270 (case parse () of |
269 (case parse () of |
271 [tr] => Toplevel.modify_init init tr |
270 [tr] => Toplevel.modify_init init tr |
272 | [] => Toplevel.ignored full_range |
271 | [] => Toplevel.ignored (#1 full_range) |
273 | _ => Toplevel.malformed core_range "Exactly one command expected") |
272 | _ => Toplevel.malformed (#1 core_range) "Exactly one command expected") |
274 handle ERROR msg => Toplevel.malformed core_range msg |
273 handle ERROR msg => Toplevel.malformed (#1 core_range) msg |
275 end; |
274 end; |
276 |
275 |
277 fun parse_text thy init pos text = |
276 fun parse_text thy init pos text = |
278 Symbol_Pos.explode (text, pos) |
277 Symbol_Pos.explode (text, pos) |
279 |> Token.tokenize (Thy_Header.get_keywords thy) {strict = false} |
278 |> Token.tokenize (Thy_Header.get_keywords thy) {strict = false} |