PFORM - a Pascal program formatter.

Syntax:

pform infile [(+|-)Respectcase] [>outfile]

Examples:

pform assign1 >out
pform /lab3x2 -r

Options:

+Respectcase
makes the formatter case sensitive. Only lower case keywords are taken as actual keywords. This is the default.
-Respectcase
makes the formatter ignore case distinctions in identifiers and keywords.

Description:

PFORM reads "infile" (a Pascal program requiring formatting) and formats it according to a series of formatting rules described below. The formatted program is written into "outfile". If "outfile" is not specified, output goes to the terminal.

The formatter does not check for syntactic errors in the input file. However, syntactic errors may lead to erroneous formatting.

Formatting Rules:

Any spaces or blank lines inserted by the user are left alone. Comments are likewise left alone. A tab character is interpreted as a single space, and so will probably be expanded to the number of spaces that the formatter deems "appropriate".

All statements and declarations begin on separate lines.

Any line greater than 80 characters long is continued on a separate line.

The keywords "begin", "end", "repeat" and "record" are forced to stand on lines by themselves (possibly followed by supporting comments). Also, the "until" clause of a "repeat - until" construct is forced to start on a new line.

A blank line is forced before the keywords "procedure", "function", "label", "const", "type" and "var".

A space is forced before and after the symbols ":=" and "=". Also, a space is forced before the symbol ":".

The bodies of "label", "const", "type", and "var" declarations are indented from their corresponding declaration header keywords.

The bodies of "begin - end", "repeat - until", "for", "while", "with", "case" and "case" variants (to one level), and "record - end" are indented from their header keywords.

The "if-then-else" construct is indented as follows:

if <expression> then
  <statement>
else
  <statement>

Copyright © 1996, Thinkage Ltd.