author | wenzelm |
Thu, 03 Mar 2022 17:30:43 +0100 | |
changeset 75206 | 481ad7da73a9 |
parent 74231 | b3c65c984210 |
child 80328 | 559909bd7715 |
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 |
40131
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
38474
diff
changeset
|
23 |
val default_indent: string -> int -> Output.output |
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
38474
diff
changeset
|
24 |
val add_mode: string -> (string -> int -> Output.output) -> unit |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
25 |
type T |
69345
6bd63c94cf62
tuned signature (see also src/Tools/Haskell/Markup.hs);
wenzelm
parents:
69247
diff
changeset
|
26 |
val make_block: {markup: Markup.output, consistent: bool, indent: int} -> |
62783 | 27 |
T list -> T |
28 |
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
|
29 |
val str: string -> T |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
30 |
val brk: int -> T |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
31 |
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
|
32 |
val fbrk: T |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
33 |
val breaks: T list -> T list |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
34 |
val fbreaks: T list -> T list |
23645 | 35 |
val blk: int * T list -> T |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
36 |
val block: T list -> T |
23645 | 37 |
val strs: string list -> T |
23617 | 38 |
val markup: Markup.T -> T list -> T |
26703 | 39 |
val mark: Markup.T -> T -> T |
42266 | 40 |
val mark_str: Markup.T * string -> T |
41 |
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
|
42 |
val item: T list -> T |
52693 | 43 |
val text_fold: T list -> T |
55763 | 44 |
val keyword1: string -> T |
45 |
val keyword2: string -> T |
|
50162 | 46 |
val text: string -> T list |
47 |
val paragraph: T list -> T |
|
48 |
val para: string -> T |
|
18802 | 49 |
val quote: T -> T |
55033 | 50 |
val cartouche: T -> T |
18802 | 51 |
val separate: string -> T list -> T list |
52 |
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
|
53 |
val enclose: string -> string -> T list -> T |
18802 | 54 |
val enum: string -> string -> string -> T list -> T |
30620 | 55 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
val big_list: string -> T list -> T |
9730 | 60 |
val indent: int -> T -> T |
23645 | 61 |
val unbreakable: T -> T |
36745 | 62 |
val margin_default: int Unsynchronized.ref |
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
63 |
val regularN: string |
23645 | 64 |
val symbolicN: string |
36745 | 65 |
val output_buffer: int option -> T -> Buffer.T |
40131
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
38474
diff
changeset
|
66 |
val output: int option -> T -> Output.output |
36745 | 67 |
val string_of_margin: int -> T -> string |
23645 | 68 |
val string_of: T -> string |
49656
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
69 |
val writeln: T -> unit |
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
70 |
val symbolic_output: T -> Output.output |
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49554
diff
changeset
|
71 |
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
|
72 |
val unformatted_string_of: T -> string |
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
73 |
val markup_chunks: Markup.T -> T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
74 |
val chunks: T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
75 |
val chunks2: T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
76 |
val block_enclose: T * T -> T list -> T |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
77 |
val writeln_chunks: T list -> unit |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
78 |
val writeln_chunks2: T list -> unit |
62784
0371c369ab1d
adapted to Poly/ML repository version 2e40cadc975a;
wenzelm
parents:
62783
diff
changeset
|
79 |
val to_ML: FixedInt.int -> T -> ML_Pretty.pretty |
36748 | 80 |
val from_ML: ML_Pretty.pretty -> T |
68918
3a0db30e5d87
simplified signature (again, see 751bcf0473a7): e.g. relevant for non-Isabelle ML environments;
wenzelm
parents:
67522
diff
changeset
|
81 |
val to_polyml: T -> PolyML.pretty |
3a0db30e5d87
simplified signature (again, see 751bcf0473a7): e.g. relevant for non-Isabelle ML environments;
wenzelm
parents:
67522
diff
changeset
|
82 |
val from_polyml: PolyML.pretty -> T |
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
83 |
end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
84 |
|
23617 | 85 |
structure Pretty: PRETTY = |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
86 |
struct |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
87 |
|
23617 | 88 |
(** print mode operations **) |
89 |
||
61865 | 90 |
fun default_indent (_: string) = Symbol.spaces; |
23617 | 91 |
|
92 |
local |
|
23698 | 93 |
val default = {indent = default_indent}; |
43684 | 94 |
val modes = Synchronized.var "Pretty.modes" (Symtab.make [("", default)]); |
23617 | 95 |
in |
43684 | 96 |
fun add_mode name indent = |
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
|
97 |
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
|
98 |
(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
|
99 |
else warning ("Redefining pretty mode " ^ quote name); |
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
|
100 |
Symtab.update (name, {indent = indent}) tab)); |
23617 | 101 |
fun get_mode () = |
43684 | 102 |
the_default default |
103 |
(Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ())); |
|
23617 | 104 |
end; |
105 |
||
106 |
fun mode_indent x y = #indent (get_mode ()) x y; |
|
23645 | 107 |
|
61865 | 108 |
val output_spaces = Output.output o Symbol.spaces; |
23645 | 109 |
val add_indent = Buffer.add o output_spaces; |
23617 | 110 |
|
111 |
||
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
112 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
113 |
(** printing items: compound phrases, strings, and breaks **) |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
114 |
|
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
115 |
val force_nat = Integer.max 0; |
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
116 |
|
37529 | 117 |
abstype T = |
69345
6bd63c94cf62
tuned signature (see also src/Tools/Haskell/Markup.hs);
wenzelm
parents:
69247
diff
changeset
|
118 |
Block of Markup.output * bool * int * T list * int |
61869 | 119 |
(*markup output, consistent, indentation, body, length*) |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
120 |
| Break of bool * int * int (*mandatory flag, width if not taken, extra indentation if taken*) |
61870 | 121 |
| Str of Output.output * int (*text, length*) |
37529 | 122 |
with |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
123 |
|
61864 | 124 |
fun length (Block (_, _, _, _, len)) = len |
61870 | 125 |
| length (Break (_, wd, _)) = wd |
126 |
| length (Str (_, len)) = len; |
|
23645 | 127 |
|
62783 | 128 |
fun make_block {markup, consistent, indent} body = |
61883
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
129 |
let |
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
130 |
val indent' = force_nat indent; |
61883
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
131 |
fun body_length prts len = |
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
132 |
let |
67522 | 133 |
val (line, rest) = chop_prefix (fn Break (true, _, _) => false | _ => true) prts; |
61883
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
134 |
val len' = Int.max (fold (Integer.add o length) line 0, len); |
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
135 |
in |
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
136 |
(case rest of |
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
137 |
Break (true, _, ind) :: rest' => |
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
138 |
body_length (Break (false, indent' + ind, 0) :: rest') len' |
61883
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
139 |
| [] => len') |
c0f34fe6aa61
clarified length of block with pre-existant forced breaks;
wenzelm
parents:
61877
diff
changeset
|
140 |
end; |
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
141 |
in Block (markup, consistent, indent', body, body_length body 0) end; |
61864 | 142 |
|
62783 | 143 |
fun markup_block {markup, consistent, indent} es = |
144 |
make_block {markup = Markup.output markup, consistent = consistent, indent = indent} es; |
|
61864 | 145 |
|
9730 | 146 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
147 |
|
23645 | 148 |
(** derived operations to create formatting expressions **) |
149 |
||
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
150 |
val str = Output.output_width ##> force_nat #> Str; |
23645 | 151 |
|
62785
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
152 |
fun brk wd = Break (false, force_nat wd, 0); |
70b9c7d4ed7f
more robust pretty printing: permissive treatment of bad values;
wenzelm
parents:
62784
diff
changeset
|
153 |
fun brk_indent wd ind = Break (false, force_nat wd, ind); |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
154 |
val fbrk = Break (true, 1, 0); |
23645 | 155 |
|
156 |
fun breaks prts = Library.separate (brk 1) prts; |
|
157 |
fun fbreaks prts = Library.separate fbrk prts; |
|
158 |
||
62783 | 159 |
fun blk (indent, es) = |
160 |
markup_block {markup = Markup.empty, consistent = false, indent = indent} es; |
|
161 |
||
23645 | 162 |
fun block prts = blk (2, prts); |
163 |
val strs = block o breaks o map str; |
|
164 |
||
62783 | 165 |
fun markup m = markup_block {markup = m, consistent = false, indent = 0}; |
42266 | 166 |
fun mark m prt = if m = Markup.empty then prt else markup m [prt]; |
167 |
fun mark_str (m, s) = mark m (str s); |
|
168 |
fun marks_str (ms, s) = fold_rev mark ms (str s); |
|
169 |
||
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
|
170 |
val item = markup Markup.item; |
52693 | 171 |
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
|
172 |
|
55763 | 173 |
fun keyword1 name = mark_str (Markup.keyword1, name); |
174 |
fun keyword2 name = mark_str (Markup.keyword2, name); |
|
23645 | 175 |
|
50162 | 176 |
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
|
177 |
val paragraph = markup Markup.paragraph; |
50162 | 178 |
val para = paragraph o text; |
179 |
||
23645 | 180 |
fun quote prt = blk (1, [str "\"", prt, str "\""]); |
62210 | 181 |
fun cartouche prt = blk (1, [str Symbol.open_, prt, str Symbol.close]); |
23645 | 182 |
|
183 |
fun separate sep prts = |
|
184 |
flat (Library.separate [str sep, brk 1] (map single prts)); |
|
185 |
||
186 |
val commas = separate ","; |
|
187 |
||
188 |
fun enclose lpar rpar prts = |
|
189 |
block (str lpar :: (prts @ [str rpar])); |
|
190 |
||
191 |
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
|
192 |
|
30620 | 193 |
val position = |
194 |
enum "," "{" "}" o map (fn (x, y) => str (x ^ "=" ^ y)) o Position.properties_of; |
|
195 |
||
71465
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
196 |
fun here pos = |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
197 |
let |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
198 |
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
|
199 |
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
|
200 |
in |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
201 |
if s2 = "" then [] |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
202 |
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
|
203 |
end; |
910a081cca74
more position information for oracles (e.g. "skip_proof" for 'sorry'), requires Proofterm.proofs := 1;
wenzelm
parents:
69345
diff
changeset
|
204 |
|
23645 | 205 |
val list = enum ","; |
206 |
fun str_list lpar rpar strs = list lpar rpar (map str strs); |
|
207 |
||
208 |
fun big_list name prts = block (fbreaks (str name :: prts)); |
|
209 |
||
210 |
fun indent 0 prt = prt |
|
61865 | 211 |
| indent n prt = blk (0, [str (Symbol.spaces n), prt]); |
23645 | 212 |
|
61870 | 213 |
fun unbreakable (Block (m, consistent, indent, es, len)) = |
61869 | 214 |
Block (m, consistent, indent, map unbreakable es, len) |
61870 | 215 |
| unbreakable (Break (_, wd, _)) = Str (output_spaces wd, wd) |
216 |
| unbreakable (e as Str _) = e; |
|
23645 | 217 |
|
218 |
||
219 |
||
220 |
(** formatting **) |
|
221 |
||
222 |
(* formatted output *) |
|
223 |
||
224 |
local |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
225 |
|
17756 | 226 |
type text = {tx: Buffer.T, ind: Buffer.T, pos: int, nl: int}; |
227 |
||
228 |
val empty: text = |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
229 |
{tx = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
230 |
ind = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
231 |
pos = 0, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
232 |
nl = 0}; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
233 |
|
32784 | 234 |
fun newline {tx, ind = _, pos = _, nl} : text = |
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
235 |
{tx = Buffer.add (Output.output "\n") tx, |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
236 |
ind = Buffer.empty, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
237 |
pos = 0, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
238 |
nl = nl + 1}; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
239 |
|
23628
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
240 |
fun control s {tx, ind, pos: int, nl} : text = |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
241 |
{tx = Buffer.add s tx, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
242 |
ind = ind, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
243 |
pos = pos, |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
244 |
nl = nl}; |
41cdbfb9f77b
markup: emit as control information -- no indent text;
wenzelm
parents:
23617
diff
changeset
|
245 |
|
17756 | 246 |
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
|
247 |
{tx = Buffer.add s tx, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
248 |
ind = Buffer.add s ind, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
249 |
pos = pos + len, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
250 |
nl = nl}; |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
251 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
252 |
fun blanks wd = string (output_spaces wd, wd); |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
253 |
|
17756 | 254 |
fun indentation (buf, len) {tx, ind, pos, nl} : text = |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
255 |
let val s = Buffer.content buf in |
23617 | 256 |
{tx = Buffer.add (mode_indent s len) tx, |
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
257 |
ind = Buffer.add s ind, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
258 |
pos = pos + len, |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
259 |
nl = nl} |
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
260 |
end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
261 |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
262 |
(*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
|
263 |
include "after", to account for text following this block.*) |
61864 | 264 |
fun break_dist (Break _ :: _, _) = 0 |
61870 | 265 |
| break_dist (e :: es, after) = length e + break_dist (es, after) |
61864 | 266 |
| break_dist ([], after) = after; |
267 |
||
268 |
val force_break = fn Break (false, wd, ind) => Break (true, wd, ind) | e => e; |
|
269 |
val force_all = map force_break; |
|
10952
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
270 |
|
b520e4f1313b
support general indentation (e.g. for non-tt latex output);
wenzelm
parents:
9730
diff
changeset
|
271 |
(*Search for the next break (at this or higher levels) and force it to occur.*) |
61864 | 272 |
fun force_next [] = [] |
273 |
| force_next ((e as Break _) :: es) = force_break e :: es |
|
274 |
| 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
|
275 |
|
23645 | 276 |
in |
19266 | 277 |
|
36745 | 278 |
fun formatted margin input = |
279 |
let |
|
280 |
val breakgain = margin div 20; (*minimum added space required of a break*) |
|
281 |
val emergencypos = margin div 2; (*position too far to right*) |
|
282 |
||
283 |
(*es is list of expressions to print; |
|
284 |
blockin is the indentation of the current block; |
|
285 |
after is the width of the following context until next break.*) |
|
286 |
fun format ([], _, _) text = text |
|
287 |
| format (e :: es, block as (_, blockin), after) (text as {ind, pos, nl, ...}) = |
|
288 |
(case e of |
|
61869 | 289 |
Block ((bg, en), consistent, indent, bes, blen) => |
36745 | 290 |
let |
291 |
val pos' = pos + indent; |
|
292 |
val pos'' = pos' mod emergencypos; |
|
293 |
val block' = |
|
294 |
if pos' < emergencypos then (ind |> add_indent indent, pos') |
|
295 |
else (add_indent pos'' Buffer.empty, pos''); |
|
61864 | 296 |
val d = break_dist (es, after) |
297 |
val bes' = if consistent andalso pos + blen > margin - d then force_all bes else bes; |
|
36745 | 298 |
val btext: text = text |
299 |
|> control bg |
|
61864 | 300 |
|> format (bes', block', d) |
36745 | 301 |
|> control en; |
302 |
(*if this block was broken then force the next break*) |
|
61864 | 303 |
val es' = if nl < #nl btext then force_next es else es; |
36745 | 304 |
in format (es', block, after) btext end |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
305 |
| Break (force, wd, ind) => |
36745 | 306 |
(*no break if text to next break fits on this line |
307 |
or if breaking would add only breakgain to space*) |
|
308 |
format (es, block, after) |
|
309 |
(if not force andalso |
|
61864 | 310 |
pos + wd <= Int.max (margin - break_dist (es, after), blockin + breakgain) |
311 |
then text |> blanks wd (*just insert wd blanks*) |
|
312 |
else text |> newline |> indentation block |> blanks ind) |
|
61870 | 313 |
| Str str => format (es, block, after) (string str text)); |
36745 | 314 |
in |
36747
7361d5dde9ce
discontinued Pretty.setdepth, which appears to be largely unused, but can disrupt important markup if enabled accidentally;
wenzelm
parents:
36745
diff
changeset
|
315 |
#tx (format ([input], (Buffer.empty, 0), 0) empty) |
36745 | 316 |
end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
317 |
|
23645 | 318 |
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
|
319 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
320 |
|
23645 | 321 |
(* special output *) |
18802 | 322 |
|
23645 | 323 |
(*symbolic markup -- no formatting*) |
74231 | 324 |
val symbolic = |
23645 | 325 |
let |
61869 | 326 |
fun out (Block ((bg, en), _, _, [], _)) = Buffer.add bg #> Buffer.add en |
327 |
| out (Block ((bg, en), consistent, indent, prts, _)) = |
|
45666 | 328 |
Buffer.add bg #> |
61864 | 329 |
Buffer.markup (Markup.block consistent indent) (fold out prts) #> |
45666 | 330 |
Buffer.add en |
61862
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
331 |
| out (Break (false, wd, ind)) = |
e2a9e46ac0fb
support pretty break indent, like underlying ML systems;
wenzelm
parents:
56334
diff
changeset
|
332 |
Buffer.markup (Markup.break wd ind) (Buffer.add (output_spaces wd)) |
61870 | 333 |
| out (Break (true, _, _)) = Buffer.add (Output.output "\n") |
334 |
| out (Str (s, _)) = Buffer.add s; |
|
74231 | 335 |
in Buffer.build o out end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
336 |
|
23645 | 337 |
(*unformatted output*) |
74231 | 338 |
val unformatted = |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
339 |
let |
69247 | 340 |
fun out (Block ((bg, en), _, _, prts, _)) = Buffer.add bg #> fold out prts #> Buffer.add en |
341 |
| out (Break (_, wd, _)) = Buffer.add (output_spaces wd) |
|
342 |
| out (Str (s, _)) = Buffer.add s; |
|
74231 | 343 |
in Buffer.build o out end; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
344 |
|
30624
e755b8b76365
simplified datatype ML_Pretty.pretty: model Isabelle not Poly/ML;
wenzelm
parents:
30620
diff
changeset
|
345 |
|
36748 | 346 |
(* output interfaces *) |
30620 | 347 |
|
62899
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
348 |
val margin_default = Unsynchronized.ref ML_Pretty.default_margin; (*right margin, or page width*) |
23645 | 349 |
|
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
350 |
val regularN = "pretty_regular"; |
23645 | 351 |
val symbolicN = "pretty_symbolic"; |
352 |
||
36745 | 353 |
fun output_buffer margin prt = |
72075
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
354 |
if print_mode_active symbolicN andalso not (print_mode_active regularN) |
9c0b835d4cc2
proper pretty printing for latex output, notably for pide_session=true (default);
wenzelm
parents:
71465
diff
changeset
|
355 |
then symbolic prt |
36745 | 356 |
else formatted (the_default (! margin_default) margin) prt; |
23645 | 357 |
|
36745 | 358 |
val output = Buffer.content oo output_buffer; |
359 |
fun string_of_margin margin = Output.escape o output (SOME margin); |
|
360 |
val string_of = Output.escape o output NONE; |
|
49656
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
361 |
val writeln = Output.writeln o string_of; |
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
362 |
|
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
363 |
val symbolic_output = Buffer.content o symbolic; |
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
364 |
val symbolic_string_of = Output.escape o symbolic_output; |
7ff712de5747
treat wrapped markup elements as raw markup delimiters;
wenzelm
parents:
49565
diff
changeset
|
365 |
|
61877
276ad4354069
renamed Pretty.str_of to Pretty.unformatted_string_of to emphasize its meaning;
wenzelm
parents:
61870
diff
changeset
|
366 |
val unformatted_string_of = Output.escape o Buffer.content o unformatted; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
367 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
368 |
|
56334
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
369 |
(* chunks *) |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
370 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
371 |
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
|
372 |
val chunks = markup_chunks Markup.empty; |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
373 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
374 |
fun chunks2 prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
375 |
(case try split_last prts of |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
376 |
NONE => blk (0, []) |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
377 |
| SOME (prefix, last) => |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
378 |
blk (0, maps (fn prt => [text_fold [prt, fbrk], fbrk]) prefix @ [text_fold [last]])); |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
379 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
380 |
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
|
381 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
382 |
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
|
383 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
384 |
fun writeln_chunks prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
385 |
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
|
386 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
387 |
fun writeln_chunks2 prts = |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
388 |
(case try split_last prts of |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
389 |
NONE => () |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
390 |
| SOME (prefix, last) => |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
391 |
(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
|
392 |
[string_of_text_fold last]) |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
393 |
|> Output.writelns); |
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
394 |
|
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
wenzelm
parents:
55918
diff
changeset
|
395 |
|
14832
6589a58f57cb
pp: abstract pretty printing context; string_of/str_of: mark result as raw output; added Pretty.unbreakable;
wenzelm
parents:
12421
diff
changeset
|
396 |
|
62663 | 397 |
(** toplevel pretty printing **) |
36748 | 398 |
|
62667 | 399 |
fun to_ML 0 (Block _) = ML_Pretty.str "..." |
400 |
| to_ML depth (Block (m, consistent, indent, prts, _)) = |
|
401 |
ML_Pretty.Block (m, consistent, FixedInt.fromInt indent, map (to_ML (depth - 1)) prts) |
|
402 |
| to_ML _ (Break (force, wd, ind)) = |
|
62387
ad3eb2889f9a
support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents:
62210
diff
changeset
|
403 |
ML_Pretty.Break (force, FixedInt.fromInt wd, FixedInt.fromInt ind) |
62667 | 404 |
| to_ML _ (Str (s, len)) = ML_Pretty.String (s, FixedInt.fromInt len); |
36748 | 405 |
|
61869 | 406 |
fun from_ML (ML_Pretty.Block (m, consistent, indent, prts)) = |
62783 | 407 |
make_block {markup = m, consistent = consistent, indent = FixedInt.toInt indent} |
408 |
(map from_ML prts) |
|
62387
ad3eb2889f9a
support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents:
62210
diff
changeset
|
409 |
| from_ML (ML_Pretty.Break (force, wd, ind)) = |
ad3eb2889f9a
support for polyml-git ec49a49972c5 (branch FixedPrecisionInt);
wenzelm
parents:
62210
diff
changeset
|
410 |
Break (force, FixedInt.toInt wd, FixedInt.toInt ind) |
62820 | 411 |
| from_ML (ML_Pretty.String (s, len)) = Str (s, force_nat (FixedInt.toInt len)); |
36748 | 412 |
|
62667 | 413 |
val to_polyml = to_ML ~1 #> ML_Pretty.to_polyml; |
62663 | 414 |
val from_polyml = ML_Pretty.from_polyml #> from_ML; |
415 |
||
37529 | 416 |
end; |
417 |
||
62819
d3ff367a16a0
careful export of type-dependent functions, without losing their special status;
wenzelm
parents:
62785
diff
changeset
|
418 |
val _ = ML_system_pp (fn d => fn _ => ML_Pretty.to_polyml o to_ML (d + 1) o quote); |
d3ff367a16a0
careful export of type-dependent functions, without losing their special status;
wenzelm
parents:
62785
diff
changeset
|
419 |
val _ = ML_system_pp (fn _ => fn _ => to_polyml o position); |
62663 | 420 |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
421 |
end; |
62899
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
422 |
|
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
423 |
structure ML_Pretty = |
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
424 |
struct |
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
425 |
open ML_Pretty; |
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
426 |
val string_of_polyml = Pretty.string_of o Pretty.from_polyml; |
845ed4584e21
clarified bootstrap of @{make_string} -- avoid query on ML environment;
wenzelm
parents:
62823
diff
changeset
|
427 |
end; |