home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TPF
-
- Version 1.0
-
- A Language Formatter for Turbo Pascal
-
-
-
-
-
- Steve Wilhite
- Saunderlane Software
- Worthington, Ohio
- Page 2
-
-
- TPF generates a standard format for Pascal code. TPF will
- accept standard Pascal and the language extensions in Turbo
- Pascal. TPF accepts full programs, procedures, or groups of
- statements. A syntactically incorrect program will cause
- TPF to abort and to cease formatting the output file.
-
- TPF's default formatting requires no control from you. The
- best way to find out how the formatting works is to try it
- and see. In addition, TPF's formatting directives give you
- considerable control over the output format when you wish.
-
- TPF's rules allow you to achieve almost any effect needed in
- the display of comments.
-
-
-
- 1.0 COMMENTS
-
- TPF's rules allow you to achieve almost any effect needed in
- the display of comments.
-
- 1. A comment standing alone on a line will be
- left-justified to the current indentation level, so that
- it will be aligned with the statements before and after
- it. If it is too long to fit with this alignment, it
- will be right-justified.
-
- 2. A comment that begins a line and continue to another
- line will be passed to the output unaltered, indentation
- unchanged. This type of comment is assumed to contain
- text formatted by the author, so it is not formatted.
-
- 3. If a comment covered by one of the above rules will not
- fit within the defined output line length, the output
- line will be extended as necessary to accommodate the
- comment. Once formatting is complete, a message to the
- display will give the number of times the width was
- exceeded and the output line number of the first
- occurrence.
-
- 4. A comment embedded within a line will be formatted with
- the rest of the code on that line. Breaks between words
- within a comment may be changed to achieve proper
- formatting, so nothing that has a fixed format should be
- used in such a comment. If a comment cannot be properly
- spaced so that the line will fit within the output
- length, that line will be extended as necessary. If no
- code follows a comment in the input line, then no code
- will be placed after the comment in the output line.
-
- Page 3
-
-
- 2.0 STATEMENT BUNCHING
-
- The normal formatting rule for a CASE statement places the
- selected statements on a separate line from the case labels.
- The B directive (see below) tells the formatter to place
- these statements on the same line as the case labels if the
- statements will fit.
-
- Similarly, the rules for IF-THEN-ELSE, FOR, WHILE, and WITH
- place the controlled statements on separate lines. The B
- directive tells the formatter to place the controlled
- statement on the same line as the statement header if the
- statement will fit.
-
-
-
- 3.0 TABLES
-
- Many Pascal programs contain lists of initialization
- statements or constant declarations that are logically a
- single action or declaration. You may want these to be fit
- into as few lines as possible. The S directive (see below)
- allow this. If this is used, logical tab stops are set up
- on the line, and successive statements or constant
- declarations are aligned to these tab stops instead of
- beginning on new lines.
-
- At least one blank is always placed between statements or
- constant declarations, so if tab stops are set up at every
- character location, statements will be packed on a line.
-
- Structured statements, which normally format on more than
- one line, are not effected by this directive.
-
-
-
- 4.0 USING TPF
-
- You invoke TPF with the following MS-DOS command:
-
- A>TPF input-file
-
- input-file
- The Turbo Pascal source file to be formatted. The
- default file type is ".PAS". If the formatting was
- successful, the input file is renamed to "name.TPF" and
- the output file receives the same file name as the
- input file.
- Page 4
-
-
- 5.0 FORMATTING DIRECTIVES
-
- Formatting directives are specified by a special format of
- the Pascal comment structure and are placed within square
- brackets.
-
- {[directives] text}
-
- Formatting directives are of two breeds: switches that turn
- on with the plus sign (+) and off with the minus sign
- (-)(e.g., R+ and U-); or numeric directives of the form
- T=5. Multiple directives separated by commas (e.g., R+,U-).
- Blanks are not allowed within a directive. Case is ignored:
- R+ is the same as r+ in a directive.
-
- The TPF formatting directives are:
-
- 1. A (Default A-) Adjusts each identifier so that the first
- instance of the identifier determines the appearance of
- all subsequence instances of the identifier. This
- facility standardizes the use of upper-case and
- lower-case characters and the break character (_) in
- program text.
-
- 2. B (Default B-) Specifies that the statements following a
- THEN, ELSE, FOR, WITH or WHILE will be put on the same
- line if they will fit. The statement following a CASE
- label will be put on the same line if it fits. The
- result is a shorter output, which may be easier to read
- but which also may be harder to correct.
-
- 3. C (Default C-) Convert leading blanks to tabs on output.
-
- 4. F (Default F+) Turns formatting on and off. This
- directive goes into effect immediately after the comment
- in which it is placed and save carefully hand-formatted
- portions of a program.
-
- 5. O (Numeric directive, default O=78) Specifies the width
- of the output line. The maximum value allowed is 127
- character. If a particular token will not fit in the
- width specified, the line will be lengthened
- accordingly, and a message at the end of the formatting
- will give the number of times the width was exceeded and
- the output line number of the first occurrence.
-
- 6. P (Default P-) Sets "portability mode" formatting, which
- removes break characters (_) from identifiers. The
- first letter of each identifier, and the first letter
- following each break character will be made upper case,
- while the remaining characters will be in lower case.
- This directiver overrides the U directive. The R
- directive sets the case of reserved words.
- Page 5
-
-
- Warning: Turbo Pascal considers the break character
- significant: User_DoesThis is a different identifier
- than UserDoes_This. Take care when using this directive
- that you do not make two different identifiers the same.
-
- 7. R (no default) R+ specifies that all reserved words are
- converted to upper case; R- specifies that they will be
- converted to lower case. If this directive is not
- specified, the reserved words will be a literal copy of
- the input.
-
- 8. S (Numeric directive, default S=1) Specifies the number
- of statements per line. The space from the current
- indention level to the end of the line is divided into
- even pieces, and successive statements are put on the
- boundaries of successive pieces. A statement may take
- more than one piece, in which case the next statement
- again goes on the boundary of the next piece. This is
- similar to the tabbing of a typewriter.
-
- 9. T (Numeric directive, default T=2) Specifies the amount
- to "tab" for each indentation level. Statements that
- continue on successive lines will be additionally
- indented by half the value of T.
-
- 10. U (no default) U+ specifies that identifiers are
- converted to upper case; U- specifies that they will be
- converted to lower case. If this directive is not
- specified, the identifiers will be a literal copy of the
- input. The P directive override this directive.
-
-
-
-
- 6.0 LIMITATIONS AND ERRORS
-
- TPF is limited in the following ways:
-
- 1. The maximum input line length is 127 characters.
-
- 2. The maximum output length is 127 characters.
-
- 3. Only syntactically correct statements are formatted. A
- syntax error in the code will cause the formatting to
- abort. An error message will give the input line number
- on which the error is detected. The error checking is
- not perfect, and successful formatting is no guarantee
- that the program will compile.
-
- 4. The number of indentation levels handled by TPF is
- limited; TPF will abort if this number is exceeded -- a
- rare circumstance.
- Page 6
-
-
- 5. If a comment will require more than the maximum output
- length (127) to meet the rules given, processing will be
- aborted. This situation should be even rarer than
- identation-level problems.
-
- 6. When it aborts, TPF deletes the output file. The input
- file is not altered.
-