1(* 2 Copyright (c) 2009. 2015 David C.J. Matthews 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License version 2.1 as published by the Free Software Foundation. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with this library; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16*) 17 18(* Signature for the pretty printer. *) 19signature PRETTYSIG = 20sig 21 type context 22 type pretty 23 val ContextLocation: 24 { file: string, startLine: FixedInt.int, startPosition: FixedInt.int, endLine: FixedInt.int, endPosition: FixedInt.int } -> context 25 and ContextProperty: string * string (* User property. *) -> context 26 27 val PrettyBlock: FixedInt.int * bool * context list * pretty list -> pretty 28 and PrettyBreak: FixedInt.int * FixedInt.int -> pretty 29 and PrettyString: string -> pretty 30 31 val isPrettyBlock: pretty -> bool 32 val isPrettyBreak: pretty -> bool 33 val isPrettyString: pretty -> bool 34 35 val projPrettyBlock: pretty -> int * bool * context list * pretty list 36 val projPrettyBreak: pretty -> int * int 37 val projPrettyString: pretty -> string 38 39(* 40 datatype context = 41 ContextLocation of 42 { file: string, startLine: int, startPosition: int, endLine: int, endPosition: int } 43 | ContextProperty of string * string (* User property. *) 44 45 datatype pretty = 46 PrettyBlock of int * bool * context list * pretty list 47 | PrettyBreak of int * int 48 | PrettyString of string 49*) 50 51 (* A simple "pretty printer" that just accumulates strings. *) 52 val uglyPrint: pretty -> string 53 54 (* A proper pretty printer. *) 55 val prettyPrint: (string -> unit) * int -> pretty -> unit 56 57 (* Tag for pretty printed out from PolyML.print. *) 58 val printOutputTag : (pretty -> unit) Universal.tag 59 (* Compiler output. Used for timing information and compiler debug output. *) 60 and compilerOutputTag: (pretty->unit) Universal.tag 61 62 val getPrintOutput : Universal.universal list -> pretty -> unit 63 and getCompilerOutput : Universal.universal list -> pretty -> unit 64 (* getSimplePrinter prints strings through compilerOutput. *) 65 and getSimplePrinter: Universal.universal list * int list -> string -> unit 66 67 val tagPrettyBlock: word 68 and tagPrettyBreak: word 69 and tagPrettyString: word 70 71 val maxPrettyTag: word 72 73 (* Types that can be shared. *) 74 structure Sharing: 75 sig 76 type pretty = pretty 77 and context = context 78 end 79end; 80