author | wenzelm |
Mon, 09 Sep 2024 19:00:53 +0200 | |
changeset 80825 | b866d1510bd0 |
parent 80824 | 0d92bd90be6c |
child 80829 | bdae6195a287 |
permissions | -rw-r--r-- |
6118 | 1 |
(* Title: Pure/General/pretty.ML |
8806 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
3 |
Author: Markus Wenzel, TU Munich |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
4 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
5 |
Generic pretty printing module. |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
6 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
7 |
Loosely based on |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
8 |
D. C. Oppen, "Pretty Printing", |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
9 |
ACM Transactions on Programming Languages and Systems (1980), 465-483. |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
10 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
11 |
The object to be printed is given as a tree with indentation and line |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
12 |
breaking information. A "break" inserts a newline if the text until |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
13 |
the next break is too long to fit on the current line. After the newline, |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
14 |
text is indented to the level of the enclosing block. Normally, if a block |
61864 | 15 |
is broken then all enclosing blocks will also be broken. |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
16 |
|
61864 | 17 |
The stored length of a block is used in break_dist (to treat each inner block as |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
18 |
a unit for breaking). |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
19 |
*) |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
20 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
21 |
signature PRETTY = |
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
22 |
sig |
80821 | 23 |
type ops = {indent: string -> int -> Output.output} |
24 |
val default_ops: ops |
|
25 |
val add_mode: string -> ops -> unit |
|
80823 | 26 |
val get_mode: unit -> ops |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
27 |
type T |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
28 |
val to_ML: T -> ML_Pretty.pretty |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
29 |
val from_ML: ML_Pretty.pretty -> T |
69345
6bd63c94cf62
tuned signature (see also src/Tools/Haskell/Markup.hs);
wenzelm
parents:
69247
diff
changeset
|
30 |
val make_block: {markup: Markup.output, consistent: bool, indent: int} -> |
62783 | 31 |
T list -> T |
32 |
val markup_block: {markup: Markup.T, consistent: bool, indent: int} -> T list -> T |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
33 |
val str: string -> T |
80813
9dd4dcb08d37
clarified signature, following 1f718be3608b: Pretty.str is now value-oriented;
wenzelm
parents:
80812
diff
changeset
|
34 |
val dots: T |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
35 |
val brk: int -> T |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
36 |
val brk_indent: int -> int -> T |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
37 |
val fbrk: T |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
38 |
val breaks: T list -> T list |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
39 |
val fbreaks: T list -> T list |
23645 | 40 |
val blk: int * T list -> T |
80328 | 41 |
val block0: T list -> T |
42 |
val block1: T list -> T |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
43 |
val block: T list -> T |
23645 | 44 |
val strs: string list -> T |
23617 | 45 |
val markup: Markup.T -> T list -> T |
26703 | 46 |
val mark: Markup.T -> T -> T |
42266 | 47 |
val mark_str: Markup.T * string -> T |
48 |
val marks_str: Markup.T list * string -> T |
|
51570
3633828d80fc
basic support for Pretty.item, which is considered as logical markup and interpreted in Isabelle/Scala, but ignored elsewhere (TTY, latex etc.);
wenzelm
parents:
51511
diff
changeset
|
49 |
val item: T list -> T |
52693 | 50 |
val text_fold: T list -> T |
55763 | 51 |
val keyword1: string -> T |
52 |
val keyword2: string -> T |
|
50162 | 53 |
val text: string -> T list |
54 |
val paragraph: T list -> T |
|
55 |
val para: string -> T |
|
18802 | 56 |
val quote: T -> T |
55033 | 57 |
val cartouche: T -> T |
18802 | 58 |
val separate: string -> T list -> T list |
59 |
val commas: T list -> T list |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
60 |
val enclose: string -> string -> T list -> T |
18802 | 61 |
val enum: string -> string -> string -> T list -> T |
30620 | 62 |
val position: Position.T -> T |
71465
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
63 |
val here: Position.T -> T list |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
64 |
val list: string -> string -> T list -> T |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
65 |
val str_list: string -> string -> string list -> T |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
66 |
val big_list: string -> T list -> T |
9730 | 67 |
val indent: int -> T -> T |
23645 | 68 |
val unbreakable: T -> T |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
69 |
type output_ops = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
70 |
{output: string -> Output.output * int, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
71 |
escape: Output.output list -> string list, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
72 |
markup: Markup.T -> Markup.output, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
73 |
indent: string -> int -> Output.output, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
74 |
margin: int} |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
75 |
val output_ops: int option -> output_ops |
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
76 |
val regularN: string |
23645 | 77 |
val symbolicN: string |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
78 |
val output_buffer: output_ops -> T -> Buffer.T |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
79 |
val output: output_ops -> T -> Output.output list |
36745 | 80 |
val string_of_margin: int -> T -> string |
23645 | 81 |
val string_of: T -> string |
49656
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
82 |
val writeln: T -> unit |
80789
bcecb69f72fa
more scalable pretty printing: avoid exception String.Size at command "value" (line 33 of "$AFP/Iptables_Semantics/Examples/SQRL_Shorewall/Analyze_SQRL_Shorewall.thy") in AFP/c69af9cd3390;
wenzelm
parents:
80504
diff
changeset
|
83 |
val symbolic_output: T -> Output.output list |
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49554
diff
changeset
|
84 |
val symbolic_string_of: T -> string |
61877
276ad4354069
renamed Pretty.str_of to Pretty.unformatted_string_of to emphasize its meaning;
wenzelm
parents:
61870
diff
changeset
|
85 |
val unformatted_string_of: T -> string |
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
86 |
val markup_chunks: Markup.T -> T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
87 |
val chunks: T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
88 |
val chunks2: T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
89 |
val block_enclose: T * T -> T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
90 |
val writeln_chunks: T list -> unit |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
91 |
val writeln_chunks2: T list -> unit |
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
92 |
end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
93 |
|
23617 | 94 |
structure Pretty: PRETTY = |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
95 |
struct |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
96 |
|
23617 | 97 |
(** print mode operations **) |
98 |
||
80821 | 99 |
type ops = {indent: string -> int -> string}; |
100 |
||
101 |
val default_ops: ops = {indent = K Symbol.spaces}; |
|
23617 | 102 |
|
103 |
local |
|
80821 | 104 |
val modes = Synchronized.var "Pretty.modes" (Symtab.make [("", default_ops)]); |
23617 | 105 |
in |
80821 | 106 |
fun add_mode name ops = |
46894
e2ad717ec889
allow redefining pretty/markup modes (not output due to bootstrap issues) -- to support reloading of theory src/HOL/src/Tools/Code_Generator;
wenzelm
parents:
45666
diff
changeset
|
107 |
Synchronized.change modes (fn tab => |
e2ad717ec889
allow redefining pretty/markup modes (not output due to bootstrap issues) -- to support reloading of theory src/HOL/src/Tools/Code_Generator;
wenzelm
parents:
45666
diff
changeset
|
108 |
(if not (Symtab.defined tab name) then () |
e2ad717ec889
allow redefining pretty/markup modes (not output due to bootstrap issues) -- to support reloading of theory src/HOL/src/Tools/Code_Generator;
wenzelm
parents:
45666
diff
changeset
|
109 |
else warning ("Redefining pretty mode " ^ quote name); |
80821 | 110 |
Symtab.update (name, ops) tab)); |
23617 | 111 |
fun get_mode () = |
80821 | 112 |
the_default default_ops |
43684 | 113 |
(Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ())); |
23617 | 114 |
end; |
115 |
||
116 |
||
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
117 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
118 |
(** printing items: compound phrases, strings, and breaks **) |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
119 |
|
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
120 |
val force_nat = Integer.max 0; |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
121 |
val short_nat = FixedInt.fromInt o force_nat; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
122 |
val long_nat = force_nat o FixedInt.toInt; |
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
123 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
124 |
datatype tree = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
125 |
Block of Markup.output * bool * int * tree list * int |
61869 | 126 |
(*markup output, consistent, indentation, body, length*) |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
127 |
| Break of bool * int * int (*mandatory flag, width if not taken, extra indentation if taken*) |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
128 |
| Str of Output.output * int; (*string output, length*) |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
129 |
|
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
130 |
fun tree_length (Block (_, _, _, _, len)) = len |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
131 |
| tree_length (Break (_, wd, _)) = wd |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
132 |
| tree_length (Str (_, len)) = len; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
133 |
|
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
134 |
abstype T = T of ML_Pretty.pretty |
37529 | 135 |
with |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
136 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
137 |
fun to_ML (T prt) = prt; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
138 |
val from_ML = T; |
23645 | 139 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
140 |
fun make_block {markup = (bg, en), consistent, indent} body = |
61883
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
141 |
let |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
142 |
val context = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
143 |
(if bg = "" then [] else [ML_Pretty.ContextProperty ("begin", bg)]) @ |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
144 |
(if en = "" then [] else [ML_Pretty.ContextProperty ("end", en)]); |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
145 |
val ind = short_nat indent; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
146 |
in T (ML_Pretty.PrettyBlock (ind, consistent, context, map to_ML body)) end; |
61864 | 147 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
148 |
fun markup_block {markup, consistent, indent} body = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
149 |
make_block {markup = Markup.output markup, consistent = consistent, indent = indent} body; |
61864 | 150 |
|
9730 | 151 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
152 |
|
23645 | 153 |
(** derived operations to create formatting expressions **) |
154 |
||
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
155 |
val str = T o ML_Pretty.str; |
80813
9dd4dcb08d37
clarified signature, following 1f718be3608b: Pretty.str is now value-oriented;
wenzelm
parents:
80812
diff
changeset
|
156 |
val dots = T ML_Pretty.dots; |
23645 | 157 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
158 |
fun brk_indent wd ind = T (ML_Pretty.PrettyBreak (short_nat wd, short_nat ind)); |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
159 |
fun brk wd = brk_indent wd 0; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
160 |
val fbrk = T ML_Pretty.PrettyLineBreak; |
23645 | 161 |
|
162 |
fun breaks prts = Library.separate (brk 1) prts; |
|
163 |
fun fbreaks prts = Library.separate fbrk prts; |
|
164 |
||
62783 | 165 |
fun blk (indent, es) = |
166 |
markup_block {markup = Markup.empty, consistent = false, indent = indent} es; |
|
167 |
||
80328 | 168 |
fun block0 prts = blk (0, prts); |
169 |
fun block1 prts = blk (1, prts); |
|
23645 | 170 |
fun block prts = blk (2, prts); |
171 |
val strs = block o breaks o map str; |
|
172 |
||
62783 | 173 |
fun markup m = markup_block {markup = m, consistent = false, indent = 0}; |
42266 | 174 |
fun mark m prt = if m = Markup.empty then prt else markup m [prt]; |
175 |
fun mark_str (m, s) = mark m (str s); |
|
176 |
fun marks_str (ms, s) = fold_rev mark ms (str s); |
|
177 |
||
51570
3633828d80fc
basic support for Pretty.item, which is considered as logical markup and interpreted in Isabelle/Scala, but ignored elsewhere (TTY, latex etc.);
wenzelm
parents:
51511
diff
changeset
|
178 |
val item = markup Markup.item; |
52693 | 179 |
val text_fold = markup Markup.text_fold; |
51570
3633828d80fc
basic support for Pretty.item, which is considered as logical markup and interpreted in Isabelle/Scala, but ignored elsewhere (TTY, latex etc.);
wenzelm
parents:
51511
diff
changeset
|
180 |
|
55763 | 181 |
fun keyword1 name = mark_str (Markup.keyword1, name); |
182 |
fun keyword2 name = mark_str (Markup.keyword2, name); |
|
23645 | 183 |
|
50162 | 184 |
val text = breaks o map str o Symbol.explode_words; |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50162
diff
changeset
|
185 |
val paragraph = markup Markup.paragraph; |
50162 | 186 |
val para = paragraph o text; |
187 |
||
80328 | 188 |
fun quote prt = block1 [str "\"", prt, str "\""]; |
189 |
fun cartouche prt = block1 [str Symbol.open_, prt, str Symbol.close]; |
|
23645 | 190 |
|
191 |
fun separate sep prts = |
|
192 |
flat (Library.separate [str sep, brk 1] (map single prts)); |
|
193 |
||
194 |
val commas = separate ","; |
|
195 |
||
196 |
fun enclose lpar rpar prts = |
|
197 |
block (str lpar :: (prts @ [str rpar])); |
|
198 |
||
199 |
fun enum sep lpar rpar prts = enclose lpar rpar (separate sep prts); |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
200 |
|
30620 | 201 |
val position = |
80504 | 202 |
enum "," "{" "}" o map (str o Properties.print_eq) o Position.properties_of; |
30620 | 203 |
|
71465
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
204 |
fun here pos = |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
205 |
let |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
206 |
val props = Position.properties_of pos; |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
207 |
val (s1, s2) = Position.here_strs pos; |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
208 |
in |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
209 |
if s2 = "" then [] |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
210 |
else [str s1, mark_str (Markup.properties props Markup.position, s2)] |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
211 |
end; |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
212 |
|
23645 | 213 |
val list = enum ","; |
214 |
fun str_list lpar rpar strs = list lpar rpar (map str strs); |
|
215 |
||
216 |
fun big_list name prts = block (fbreaks (str name :: prts)); |
|
217 |
||
218 |
fun indent 0 prt = prt |
|
80328 | 219 |
| indent n prt = block0 [str (Symbol.spaces n), prt]; |
23645 | 220 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
221 |
val unbreakable = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
222 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
223 |
fun unbreak (ML_Pretty.PrettyBlock (ind, consistent, context, body)) = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
224 |
ML_Pretty.PrettyBlock (ind, consistent, context, map unbreak body) |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
225 |
| unbreak (ML_Pretty.PrettyBreak (wd, _)) = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
226 |
ML_Pretty.str (Symbol.spaces (long_nat wd)) |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
227 |
| unbreak prt = prt; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
228 |
in to_ML #> unbreak #> from_ML end; |
23645 | 229 |
|
230 |
||
231 |
||
232 |
(** formatting **) |
|
233 |
||
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
234 |
(* output operations: default via print_mode *) |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
235 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
236 |
type output_ops = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
237 |
{output: string -> Output.output * int, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
238 |
escape: Output.output list -> string list, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
239 |
markup: Markup.T -> Markup.output, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
240 |
indent: string -> int -> Output.output, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
241 |
margin: int}; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
242 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
243 |
fun output_ops opt_margin : output_ops = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
244 |
let |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
245 |
val {output, escape} = Output.get_mode (); |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
246 |
val {output = markup} = Markup.get_mode (); |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
247 |
val {indent} = get_mode (); |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
248 |
val margin = the_default ML_Pretty.default_margin opt_margin; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
249 |
in {output = output, escape = escape, markup = markup, indent = indent, margin = margin} end; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
250 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
251 |
fun output_newline (ops: output_ops) = #1 (#output ops "\n"); |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
252 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
253 |
fun output_spaces (ops: output_ops) = #output ops o Symbol.spaces; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
254 |
fun output_spaces' ops = Buffer.add o #1 o output_spaces ops; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
255 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
256 |
|
23645 | 257 |
(* formatted output *) |
258 |
||
259 |
local |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
260 |
|
17756 | 261 |
type text = {tx: Buffer.T, ind: Buffer.T, pos: int, nl: int}; |
262 |
||
263 |
val empty: text = |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
264 |
{tx = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
265 |
ind = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
266 |
pos = 0, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
267 |
nl = 0}; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
268 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
269 |
fun newline s {tx, ind = _, pos = _, nl} : text = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
270 |
{tx = Buffer.add s tx, |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
271 |
ind = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
272 |
pos = 0, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
273 |
nl = nl + 1}; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
274 |
|
23628
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
275 |
fun control s {tx, ind, pos: int, nl} : text = |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
276 |
{tx = Buffer.add s tx, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
277 |
ind = ind, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
278 |
pos = pos, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
279 |
nl = nl}; |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
280 |
|
17756 | 281 |
fun string (s, len) {tx, ind, pos: int, nl} : text = |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
282 |
{tx = Buffer.add s tx, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
283 |
ind = Buffer.add s ind, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
284 |
pos = pos + len, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
285 |
nl = nl}; |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
286 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
287 |
(*Add the lengths of the expressions until the next Break; if no Break then |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
288 |
include "after", to account for text following this block.*) |
61864 | 289 |
fun break_dist (Break _ :: _, _) = 0 |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
290 |
| break_dist (e :: es, after) = tree_length e + break_dist (es, after) |
61864 | 291 |
| break_dist ([], after) = after; |
292 |
||
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
293 |
val fbreak = Break (true, 1, 0); |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
294 |
|
61864 | 295 |
val force_break = fn Break (false, wd, ind) => Break (true, wd, ind) | e => e; |
296 |
val force_all = map force_break; |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
297 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
298 |
(*Search for the next break (at this or higher levels) and force it to occur.*) |
61864 | 299 |
fun force_next [] = [] |
300 |
| force_next ((e as Break _) :: es) = force_break e :: es |
|
301 |
| force_next (e :: es) = e :: force_next es; |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
302 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
303 |
fun block_length indent = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
304 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
305 |
fun block_len len prts = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
306 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
307 |
val (line, rest) = chop_prefix (fn Break (true, _, _) => false | _ => true) prts; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
308 |
val len' = Int.max (fold (Integer.add o tree_length) line 0, len); |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
309 |
in |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
310 |
(case rest of |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
311 |
Break (true, _, ind) :: rest' => |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
312 |
block_len len' (Break (false, indent + ind, 0) :: rest') |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
313 |
| [] => len') |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
314 |
end; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
315 |
in block_len 0 end; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
316 |
|
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
317 |
fun property context name = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
318 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
319 |
fun get (ML_Pretty.ContextProperty (a, b)) = if name = a then SOME b else NONE |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
320 |
| get _ = NONE; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
321 |
in the_default "" (get_first get context) end; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
322 |
|
23645 | 323 |
in |
19266 | 324 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
325 |
fun output_tree (ops: output_ops) make_length = |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
326 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
327 |
fun out (T (ML_Pretty.PrettyBlock (ind, consistent, context, body))) = |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
328 |
let |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
329 |
val bg = property context "begin"; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
330 |
val en = property context "end"; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
331 |
val indent = long_nat ind; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
332 |
val body' = map (out o T) body; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
333 |
val len = if make_length then block_length indent body' else ~1; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
334 |
in Block ((bg, en), consistent, indent, body', len) end |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
335 |
| out (T (ML_Pretty.PrettyBreak (wd, ind))) = Break (false, long_nat wd, long_nat ind) |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
336 |
| out (T ML_Pretty.PrettyLineBreak) = fbreak |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
337 |
| out (T (ML_Pretty.PrettyString s)) = Str (#output ops s ||> force_nat) |
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
338 |
| out (T (ML_Pretty.PrettyStringWithWidth (s, n))) = Str (s, long_nat n); |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
339 |
in out end; |
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
340 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
341 |
fun format_tree (ops: output_ops) input = |
36745 | 342 |
let |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
343 |
val margin = #margin ops; |
36745 | 344 |
val breakgain = margin div 20; (*minimum added space required of a break*) |
345 |
val emergencypos = margin div 2; (*position too far to right*) |
|
346 |
||
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
347 |
val linebreak = newline (output_newline ops); |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
348 |
val blanks = string o output_spaces ops; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
349 |
val blanks' = output_spaces' ops; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
350 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
351 |
fun indentation (buf, len) {tx, ind, pos, nl} : text = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
352 |
let val s = Buffer.content buf in |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
353 |
{tx = Buffer.add (#indent ops s len) tx, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
354 |
ind = Buffer.add s ind, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
355 |
pos = pos + len, |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
356 |
nl = nl} |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
357 |
end; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
358 |
|
36745 | 359 |
(*es is list of expressions to print; |
360 |
blockin is the indentation of the current block; |
|
361 |
after is the width of the following context until next break.*) |
|
362 |
fun format ([], _, _) text = text |
|
363 |
| format (e :: es, block as (_, blockin), after) (text as {ind, pos, nl, ...}) = |
|
364 |
(case e of |
|
61869 | 365 |
Block ((bg, en), consistent, indent, bes, blen) => |
36745 | 366 |
let |
367 |
val pos' = pos + indent; |
|
368 |
val pos'' = pos' mod emergencypos; |
|
369 |
val block' = |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
370 |
if pos' < emergencypos then (ind |> blanks' indent, pos') |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
371 |
else (blanks' pos'' Buffer.empty, pos''); |
61864 | 372 |
val d = break_dist (es, after) |
373 |
val bes' = if consistent andalso pos + blen > margin - d then force_all bes else bes; |
|
36745 | 374 |
val btext: text = text |
375 |
|> control bg |
|
61864 | 376 |
|> format (bes', block', d) |
36745 | 377 |
|> control en; |
378 |
(*if this block was broken then force the next break*) |
|
61864 | 379 |
val es' = if nl < #nl btext then force_next es else es; |
36745 | 380 |
in format (es', block, after) btext end |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
381 |
| Break (force, wd, ind) => |
36745 | 382 |
(*no break if text to next break fits on this line |
383 |
or if breaking would add only breakgain to space*) |
|
384 |
format (es, block, after) |
|
385 |
(if not force andalso |
|
61864 | 386 |
pos + wd <= Int.max (margin - break_dist (es, after), blockin + breakgain) |
387 |
then text |> blanks wd (*just insert wd blanks*) |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
388 |
else text |> linebreak |> indentation block |> blanks ind) |
61870 | 389 |
| Str str => format (es, block, after) (string str text)); |
36745 | 390 |
in |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
391 |
#tx (format ([output_tree ops true input], (Buffer.empty, 0), 0) empty) |
36745 | 392 |
end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
393 |
|
23645 | 394 |
end; |
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
395 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
396 |
|
23645 | 397 |
(* special output *) |
18802 | 398 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
399 |
(*symbolic markup -- no formatting*) |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
400 |
fun symbolic ops prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
401 |
let |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
402 |
fun buffer_markup m body = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
403 |
let val (bg, en) = #markup ops m |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
404 |
in Buffer.add bg #> body #> Buffer.add en end; |
80822 | 405 |
|
61869 | 406 |
fun out (Block ((bg, en), _, _, [], _)) = Buffer.add bg #> Buffer.add en |
407 |
| out (Block ((bg, en), consistent, indent, prts, _)) = |
|
45666 | 408 |
Buffer.add bg #> |
80822 | 409 |
buffer_markup (Markup.block consistent indent) (fold out prts) #> |
45666 | 410 |
Buffer.add en |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
411 |
| out (Break (false, wd, ind)) = buffer_markup (Markup.break wd ind) (output_spaces' ops wd) |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
412 |
| out (Break (true, _, _)) = Buffer.add (output_newline ops) |
61870 | 413 |
| out (Str (s, _)) = Buffer.add s; |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
414 |
in Buffer.build (out (output_tree ops false prt)) end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
415 |
|
23645 | 416 |
(*unformatted output*) |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
417 |
fun unformatted ops prt = |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
418 |
let |
69247 | 419 |
fun out (Block ((bg, en), _, _, prts, _)) = Buffer.add bg #> fold out prts #> Buffer.add en |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
420 |
| out (Break (_, wd, _)) = output_spaces' ops wd |
69247 | 421 |
| out (Str (s, _)) = Buffer.add s; |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
422 |
in Buffer.build (out (output_tree ops false prt)) end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
423 |
|
30624
e755b8b76365
simplified datatype ML_Pretty.pretty: model Isabelle not Poly/ML;
wenzelm
parents:
30620
diff
changeset
|
424 |
|
36748 | 425 |
(* output interfaces *) |
30620 | 426 |
|
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
427 |
val regularN = "pretty_regular"; |
23645 | 428 |
val symbolicN = "pretty_symbolic"; |
429 |
||
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
430 |
fun output_buffer ops prt = |
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
431 |
if print_mode_active symbolicN andalso not (print_mode_active regularN) |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
432 |
then symbolic ops prt |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
433 |
else format_tree ops prt; |
23645 | 434 |
|
80789
bcecb69f72fa
more scalable pretty printing: avoid exception String.Size at command "value" (line 33 of "$AFP/Iptables_Semantics/Examples/SQRL_Shorewall/Analyze_SQRL_Shorewall.thy") in AFP/c69af9cd3390;
wenzelm
parents:
80504
diff
changeset
|
435 |
val output = Buffer.contents oo output_buffer; |
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
436 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
437 |
fun string_of_margin margin prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
438 |
let val ops = output_ops (SOME margin) |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
439 |
in implode (#escape ops (output ops prt)) end; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
440 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
441 |
fun string_of prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
442 |
let val ops = output_ops NONE |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
443 |
in implode (#escape ops (output ops prt)) end; |
49656
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
444 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
445 |
fun writeln prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
446 |
let val ops = output_ops NONE |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
447 |
in Output.writelns (#escape ops (output ops prt)) end; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
448 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
449 |
fun symbolic_output prt = Buffer.contents (symbolic (output_ops NONE) prt); |
49656
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
450 |
|
80825
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
451 |
fun symbolic_string_of prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
452 |
let val ops = output_ops NONE |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
453 |
in implode (#escape ops (Buffer.contents (symbolic ops prt))) end; |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
454 |
|
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
455 |
fun unformatted_string_of prt = |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
456 |
let val ops = output_ops NONE |
b866d1510bd0
clarified signature: more explicit type output_ops: default via print_mode;
wenzelm
parents:
80824
diff
changeset
|
457 |
in implode (#escape ops (Buffer.contents (unformatted ops prt))) end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
458 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
459 |
|
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
460 |
(* chunks *) |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
461 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
462 |
fun markup_chunks m prts = markup m (fbreaks (map (text_fold o single) prts)); |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
463 |
val chunks = markup_chunks Markup.empty; |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
464 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
465 |
fun chunks2 prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
466 |
(case try split_last prts of |
80328 | 467 |
NONE => block0 [] |
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
468 |
| SOME (prefix, last) => |
80328 | 469 |
block0 (maps (fn prt => [text_fold [prt, fbrk], fbrk]) prefix @ [text_fold [last]])); |
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
470 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
471 |
fun block_enclose (prt1, prt2) prts = chunks [block (fbreaks (prt1 :: prts)), prt2]; |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
472 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
473 |
fun string_of_text_fold prt = string_of prt |> Markup.markup Markup.text_fold; |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
474 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
475 |
fun writeln_chunks prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
476 |
Output.writelns (Library.separate "\n" (map string_of_text_fold prts)); |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
477 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
478 |
fun writeln_chunks2 prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
479 |
(case try split_last prts of |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
480 |
NONE => () |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
481 |
| SOME (prefix, last) => |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
482 |
(map (fn prt => Markup.markup Markup.text_fold (string_of prt ^ "\n") ^ "\n") prefix @ |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
483 |
[string_of_text_fold last]) |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
484 |
|> Output.writelns); |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
485 |
|
80810
1f718be3608b
clarified Pretty.T vs. output tree (following Isabelle/Scala): Output.output_width (via print_mode) happens during formatting, instead of construction;
wenzelm
parents:
80809
diff
changeset
|
486 |
end; |
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
487 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
488 |
end; |
62899
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
489 |
|
80809
4a64fc4d1cde
clarified signature: type ML_Pretty.pretty coincides with PolyML.pretty;
wenzelm
parents:
80805
diff
changeset
|
490 |
structure ML_Pretty: ML_PRETTY = |
62899
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
491 |
struct |
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
492 |
open ML_Pretty; |
80809
4a64fc4d1cde
clarified signature: type ML_Pretty.pretty coincides with PolyML.pretty;
wenzelm
parents:
80805
diff
changeset
|
493 |
val string_of = Pretty.string_of o Pretty.from_ML; |
62899
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
494 |
end; |
80812 | 495 |
|
496 |
||
497 |
||
498 |
(** toplevel pretty printing **) |
|
499 |
||
500 |
val _ = ML_system_pp (fn d => fn _ => ML_Pretty.prune (d + 1) o Pretty.to_ML o Pretty.quote); |
|
501 |
val _ = ML_system_pp (fn _ => fn _ => Pretty.to_ML o Pretty.position); |
|
502 |
val _ = ML_system_pp (fn _ => fn _ => Pretty.to_ML o Pretty.mark_str o Path.print_markup); |
|
503 |
||
504 |
val _ = |
|
505 |
ML_system_pp (fn _ => fn _ => fn t => |
|
506 |
ML_Pretty.str ("<thread " ^ quote (Isabelle_Thread.print t) ^ |
|
507 |
(if Isabelle_Thread.is_active t then "" else " (inactive)") ^ ">")); |
|
508 |
||
509 |
val _ = |
|
510 |
ML_system_pp (fn _ => fn _ => fn bytes => |
|
511 |
ML_Pretty.str |
|
512 |
(if Bytes.is_empty bytes then "Bytes.empty" |
|
513 |
else "Bytes {size = " ^ string_of_int (Bytes.size bytes) ^ "}")); |