equal
deleted
inserted
replaced
170 |
170 |
171 |
171 |
172 |
172 |
173 (** present theory source **) |
173 (** present theory source **) |
174 |
174 |
|
175 (*NB: arranging white space around command spans is a black art.*) |
|
176 |
175 (* presentation tokens *) |
177 (* presentation tokens *) |
176 |
178 |
177 datatype token = |
179 datatype token = |
178 NoToken |
180 NoToken |
179 | BasicToken of T.token |
181 | BasicToken of T.token |
253 val (tag, tags) = tag_stack; |
255 val (tag, tags) = tag_stack; |
254 val tag' = try hd (fold OuterKeyword.update_tags cmd_tags (the_list tag)); |
256 val tag' = try hd (fold OuterKeyword.update_tags cmd_tags (the_list tag)); |
255 |
257 |
256 val active_tag' = |
258 val active_tag' = |
257 if is_some tag' then tag' |
259 if is_some tag' then tag' |
|
260 else if cmd_name = "end" andalso not (Toplevel.is_toplevel state') then NONE |
258 else try hd (default_tags cmd_name); |
261 else try hd (default_tags cmd_name); |
259 val edge = (active_tag, active_tag'); |
262 val edge = (active_tag, active_tag'); |
260 |
263 |
261 val newline' = |
264 val newline' = |
262 if is_none active_tag' then span_newline else newline; |
265 if is_none active_tag' then span_newline else newline; |
304 Scan.one T.is_blank -- Scan.any T.is_comment -- Scan.one T.is_proper; |
307 Scan.one T.is_blank -- Scan.any T.is_comment -- Scan.one T.is_proper; |
305 |
308 |
306 val is_improper = not o (T.is_proper orf T.is_begin_ignore orf T.is_end_ignore); |
309 val is_improper = not o (T.is_proper orf T.is_begin_ignore orf T.is_end_ignore); |
307 val improper = Scan.any is_improper; |
310 val improper = Scan.any is_improper; |
308 val improper_end = Scan.repeat (Scan.unless space_proper (Scan.one is_improper)); |
311 val improper_end = Scan.repeat (Scan.unless space_proper (Scan.one is_improper)); |
|
312 val blank_end = Scan.repeat (Scan.unless space_proper (Scan.one T.is_blank)); |
309 |
313 |
310 val opt_newline = Scan.option (Scan.one T.is_newline); |
314 val opt_newline = Scan.option (Scan.one T.is_newline); |
311 |
315 |
312 val ignore = |
316 val ignore = |
313 Scan.depend (fn d => opt_newline |-- Scan.one T.is_begin_ignore |
317 Scan.depend (fn d => opt_newline |-- Scan.one T.is_begin_ignore |
314 >> pair (d + 1)) || |
318 >> pair (d + 1)) || |
315 Scan.depend (fn d => Scan.one T.is_end_ignore --| |
319 Scan.depend (fn d => Scan.one T.is_end_ignore --| |
316 (if d = 0 then Scan.fail_with (K "Bad nesting of meta-comments") else opt_newline) |
320 (if d = 0 then Scan.fail_with (K "Bad nesting of meta-comments") else opt_newline) |
317 >> pair (d - 1)); |
321 >> pair (d - 1)); |
318 |
322 |
319 val tag = (improper -- P.$$$ "%" -- improper) |-- P.!!! (P.tag_name --| improper_end); |
323 val tag = (improper -- P.$$$ "%" -- improper) |-- P.!!! (P.tag_name --| blank_end); |
320 |
324 |
321 val locale = |
325 val locale = |
322 Scan.option ((P.$$$ "(" -- improper -- P.$$$ "in") |-- |
326 Scan.option ((P.$$$ "(" -- improper -- P.$$$ "in") |-- |
323 P.!!! (improper |-- P.xname --| (improper -- P.$$$ ")"))); |
327 P.!!! (improper |-- P.xname --| (improper -- P.$$$ ")"))); |
324 |
328 |