home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
lout2.lzh
/
LOUT2
/
DOC
/
TR.EQ
/
s6
< prev
next >
Wrap
Text File
|
1994-01-25
|
6KB
|
165 lines
@Appendix
@Title { Pas -- a Lout Package for Printing Pascal Programs }
@Begin
@PP
Pas
@Reference
@Tag { jensen75 }
@Type { Book }
@Author { Jensen, K. and Wirth, N. }
@Title { Pascal User Manual and Report }
@Publisher { Springer-Verlag }
@Year { 1975 }
is a package of definitions for printing Pascal programs
[{@Ref jensen75}] neatly with the Lout document formatter
[{@Ref kingston92}]. No attempt is made to follow any particular
printing standard; the design simply reflects the author's taste.
@PP
The package is so simple that there is very little to say about
it. To use Pas, place @Code "@SysInclude { pas }" in the setup file,
or type @Code "-ipas" in the command line. A Pascal program is
entered like this, where the @Code "@ID" symbol from the DocumentLayout
package [{@Ref kingston92begin}] has been used to obtain an indented display:
@ID @Code {
"@ID @Pas {"
"procedure PriDelete(x: PriEntry; var Q: PriorityQueue);"
" var i: integer;"
"begin"
" with Q^ do begin"
" size := size - 1;"
" if x^.back <= size then"
" begin"
" i := x^.back;"
" A[i] := A[size + 1];"
" A[i]^.back := i;"
" PriAddRoot(i, Q);"
" PriAddLeaf(i, Q)"
" end"
" end"
"end;"
"}"
}
The result will come out like this:
@ID @Pas {
procedure PriDelete(x: PriEntry; var Q: PriorityQueue);
var i: integer;
begin
with Q^ do begin
size := size - 1;
if x^.back <= size then
begin
i := x^.back;
A[i] := A[size + 1];
A[i]^.back := i;
PriAddRoot(i, Q);
PriAddLeaf(i, Q)
end
end
end;
}
Blank lines, line breaks, indents and spaces in the input are respected, with a
tab being considered equal to eight spaces. @Code "@Pas" can also be used
within a paragraph to produce Pascal fragments like @Pas { A[i..j] }. Use
@Code "@OneCol @Pas { ... }" to prevent the result from breaking over two
lines.
@PP
@Code "@Pas" does not attempt to rearrange the program in any way. Each
item is simply printed according to the following plan:
@ID {
7c @Wide {
@Code and |2.5ct @Pas { and }
//1vx @Code array |2.5ct @Pas { array }
//1vx @Code begin |2.5ct @Pas { begin }
//1vx @Code case |2.5ct @Pas { case }
//1vx @Code const |2.5ct @Pas { const }
//1vx @Code div |2.5ct @Pas { div }
//1vx @Code do |2.5ct @Pas { do }
//1vx @Code downto |2.5ct @Pas { downto }
//1vx @Code else |2.5ct @Pas { else }
//1vx @Code end |2.5ct @Pas { end }
//1vx @Code file |2.5ct @Pas { file }
//1vx @Code for |2.5ct @Pas { for }
//1vx @Code forward |2.5ct @Pas { forward }
//1vx @Code function |2.5ct @Pas { function }
//1vx @Code goto |2.5ct @Pas { goto }
//1vx @Code if |2.5ct @Pas { if }
//1vx @Code in |2.5ct @Pas { in }
//1vx @Code label |2.5ct @Pas { label }
//1vx @Code mod |2.5ct @Pas { mod }
//1vx @Code nil |2.5ct @Pas { nil }
//1vx @Code not |2.5ct @Pas { not }
//1vx @Code of |2.5ct @Pas { of }
//1vx @Code or |2.5ct @Pas { or }
//1vx @Code otherwise |2.5ct @Pas { otherwise }
//1vx @Code packed |2.5ct @Pas { packed }
//1vx @Code procedure |2.5ct @Pas { procedure }
//1vx @Code program |2.5ct @Pas { program }
//1vx @Code record |2.5ct @Pas { record }
//1vx @Code repeat |2.5ct @Pas { repeat }
//1vx @Code set |2.5ct @Pas { set }
//1vx @Code then |2.5ct @Pas { then }
//1vx @Code to |2.5ct @Pas { to }
//1vx @Code type |2.5ct @Pas { type }
//1vx @Code until |2.5ct @Pas { until }
//1vx @Code var |2.5ct @Pas { var }
//1vx @Code while |2.5ct @Pas { while }
//1vx @Code with |2.5ct @Pas { with }
} | 7c @Wide {
@Code "0" |2.5ct @Pas { 0 }
//1vx @Code "1" |2.5ct @Pas { 1 }
//1vx @Code "2" |2.5ct @Pas { 2 }
//1vx @Code "3" |2.5ct @Pas { 3 }
//1vx @Code "4" |2.5ct @Pas { 4 }
//1vx @Code "5" |2.5ct @Pas { 5 }
//1vx @Code "6" |2.5ct @Pas { 6 }
//1vx @Code "7" |2.5ct @Pas { 7 }
//1vx @Code "8" |2.5ct @Pas { 8 }
//1vx @Code "9" |2.5ct @Pas { 9 }
//1vx @Code "." |2.5ct @Pas { . }
//1vx @Code "," |2.5ct @Pas { , }
//1vx @Code ":" |2.5ct @Pas { : }
//1vx @Code ";" |2.5ct @Pas { ; }
//1vx @Code "'" |2.5ct @Pas { ' }
//1vx @Code "`" |2.5ct @Pas { ` }
//1vx @Code "+" |2.5ct @Pas { + }
//1vx @Code "-" |2.5ct @Pas { - }
//1vx @Code "*" |2.5ct @Pas { * }
//1vx @Code "/" |2.5ct @Pas { / }
//1vx @Code "(" |2.5ct @Pas { ( }
//1vx @Code ")" |2.5ct @Pas { ) }
//1vx @Code "[" |2.5ct @Pas { [ }
//1vx @Code "]" |2.5ct @Pas { ] }
//1vx @Code "^" |2.5ct @Pas { ^ }
//1vx @Code ".." |2.5ct @Pas { .. }
//1vx @Code "=" |2.5ct @Pas { = }
//1vx @Code "<" |2.5ct @Pas { < }
//1vx @Code ">" |2.5ct @Pas { > }
//1vx @Code "<>" |2.5ct @Pas { <> }
//1vx @Code "<=" |2.5ct @Pas { <= }
//1vx @Code ">=" |2.5ct @Pas { >= }
//1vx @Code ":=" |2.5ct @Pas { := }
}
}
Anything not mentioned here will appear in italic font.
@PP
Pascal character strings need a little attention before formatting by
Pas. Their interiors are best enclosed in double quotes to prevent the
above transformations from occurring inside them. Any @Code "\\" or
@Code "\"" characters inside strings will need to be replaced by
@Code "\\\\" and @Code "\\\"" respectively, and the opening quote should
be replaced by {@Code "`"}.
@PP
Similar remarks apply to Pascal comments; don't forget that @Code "{"
and @Code "}" must be enclosed in double quotes. Alternatively, a
@Code "@Com" symbol can be placed in front of a comment enclosed
in braces. It will add literal braces:
@ID @Code {
"@Com { A Pascal comment }"
}
has result
@ID @Pas {
@Com { A Pascal comment }
}
It may still be necessary to enclose the interior in double quotes.
@End @Appendix