home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / fweb153.zip / fweb-1.53 / web / t_codes.hweb < prev    next >
Text File  |  1995-09-23  |  10KB  |  222 lines

  1. @z --- t_codes.hweb ---
  2.  
  3. FWEB version 1.53 (September 23, 1995)
  4.  
  5. Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
  6.  
  7. @x-----------------------------------------------------------------------------
  8.  
  9. @ If the first byte of a token is less than $|0200| \equiv |ID0|$, the
  10. token occupies a single byte. Another way of saying this is that codes less
  11. than $|0200| \equiv |0x80| \equiv |0177| \equiv 128 \equiv 2^7$ are 7-bit
  12. ASCII codes that represent themselves.  In particular, a single-character
  13. identifier like~`|x|' will be a one-byte token, while all longer
  14. identifiers will occupy two bytes.  We shall use the macro |TOKEN1| to help
  15. us test for such a token, as in `|if(TOKEN1(a))@;|\dots'.
  16.  
  17. Some of the 7-bit ASCII codes will not be present, however, so we can
  18. use them for special purposes. The following symbolic names are used:
  19.  
  20. \yskip \hang |join| denotes the concatenation of adjacent items with no
  21. space or line breaks allowed between them (the \.{@@\&} operation of \.{WEB}).
  22.  
  23. \hang |stringg| denotes the beginning or end of a string or verbatim
  24. construction;
  25.  
  26. \hang |constant| denotes the beginning or end of a numerical constant.
  27. @^ASCII code@>
  28.  
  29. @D stringg OCTAL(2) /* Extended ASCII alpha should not appear. (The funny
  30.     spelling is to avoid conflict with the VAX' \.{stdlib}.) */
  31. @D constant OCTAL(3) // Numerical constant.
  32. @D begin_Xmeta or_or
  33. @D end_Xmeta star_star
  34. @D cdir OCTAL(6) // Brackets compiler directive..
  35. @D colon_colon OCTAL(11) // \Cpp\ and \Fortran--90: `$\CF$'.
  36.  
  37. @D join OCTAL(177) // |ASCII| delete will not appear.
  38.  
  39. @d ID0 0200 // $128 =$ end of the 7-bit ASCII codes.
  40. @d TOKEN1(a) ((a) < ID0) // Is |a|~a single-byte token?
  41.  
  42. @ Otherwise we make a sixteen-bit token by combining two consecutive
  43. bytes~|a| and~|b|. If $|0200| <= a < |0250| \equiv |MOD0|$, then
  44. $(a-|0200|) \times 2^8 + |b|$ corresponds to an identifier; we shall
  45. introduce the macro |IDENTIFIER(a,b)| to perform this construction. (This
  46. means that there must be fewer than 10,240 identifiers, since $|050|\times
  47. 2^8 = 10,240$.) If
  48. |0250<=a<0320|, then $(a-|0250|) \times 2^8 +|b|$ points to a module name.
  49. (Thus, there must be fewer than 10,240 module names.)
  50. Otherwise, i.e., if |0320<=a<0400|, then $(a-|0320|) \times 2^8 +|b|$ is
  51. the number of the module in which the current replacement text appears.
  52. (Notice that this allows more module numbers than module names. Thus, we
  53. can use the tokens between~|0370| and~|0377| for other purposes. For
  54. example, see the definition of |MACRO_ARGUMENT|.)
  55.  
  56. @m MOD0 0250 
  57. @m MOD1 0320
  58.  
  59. @d MACRO_ARGUMENT 0377 /* See the related definition and discussion of
  60.                 |MOD0|. */  
  61. @d BASE2 0400 /* |0xFF + 1 = 0x100 = 256| */
  62.  
  63. @d MODULE_NAME $EVAL((MOD0-0200)<<8) /* |024000= 10240 = (0250-0200)*0400| */
  64. @d MODULE_NUM $EVAL((MOD1-0200)<<8) /* |050000 = 20480 = (0320-0200)*0400| */
  65. @d LINE_NUM $EVAL(MOD1<<8)@&L /* |0150000==0320*0400| */
  66.  
  67. @d IDENTIFIER(left,right) 
  68.     ((sixteen_bits)( ((left)-ID0)*BASE2 + (sixteen_bits)(right) ))
  69.      /* Construct two-byte token out of its constituents. */
  70.  
  71. @d LEFT(a,id) ((eight_bits)(((a)/BASE2 + (id)))) /* Make left-hand byte out of
  72.                     |sixteen_bits|. */ 
  73. @d RIGHT(a) ((eight_bits)(((a) % BASE2))) /* Make right-hand byte. */
  74.  
  75. @ Control codes in \.{WEB} begin with `\.{@@}', and the next character
  76. identifies the code. Some of these are of interest only to \.{WEAVE},
  77. so \.{TANGLE} ignores them; the others are converted by \.{TANGLE} into
  78. internal code numbers by the |control_code| table below. The ordering
  79. of these internal code numbers has been chosen to simplify the program logic;
  80. larger numbers are given to the control codes that denote more significant
  81. milestones.
  82.  
  83. The following table shows the assignments:
  84. $$\def\:{\char\count255\global\advance\count255 by 1}
  85. \def\Hrule{\noalign{\hrule}}\def\HHrule{\noalign{\hrule height2pt}}
  86. \def\Width{60pt}
  87. \count255='40
  88. \vbox{
  89. \hbox{\hbox to \Width{\it\hfill0\/\hfill}%
  90. \hbox to \Width{\it\hfill1\/\hfill}%
  91. \hbox to \Width{\it\hfill2\/\hfill}%
  92. \hbox to \Width{\it\hfill3\/\hfill}%
  93. \hbox to \Width{\it\hfill4\/\hfill}%
  94. \hbox to \Width{\it\hfill5\/\hfill}%
  95. \hbox to \Width{\it\hfill6\/\hfill}%
  96. \hbox to \Width{\it\hfill7\/\hfill}}
  97. \vskip 4pt
  98. \hrule
  99. \def\!{\vrule height 10.5pt depth 4.5pt}
  100. \halign{\hbox to 0pt{\hskip -24pt\WO{\~#}\hfill}&\!
  101. \hbox to \Width{\hfill$#$\hfill\!}&
  102. &\hbox to \Width{\hfill$#$\hfill\!}\cr
  103. 00&\\{ignore}&\MM &\\{verbatim}&\\{force\_line}&\WW    &**     &\CC    &\\{bell}\cr\Hrule
  104. 01&\dots  &\\{begin\_cmnt}&\\{lf} &\PP    &\\{ff} &\\{cr}
  105.     &\\{begin\_lang}       &\\{begin\_meta}        \cr\Hrule
  106. 02&\GG    &\LS    &\LL    &\.{.DOT.}&;    &\SR    &\SlSl  &\\{end\_meta}
  107. \cr\Hrule 
  108. 03&\\{stmt\_label}&\MG   &\WI    &\WL    &\NN    &\WG    &\WS    &\WV     \cr\HHrule
  109. 04&       &\WR    &       &\#     &       &\MOD   &\amp   &        \cr\Hrule
  110. 05&       &       &\ast   &+      &       &-      &       &/       \cr\Hrule
  111. 06&       &       &       &       &       &       &       &        \cr\Hrule
  112. 07&       &       &       &       &<      &=      &>      &?       \cr\Hrule
  113. 10&\Wcp   &\Wcm   &\Wcs   &\Wcv   &\Wcd   &\Wcx   &\Wca   &\Wco    \cr\Hrule
  114. 11&\Wcg   &\Wcl   &       &       &       &       &       &        \cr\Hrule
  115. 12&       &       &       &       &       &       &       &        \cr\Hrule
  116. 13&       &       &       &       &       &       &\^     &        \cr\Hrule
  117. 14&       &       &       &       &       &       &       &        \cr\Hrule
  118. 15&       &       &       &       &       &       &       &        \cr\Hrule
  119. 16&       &       &       &       &       &       &       &        \cr\Hrule
  120. 17&       &       &       &       &\OR    &\.{@@\$}&\.{@@\_},\TL&\\{join}\cr\HHrule
  121. 20&\.{L$l$}&\.{C} &\.{R}  &\.{N}  &\.{M}  &\.{X}  &       &        \cr\Hrule
  122. 21&\NP    &\NC    &\.{\#<}&\WPtr  &\CC    &       &       &
  123. \cr\Hrule
  124. 22&       &       &       &       &       &       &       &        \cr\Hrule
  125. 23&\\{constant}&\\{stringg}&\\{identifier}&\.{@@\^}&\.{@@9} &\.{@@.} &\.{@@t} &\.{@@'}  \cr\Hrule
  126. 24&\.{@@\&}&\.{@@,} &\.{@@\char'174}&\.{@@/} &\.{@@\#} &\.{@@+} &\.{@@;}& \cr\Hrule
  127. 25&\.{@@(} &\.{@@)} &\.{\ } &\\{copy\_mode}&\\{toggle\_output}&\.{@@e}&\.{@@:}&
  128. \cr\Hrule
  129. 26&       &       &\.{@@!} &       &       &\.{@@0} &\.{@@1} &\.{@@2}  \cr\Hrule
  130. 27&\.{@@f} &\.{@@\%}&       &       &\.{@@l} &\.{@@o} &\.{@@d} &\.{@@m}  \cr\Hrule
  131. 30&\.{@@\#ifdef}&\.{@@\#ifndef}&\.{@@\#if}&\.{@@\#else}&\.{@@\#elif}&\.{@@\#endif}
  132. &\.{@@\#pragma}       &\.{@@\#undef}\cr\Hrule
  133. 31&\.{@@a} &\.{@@<} &\.{@@\ }&       &       &       &       &        \cr\Hrule
  134. 32&       &       &       &       &       &       &       &        \cr\Hrule
  135. 33&       &       &       &       &       &       &       &        \cr\Hrule
  136. 34&       &       &       &       &       &       &       &
  137. \cr\Hrule
  138. 35&       &       &       &       &       &       &       &
  139. \cr\Hrule
  140. 36&       &       &       &       &       &       &       &
  141. \cr\Hrule
  142. 37&       &       &       &       &       &       &\\{begin\_cmnt0}&        \cr}
  143. \hrule width 480pt}$$
  144.  
  145. @D ignore 0 // Control code of no interest to \.{TANGLE}.
  146.  
  147. @d begin_comment0 HEX(FE) // Sent from |input_ln|; marker for long comment.
  148. @d begin_comment1 HEX(FD) // As above; marker for short comment.
  149.  
  150. @D module_number OCTAL(201) // Code returned by |get_output| for mod.\ numbers.
  151. @D identifier OCTAL(202) // Code returned by |get_output| for identifiers.
  152. @D id_keyword OCTAL(203) // As above, but for expandable keyword.
  153.  
  154. @D L_switch OCTAL(257) // Control code for `\.{@@L}'.
  155. @D begin_FORTRAN OCTAL(260)
  156. @D begin_RATFOR OCTAL(261)
  157. @D begin_C OCTAL(262)
  158. @D begin_LITERAL OCTAL(263)
  159.  
  160. @D verbatim OCTAL(264)  /* Can't be~|02| as for \.{fweave}, because
  161.                 |stringg| is defined to be that. */
  162.  
  163. @D invisible_cmnt OCTAL(265) // Control code for `\.{@@\%}'.
  164. @D compiler_directive OCTAL(266) // No longer used.
  165. @D Compiler_Directive OCTAL(267) // Control code for `\.{@@?}'.
  166. @D no_index OCTAL(300)    // Control code for `\.{@@-}'.
  167. @D yes_index OCTAL(301) // Control code for `\.{@@+}'.
  168.  
  169. @D ascii_constant OCTAL(302) // Control code for `\.{@@'}'.
  170. @D begin_vcmnt OCTAL(303) // Control code for `\.{@@\slashstar}'.
  171. @D big_line_break OCTAL(304) // Control code for `\.{@@\#}'.
  172.  
  173. @D begin_bp OCTAL(305)
  174. @D insert_bp OCTAL(306)
  175.  
  176. @D begin_meta OCTAL(17) // Control code for |"@@("|.
  177. @D end_meta OCTAL(27)
  178.  
  179. @D TeX_string OCTAL(307)
  180. @D xref_roman OCTAL(310)
  181. @D xref_typewriter OCTAL(311)
  182. @D xref_wildcard OCTAL(312)
  183.  
  184. @D control_text OCTAL(313) // Control code for `\.{@@t}', `\.{@@\^}', etc.
  185.  
  186. @D begin_nuweb OCTAL(314)
  187. @D no_mac_expand OCTAL(315) // Control code for `\.{@@\~}'
  188. @D set_line_info OCTAL(316) // Expt'l control code for `\.{@@Q}'. 
  189.  
  190. @D formatt OCTAL(320) // Control code for `\.{@@f}'.
  191.  
  192. @D limbo_text OCTAL(323) // Control code for `\.{@@l}'.
  193. @D op_def OCTAL(324)    // Control code for `\.{@@v}'.
  194. @D macro_def OCTAL(325)    // Control code for `\.{@@W}'.
  195.  
  196. @D ignore_defn OCTAL(327)// Stuff to here should be ignored when scanning defn.
  197.  
  198. @D new_output_file OCTAL(331) // Control code for `\.{@@o}'.
  199.  
  200. @D definition OCTAL(332) // Control code for `\.{@@d}'.
  201. @D undefinition OCTAL(333) // Control code for `\.{@@u}'.
  202. @D WEB_definition OCTAL(334) // Control code for `\.{@@m}'.
  203.  
  204. @D m_ifdef OCTAL(335)
  205. @D m_ifndef OCTAL(336)
  206. @D m_if OCTAL(337)
  207. @D m_else OCTAL(340)
  208. @D m_elif OCTAL(341)
  209. @D m_endif OCTAL(342)
  210. @D m_for OCTAL(343)
  211. @D m_endfor OCTAL(344)
  212. @D m_line OCTAL(345)
  213. @D m_undef OCTAL(346)
  214.  
  215. @D end_of_buffer OCTAL(347)
  216.  
  217. @D begin_code OCTAL(350) // Control code for `\.{@@a}'.
  218. @D module_name OCTAL(351) // Control code for `\.{@@<}'.
  219.  
  220. @D new_module OCTAL(352) // Control code for `\.{@@\ }' and `\.{@@*}'.
  221.  
  222.