Copyright © 2011 , Kurt Nørmark |
The pretty printer handles all aspects of Scheme which has special lexical syntax: lists, pairs (dot notation), booleans, chars, vectors, and quasi quotation (backquoting). In addition, the pretty printing function handles Scheme special forms such as cond, let, define, if, etc.
A few parameters (global variables) control the pretty printer.
Conventional comments, read by the this pretty printer, are lost. This library assumes that comments are represented as syntactical forms like (comment!!! n "A comment"). The LAML schemedoc tool contains a procedure lexical-to-syntactical-comments! which converts conventional, semicolon Lisp comments to the syntactical comments expected by the pretty printing library. The variable syntactical-comment-symbol (and the variable COMMENT-FORM-START in SchemeDoc) allows you to control the prefix symbol of syntactical comments.
The important top level functions of this library are pretty-print-lisp-file and pretty-print-lisp-form.
Internally, the pretty printer adds pretty-print tokens (strings or chars) to a list, which finally is reversed and linearized into a string.
This library relies on the general library (not loaded by this library).
In the laml.scm file there are LAML procedures scheme-pp and scheme-pp-simple which pretty print Scheme and Lisp files. pp-scheme handles comments properly. These are the most top-level Scheme pretty printing procedures in the LAML system.
indentation-delta | indentation-delta | An integer which gives the level of indentation |
prefered-maximum-width | prefered-maximum-width | An integer that expresses the preferred maximum column width |
pretty-print-lisp-file | (pretty-print-lisp-file in-file-path [out-file-path]) | Assume that in-file-path contains a lisp file with one or lisp forms. |
pretty-print-lisp-form | (pretty-print-lisp-form form) | Pretty print form and return the pretty printed string |
pretty-print-lisp-string | (pretty-print-lisp-string str) | Pretty print the string str and the return pretty printed string. |
syntactical-comment-symbol | syntactical-comment-symbol | The symbol which is used for syntactical comments, such as (comment 2 "This is a comment"). |
use-single-lining | use-single-lining | A boolean which controls the application of single line pretty printing. |
1 Pretty printing parameters. | |||
The variables in this section controls the pretty printing. | |||
indentation-delta | |||
Form | indentation-delta | ||
Description | An integer which gives the level of indentation | ||
See also | Scheme source file | indentation-delta | |
use-single-lining | |||
Form | use-single-lining | ||
Description | A boolean which controls the application of single line pretty printing. If true, the Lisp pretty printer will pretty print short list forms on a single line | ||
See also | Scheme source file | use-single-lining | |
prefered-maximum-width | |||
Form | prefered-maximum-width | ||
Description | An integer that expresses the preferred maximum column width | ||
See also | Scheme source file | prefered-maximum-width | |
syntactical-comment-symbol | |||
Form | syntactical-comment-symbol | ||
Description | The symbol which is used for syntactical comments, such as (comment 2 "This is a comment"). It is recommended to use a symbol which is unlikely to be used in 'normal programs', such as comment!!! | ||
See also | Scheme source file | syntactical-comment-symbol | |
2 Top level pretty printing functions. | |||
In this section you will find the important, overall pretty printing functions. | |||
pretty-print-lisp-file | |||
Form | (pretty-print-lisp-file in-file-path [out-file-path]) | ||
Description | Assume that in-file-path contains a lisp file with one or lisp forms. Pretty prints the Lisp forms taken from in-file-path. Output them on the optional out-file-path (which per default is in-file-path). Important warning: If only one file is given as parameter, the input file is overwritten by the pretty printed result. | ||
See also | Scheme source file | pretty-print-lisp-file | |
pretty-print-lisp-form | |||
Form | (pretty-print-lisp-form form) | ||
Description | Pretty print form and return the pretty printed string | ||
See also | Scheme source file | pretty-print-lisp-form | |
pretty-print-lisp-string | |||
Form | (pretty-print-lisp-string str) | ||
Description | Pretty print the string str and the return pretty printed string. This function is not efficient, because it generates a temporary file, from which we parse the string, and after this the function pretty-print-lisp-form is used. | ||
See also | Scheme source file | pretty-print-lisp-string | |