134 let |
134 let |
135 fun convert _ (PolyML.PrettyBreak (width, offset)) = ML_Pretty.Break (false, width, offset) |
135 fun convert _ (PolyML.PrettyBreak (width, offset)) = ML_Pretty.Break (false, width, offset) |
136 | convert _ (PolyML.PrettyBlock (_, _, |
136 | convert _ (PolyML.PrettyBlock (_, _, |
137 [PolyML.ContextProperty ("fbrk", _)], [PolyML.PrettyString " "])) = |
137 [PolyML.ContextProperty ("fbrk", _)], [PolyML.PrettyString " "])) = |
138 ML_Pretty.Break (true, 1, 0) |
138 ML_Pretty.Break (true, 1, 0) |
139 | convert len (PolyML.PrettyBlock (ind, _, context, prts)) = |
139 | convert len (PolyML.PrettyBlock (ind, consistent, context, prts)) = |
140 let |
140 let |
141 fun property name default = |
141 fun property name default = |
142 (case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of |
142 (case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of |
143 SOME (PolyML.ContextProperty (_, b)) => b |
143 SOME (PolyML.ContextProperty (_, b)) => b |
144 | _ => default); |
144 | _ => default); |
145 val bg = property "begin" ""; |
145 val bg = property "begin" ""; |
146 val en = property "end" ""; |
146 val en = property "end" ""; |
147 val len' = property "length" len; |
147 val len' = property "length" len; |
148 in ML_Pretty.Block ((bg, en), map (convert len') prts, ind) end |
148 in ML_Pretty.Block ((bg, en), map (convert len') prts, consistent, ind) end |
149 | convert len (PolyML.PrettyString s) = |
149 | convert len (PolyML.PrettyString s) = |
150 ML_Pretty.String (s, case Int.fromString len of SOME i => i | NONE => size s) |
150 ML_Pretty.String (s, case Int.fromString len of SOME i => i | NONE => size s) |
151 in convert "" end; |
151 in convert "" end; |
152 |
152 |
153 fun ml_pretty (ML_Pretty.Break (false, width, offset)) = PolyML.PrettyBreak (width, offset) |
153 fun ml_pretty (ML_Pretty.Break (false, width, offset)) = PolyML.PrettyBreak (width, offset) |
154 | ml_pretty (ML_Pretty.Break (true, _, _)) = |
154 | ml_pretty (ML_Pretty.Break (true, _, _)) = |
155 PolyML.PrettyBlock (0, false, [PolyML.ContextProperty ("fbrk", "")], |
155 PolyML.PrettyBlock (0, false, [PolyML.ContextProperty ("fbrk", "")], |
156 [PolyML.PrettyString " "]) |
156 [PolyML.PrettyString " "]) |
157 | ml_pretty (ML_Pretty.Block ((bg, en), prts, ind)) = |
157 | ml_pretty (ML_Pretty.Block ((bg, en), prts, consistent, ind)) = |
158 let val context = |
158 let val context = |
159 (if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @ |
159 (if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @ |
160 (if en = "" then [] else [PolyML.ContextProperty ("end", en)]) |
160 (if en = "" then [] else [PolyML.ContextProperty ("end", en)]) |
161 in PolyML.PrettyBlock (ind, false, context, map ml_pretty prts) end |
161 in PolyML.PrettyBlock (ind, consistent, context, map ml_pretty prts) end |
162 | ml_pretty (ML_Pretty.String (s, len)) = |
162 | ml_pretty (ML_Pretty.String (s, len)) = |
163 if len = size s then PolyML.PrettyString s |
163 if len = size s then PolyML.PrettyString s |
164 else PolyML.PrettyBlock |
164 else PolyML.PrettyBlock |
165 (0, false, [PolyML.ContextProperty ("length", Int.toString len)], [PolyML.PrettyString s]); |
165 (0, false, [PolyML.ContextProperty ("length", Int.toString len)], [PolyML.PrettyString s]); |
166 |
166 |