Overview  Index  Help 
SMLFormat

PrettyPrinter


structure PrettyPrinter :> PRETTYPRINTER =
struct
  type environmentEntry =
       {requiredColumns : int, newline : bool ref, priority : FE.priority}
  type environment = environmentEntry list
  datatype symbol =
           Term of int * string
         | List of {symbols : symbol list, environment : environment}
         | Indicator of {space : bool, newline : bool ref}
         | DeferredIndicator of {space : bool, requiredColumns : int ref}
         | StartOfIndent of int
         | EndOfIndent
  exception Fail of string
  val format : PrinterParameter.parameter list -> symbol -> string
end

This module translates the symbols into a text representation which fits within the specified column width.

Author:
YAMATODANI Kiyoshi
Version:
$Id: StrPrettyPrinter.html,v 1.5 2007/03/27 15:03:01 kiyoshiy Exp $

 
Type detail

environmentEntry

type environmentEntry =
     {requiredColumns : int, newline : bool ref, priority : FE.priority}


environment

type environment = environmentEntry list

 
Datatype detail

symbol

datatype symbol =
         Term of int * string
       | List of {symbols : symbol list, environment : environment}
       | Indicator of {space : bool, newline : bool ref}
       | DeferredIndicator of {space : bool, requiredColumns : int ref}
       | StartOfIndent of int
       | EndOfIndent

 
DataConstructor detail

Term

constructor Term : int * string -> symbol


List

constructor List : {symbols : symbol list, environment : environment} -> symbol


Indicator

constructor Indicator : {space : bool, newline : bool ref} -> symbol


DeferredIndicator

constructor DeferredIndicator
            : {space : bool, requiredColumns : int ref} -> symbol


StartOfIndent

constructor StartOfIndent : int -> symbol


EndOfIndent

constructor EndOfIndent : symbol

 
Value detail

format

fun format parameter symbol
    : PrinterParameter.parameter list -> symbol -> string

translates the symbol into a text representation which fits within the specified column width.

This function tries to insert newline characters so that the text can fit within the specified column width, but it may exceed the specified column width if the column width is too small.

Parameters:
parameter
parameters which control the printer
symbol
the symbol to be translated.
Returns:
the text representation of the symbol.

 
Exception detail

Fail

exception Fail of string

raised when any error occurs.

Parameters:
message
the error message


Overview  Index  Help 
SMLFormat: Pretty-Printer library for SML