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 >
Text File  |  1994-01-25  |  6KB  |  165 lines

  1. @Appendix
  2.     @Title { Pas -- a Lout Package for Printing Pascal Programs }
  3. @Begin
  4. @PP
  5. Pas
  6. @Reference
  7.    @Tag { jensen75 }
  8.    @Type { Book }
  9.    @Author { Jensen, K. and Wirth, N. }
  10.    @Title { Pascal User Manual and Report }
  11.    @Publisher { Springer-Verlag }
  12.    @Year { 1975 }
  13. is a package of definitions for printing Pascal programs
  14. [{@Ref jensen75}] neatly with the Lout document formatter
  15. [{@Ref kingston92}].  No attempt is made to follow any particular
  16. printing standard; the design simply reflects the author's taste.
  17. @PP
  18. The package is so simple that there is very little to say about
  19. it.  To use Pas, place @Code "@SysInclude { pas }" in the setup file,
  20. or type @Code "-ipas" in the command line.  A Pascal program is
  21. entered like this, where the @Code "@ID" symbol from the DocumentLayout
  22. package [{@Ref kingston92begin}] has been used to obtain an indented display:
  23. @ID @Code {
  24. "@ID @Pas {"
  25. "procedure PriDelete(x: PriEntry; var Q: PriorityQueue);"
  26. "    var i: integer;"
  27. "begin"
  28. "    with Q^ do begin"
  29. "        size := size - 1;"
  30. "        if x^.back <= size then"
  31. "        begin"
  32. "            i := x^.back;"
  33. "            A[i] := A[size + 1];"
  34. "            A[i]^.back := i;"
  35. "            PriAddRoot(i, Q);"
  36. "            PriAddLeaf(i, Q)"
  37. "        end"
  38. "    end"
  39. "end;"
  40. "}"
  41. }
  42. The result will come out like this:
  43. @ID @Pas {
  44. procedure PriDelete(x: PriEntry; var Q: PriorityQueue);
  45.     var i: integer;
  46. begin
  47.     with Q^ do begin
  48.     size := size - 1;
  49.     if x^.back <= size then
  50.     begin
  51.         i := x^.back;
  52.         A[i] := A[size + 1];
  53.         A[i]^.back := i;
  54.         PriAddRoot(i, Q);
  55.         PriAddLeaf(i, Q)
  56.     end
  57.     end
  58. end;
  59. }
  60. Blank lines, line breaks, indents and spaces in the input are respected, with a
  61. tab being considered equal to eight spaces.  @Code "@Pas" can also be used
  62. within a paragraph to produce Pascal fragments like @Pas { A[i..j] }.  Use
  63. @Code "@OneCol @Pas { ... }" to prevent the result from breaking over two
  64. lines.
  65. @PP
  66. @Code "@Pas" does not attempt to rearrange the program in any way.  Each
  67. item is simply printed according to the following plan:
  68. @ID {
  69. 7c @Wide {
  70.       @Code and     |2.5ct @Pas { and }
  71. //1vx @Code array     |2.5ct @Pas { array }
  72. //1vx @Code begin     |2.5ct @Pas { begin }
  73. //1vx @Code case     |2.5ct @Pas { case }
  74. //1vx @Code const     |2.5ct @Pas { const }
  75. //1vx @Code div     |2.5ct @Pas { div }
  76. //1vx @Code do         |2.5ct @Pas { do }
  77. //1vx @Code downto     |2.5ct @Pas { downto }
  78. //1vx @Code else     |2.5ct @Pas { else }
  79. //1vx @Code end     |2.5ct @Pas { end }
  80. //1vx @Code file     |2.5ct @Pas { file }
  81. //1vx @Code for     |2.5ct @Pas { for }
  82. //1vx @Code forward    |2.5ct @Pas { forward }
  83. //1vx @Code function     |2.5ct @Pas { function }
  84. //1vx @Code goto     |2.5ct @Pas { goto }
  85. //1vx @Code if         |2.5ct @Pas { if }
  86. //1vx @Code in         |2.5ct @Pas { in }
  87. //1vx @Code label     |2.5ct @Pas { label }
  88. //1vx @Code mod     |2.5ct @Pas { mod }
  89. //1vx @Code nil     |2.5ct @Pas { nil }
  90. //1vx @Code not     |2.5ct @Pas { not }
  91. //1vx @Code of         |2.5ct @Pas { of }
  92. //1vx @Code or         |2.5ct @Pas { or }
  93. //1vx @Code otherwise     |2.5ct @Pas { otherwise }
  94. //1vx @Code packed     |2.5ct @Pas { packed }
  95. //1vx @Code procedure     |2.5ct @Pas { procedure }
  96. //1vx @Code program     |2.5ct @Pas { program }
  97. //1vx @Code record     |2.5ct @Pas { record }
  98. //1vx @Code repeat     |2.5ct @Pas { repeat }
  99. //1vx @Code set     |2.5ct @Pas { set }
  100. //1vx @Code then     |2.5ct @Pas { then }
  101. //1vx @Code to         |2.5ct @Pas { to }
  102. //1vx @Code type     |2.5ct @Pas { type }
  103. //1vx @Code until     |2.5ct @Pas { until }
  104. //1vx @Code var     |2.5ct @Pas { var }
  105. //1vx @Code while     |2.5ct @Pas { while }
  106. //1vx @Code with     |2.5ct @Pas { with }
  107. } | 7c @Wide {
  108.       @Code "0"        |2.5ct @Pas { 0 }
  109. //1vx @Code "1"        |2.5ct @Pas { 1 }
  110. //1vx @Code "2"        |2.5ct @Pas { 2 }
  111. //1vx @Code "3"        |2.5ct @Pas { 3 }
  112. //1vx @Code "4"        |2.5ct @Pas { 4 }
  113. //1vx @Code "5"        |2.5ct @Pas { 5 }
  114. //1vx @Code "6"        |2.5ct @Pas { 6 }
  115. //1vx @Code "7"        |2.5ct @Pas { 7 }
  116. //1vx @Code "8"        |2.5ct @Pas { 8 }
  117. //1vx @Code "9"        |2.5ct @Pas { 9 }
  118. //1vx @Code "."        |2.5ct @Pas { . }
  119. //1vx @Code ","        |2.5ct @Pas { , }
  120. //1vx @Code ":"        |2.5ct @Pas { : }
  121. //1vx @Code ";"        |2.5ct @Pas { ; }
  122. //1vx @Code "'"        |2.5ct @Pas { ' }
  123. //1vx @Code "`"        |2.5ct @Pas { ` }
  124. //1vx @Code "+"        |2.5ct @Pas { + }
  125. //1vx @Code "-"        |2.5ct @Pas { - }
  126. //1vx @Code "*"        |2.5ct @Pas { * }
  127. //1vx @Code "/"        |2.5ct @Pas { / }
  128. //1vx @Code "("        |2.5ct @Pas { ( }
  129. //1vx @Code ")"        |2.5ct @Pas { ) }
  130. //1vx @Code "["        |2.5ct @Pas { [ }
  131. //1vx @Code "]"        |2.5ct @Pas { ] }
  132. //1vx @Code "^"        |2.5ct @Pas { ^ }
  133. //1vx @Code ".."    |2.5ct @Pas { .. }
  134. //1vx @Code "="        |2.5ct @Pas { = }
  135. //1vx @Code "<"        |2.5ct @Pas { < }
  136. //1vx @Code ">"        |2.5ct @Pas { > }
  137. //1vx @Code "<>"    |2.5ct @Pas { <> }
  138. //1vx @Code "<="    |2.5ct @Pas { <= }
  139. //1vx @Code ">="    |2.5ct @Pas { >= }
  140. //1vx @Code ":="    |2.5ct @Pas { := }
  141. }
  142. }
  143. Anything not mentioned here will appear in italic font.
  144. @PP
  145. Pascal character strings need a little attention before formatting by
  146. Pas.  Their interiors are best enclosed in double quotes to prevent the
  147. above transformations from occurring inside them.  Any @Code "\\" or
  148. @Code "\"" characters inside strings will need to be replaced by
  149. @Code "\\\\" and @Code "\\\"" respectively, and the opening quote should
  150. be replaced by {@Code "`"}.
  151. @PP
  152. Similar remarks apply to Pascal comments; don't forget that @Code "{"
  153. and @Code "}" must be enclosed in double quotes.  Alternatively, a
  154. @Code "@Com" symbol can be placed in front of a comment enclosed
  155. in braces.  It will add literal braces:
  156. @ID @Code {
  157. "@Com { A Pascal comment }"
  158. }
  159. has result
  160. @ID @Pas {
  161. @Com { A Pascal comment }
  162. }
  163. It may still be necessary to enclose the interior in double quotes.
  164. @End @Appendix
  165.