prod.w
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:13k
源码类别:

通讯编程

开发平台:

Visual C++

  1. % This file is part of CWEB.
  2. % This program by Silvio Levy and Donald E. Knuth
  3. % is based on a program by Knuth.
  4. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  5. % Version 3.0 --- June 1993
  6. %
  7. @
  8. defv{char'174} 
  9. mathchardefRA="3221 % right arrow
  10. mathchardefBA="3224 % double arrow
  11. Here is a table of all the productions.  Each production that
  12. combines two or more consecutive scraps implicitly inserts a {tt $}
  13. where necessary, that is, between scraps whose abutting boundaries
  14. have different |mathness|.  In this way we never get double {tt$$}.
  15. A translation is provided when the resulting scrap is not merely a
  16. juxtaposition of the scraps it comes from.  An asterisk$^*$ next to a scrap
  17. means that its first identifier gets an underlined entry in the index,
  18. via the function |make_underlined|.  Two asterisks$^{**}$ means that both
  19. |make_underlined| and |make_reserved| are called; that is, the
  20. identifier's ilk becomes |raw_int|.  A dagger dag before the
  21. production number refers to the notes at the end of this section,
  22. which deal with various exceptional cases.
  23. We use \{in}, \{out}, \{back} and
  24. \{bsp} as shorthands for |indent|, |outdent|, |backup| and
  25. |break_space|, respectively.
  26. begingroup lineskip=4pt
  27. defalt #1 #2
  28. {$displaystyleBigl{!matrix{struthbox{#1}cr
  29.    struthbox{#2}cr}!Bigr}$ }
  30. defaltt #1 #2 #3
  31. {$displaystyleBiggl{!matrix{struthbox{#1}crhbox{#2}cr
  32.    struthbox{#3}cr}!Biggr}$ }
  33. defmalt #1 #2
  34. {$displaystylematrix{struthbox{#1}hfillcrstruthbox{#2}hfillcr}$}
  35. defmaltt #1 #2 #3
  36. {$displaystylematrix{struthbox{#1}hfillcrhbox{#2}hfillcr
  37.    struthbox{#3}hfillcr}$}
  38. yskipnewcountprodnoprodno=0
  39. newdimenmidcol midcol=2.5in
  40. deftheprodno{numberprodno globaladvanceprodno by1enspace}
  41. def+#1&#2&#3&#4cr{defnext{#1}%
  42.  line{hbox to 2em{hss
  43.   ifxnextemptytheprodnoelsenextfi}strut
  44.   ignorespaces#2hfilhbox tomidcol{$RA$
  45.   ignorespaces#3hfil}quad hbox to1.45in{ignorespaces#4hfil}}}
  46. +relax & LHS & RHS hfill Translation & Examplecr
  47. yskip
  48. +& altt\{any} {\{any} \{any}} {\{any} \{any} \{any}}
  49. |insert| & altt\{any} {\{any} \{any}} {\{any} \{any} \{any}}
  50. & stmt;  /$ast,$comment$,*$/cr
  51. +& |exp| altt|lbrace| |int_like| |decl|
  52.     & |fn_decl| altt|lbrace| |int_like| |decl|
  53.         hfill $F=E^*,|in|,|in|$ & malt {\{main}()${$}
  54.            {\{main}$(\{ac},\{av})$ &{int} \{ac};} cr
  55. +& |exp| |unop| & |exp| & |x++|cr
  56. +& |exp| alt |binop| |unorbinop| |exp| & |exp| & malt {|x/y|} {|x+y|} cr
  57. +& |exp| |comma| |exp| & |exp| hfill $EC,|opt|9,E$& |f(x,y)|cr
  58. +& |exp| alt |exp| |cast| & |exp| & |time()|cr
  59. +& |exp| |semi| & |stmt| & |x=0;|cr
  60. +& |exp| |colon| & |tag| hfill $E^*C$ & |found:|cr
  61. +& |exp| |base| |int_like| |comma| & |base| hfill $B. IC$,|opt|9
  62.  & &D : &C,cr
  63. +& |exp| |base| |int_like| |lbrace| & |exp| |lbrace| hfill
  64.      $E=E. B. I$ & &D : &C ${$cr
  65. +& |exp| |rbrace| & |stmt| |rbrace| & end of &{enum} listcr
  66. +& |lpar| alt |exp| |unorbinop| |rpar| & |exp| & malt{|(x)|} {|(*)|} cr
  67. +& |lpar| |rpar| & |exp| hfill $L.{\,}R$ & functions, declarationscr
  68. +& |lpar| alt |decl_head| |int_like| |rpar| & |cast| & |(char*)|cr
  69. +& |lpar| altt |decl_head| |int_like| |exp| |comma| & |lpar| hfill
  70.      $L$,altt $D$ $I$ $E$ C,|opt|9 & |(int,|cr
  71. +& |lpar| alt |stmt| |decl| & |lpar| hfill alt {$LS. $} {$LD. $} &
  72.     alt {|(k=5;|} {|(int k=5;|} cr
  73. +& |question| |exp| |colon| & |binop| & |?x:|cr
  74. +& |unop| alt |exp| |int_like| & alt |exp| |int_like| &
  75.   malt |!x| |~|&C cr
  76. +& |unorbinop| alt|exp| |int_like| & alt|exp| |int_like| hfill
  77.   $.{U.}E$ & |*x|cr
  78. +& |unorbinop| |binop| & |binop| hfill $|math_rel|,U.{B.}.}$ & |*=|cr
  79. +& |binop| |binop| & |binop| hfill
  80.                         $|math_rel|,.{B_1.}.{B_2.}.}$ & |>>=|cr
  81. +& |cast| |exp| & |exp| hfill $C. E$ & |(double)x|cr
  82. +& |cast| |semi| & |exp| |semi| & |(int);|cr
  83. +& |sizeof_like| |cast| & |exp| & |sizeof (double)|cr
  84. +& |sizeof_like| |exp| & |exp| hfill $S. E$ & |sizeof x|cr
  85. +& |int_like| alt|int_like| |struct_like| &
  86.         alt|int_like| |struct_like| hfill $I. $alt $I$ $S$
  87.         unskip& |extern char|cr
  88. +& |int_like| |exp| alt|raw_int| |struct_like| &
  89.          |int_like| alt|int_like| |struct_like| & |extern "Ada" int|cr
  90. +& |int_like| altt|exp| |unorbinop| |semi| & |decl_head|
  91.                     altt|exp| |unorbinop| |semi| hfill
  92.                    $D=I$altt{. } {. } {} unskip & |int x|cr
  93. +& |int_like| |colon| & |decl_head| |colon| hfill $D=I. $ & |unsigned:|cr
  94. +& |int_like| |prelangle| & |int_like| |langle| & &C$langle$cr
  95. +& |int_like| |colcol| alt |exp| |int_like| & alt |exp| |int_like| &
  96.    malt {&CDC$x$} {&CDC&B} cr
  97. +& |int_like| |cast| |lbrace| & |fn_decl| |lbrace| hfill $IC,|in|,|in|$&
  98.     &C$langle&{void}astrangle{$cr
  99. +& |int_like| |cast| & |int_like| & &C$langle&{class} &Trangle$cr
  100. +& |decl_head| |comma| & |decl_head| hfill $DC. $ & |int x,|cr
  101. +& |decl_head| |unorbinop| & |decl_head| hfill $D.{U.}$ & |int *|cr
  102. +dagtheprodno& |decl_head| |exp| & |decl_head| hfill $DE^*$ & |int x|cr
  103. +& |decl_head| alt|binop| |colon| |exp| altt|comma| |semi| |rpar| &
  104.      |decl_head| altt|comma| |semi| |rpar| hfill
  105.      $D=D$alt $B$ $C$ unskip$E$ & maltt initialization {fields or}
  106.        {default argument} cr
  107. +& |decl_head| |cast| & |decl_head| & |int f(int)|cr
  108. +dagtheprodno& |decl_head| altt|int_like| |lbrace| |decl| & |fn_decl|
  109.                    altt|int_like| |lbrace| |decl| hfill $F=D,|in|,|in|$
  110.                              & |long time () {|cr
  111. +& |decl_head| |semi| & |decl| & |int n;|cr
  112. +& |decl| |decl| & |decl| hfill $D,|force|,D$ & |int n;double x;|cr
  113. +& |decl| alt|stmt| |function| & alt|stmt| |function|
  114.         hfill $D,|big_force|,$alt $S$ $F$ unskip& &{extern} $n$;
  115.             \{main} ()|{}|cr
  116. +dagtheprodno& |typedef_like| |decl_head| alt|exp| |int_like| &
  117.       |typedef_like| |decl_head| hfill $D=D$alt $E^{**}$ $I^{**}$ unskip &
  118.           &{typedef} &{char} &{ch};cr
  119. +& |typedef_like| |decl_head| |semi| & |decl| hfill $T. D$ &
  120.                                              &{typedef} &{int} $&x,&y$;cr
  121. +& |struct_like| |lbrace| & |struct_head| hfill $S. L$ & |struct {|cr
  122. +& |struct_like| alt|exp| |int_like| |semi| & |decl_head|
  123.      hfill $S. $alt $E^{**}$ $I^{**}$ & &{struct} &{forward};cr
  124. +& |struct_like| alt|exp| |int_like| |lbrace| & |struct_head| hfill
  125.      $S. $alt $E^{**}$ $I^{**}$ unskip $. L$ &
  126.               &{struct} &{name_info} ${$cr
  127. +& |struct_like| alt|exp| |int_like| |colon| &
  128.     |struct_like| alt|exp| |int_like| |base| & |class| &C :cr
  129. +dagtheprodno& |struct_like| alt|exp| |int_like| & |int_like|
  130.         hfill $S. $alt$E$ $I$ & &{struct} &{name_info} $z$;cr
  131. +& |struct_head| altt|decl| |stmt| |function| |rbrace| & |int_like|hfill
  132.          $S,\{in},|force|,D,\{out},|force|,R$ &
  133.                                         |struct {| declaration |}|cr
  134. +& |struct_head| |rbrace| & |int_like|hfill $S.{\,}R$ & |class C{}|cr
  135. +& |fn_decl| |decl| & |fn_decl| hfill $F,|force|,D$
  136.                                        & $f(z)$ &{double} $z$; cr
  137. +& |fn_decl| |stmt| & |function| hfill $F,|out|,|out|,|force|,S$
  138.                                        & \{main}() {dots}cr
  139. +& |function| altt|stmt| |decl| |function| & altt |stmt| |decl| |function|
  140.    hfill $F,|big_force|,$altt $S$ $D$ $F$ & outer blockcr
  141. +& |lbrace| |rbrace| & |stmt| hfill $L.{\,}R$ & empty statementcr
  142. advancemidcol35pt
  143. +& |lbrace| altt|stmt| |decl| |function| |rbrace| & |stmt| hfill
  144.      $|force|,L,\{in},|force|,S,
  145.                 |force|,\{back},R,\{out},|force|$ & compound statementcr
  146. advancemidcol-20pt
  147. +& |lbrace| |exp| [|comma|] |rbrace| & |exp| & initializercr
  148. +& |if_like| |exp| & |if_clause| hfill $I.{ }E$ & |if (z)|cr
  149. +& |for_like| |exp| & |else_like| hfill $F.{ }E$ & |while (1)|cr
  150. +& |else_like| |lbrace| & |else_head| |lbrace| & &{else} ${$cr
  151. +& |else_like| |stmt| & |stmt| hfill
  152.        $|force|,E,\{in},\{bsp},S,\{out},|force|$ & |else x=0;|cr
  153. +& |else_head| alt|stmt| |exp|  & |stmt| hfill
  154.       $|force|,E,\{bsp},|noop|,|cancel|,S,\{bsp}$ & |else{x=0;}|cr
  155. +& |if_clause| |lbrace| & |if_head| |lbrace| & |if (x) {|cr
  156. +& |if_clause| |stmt| |else_like| |if_like| & |if_like| hfill
  157.     $|force|,I,\{in},\{bsp},S,\{out},|force|,E,. I$ &
  158.      |if (x) y; else if|cr
  159. +& |if_clause| |stmt| |else_like| & |else_like| hfill
  160.     $|force|,I,\{in},\{bsp},S,\{out},|force|,E$ &
  161.    |if (x) y; else|cr
  162. +& |if_clause| |stmt| & |else_like| |stmt| & |if (x)|cr
  163. +& |if_head| alt|stmt| |exp| |else_like| |if_like| & |if_like| hfill
  164.     $|force|,I,\{bsp},|noop|,|cancel|,S,|force|,E,. I$ &
  165.      |if (x){y;}else if|cr
  166. +& |if_head| alt|stmt| |exp| |else_like| & |else_like| hfill
  167.     $|force|,I,\{bsp},|noop|,|cancel|,S,|force|,E$ &
  168.    |if (x){y;}else|cr
  169. +& |if_head| alt|stmt| |exp| & |else_head| alt|stmt| |exp| & |if (x){y;}|cr
  170. advancemidcol20pt
  171. +& |do_like| |stmt| |else_like| |semi| & |stmt| hfill
  172.       $D,\{bsp},|noop|,|cancel|,S,|cancel|,|noop|,\{bsp},ES$%
  173.       &       |do f(x); while (g(x));|cr
  174. advancemidcol-20pt
  175. +& |case_like| |semi| & |stmt| & |return;|cr
  176. +& |case_like| |colon| & |tag| & |default:|cr
  177. +& |case_like| |exp| |semi| & |stmt| hfill $C. ES$ & |return 0;|cr
  178. +& |case_like| |exp| |colon| & |tag| hfill $C. EC$ & |case 0:|cr
  179. +& |tag| |tag| & |tag| hfill $T_1,\{bsp},T_2$ & |case 0: case 1:|cr
  180. +& |tag| altt|stmt| |decl| |function| & altt|stmt| |decl| |function|
  181.        hfill $|force|,\{back},T,\{bsp},S$ & |case 0: z=0;|cr
  182. +dagtheprodno& |stmt| altt|stmt| |decl| |function| &
  183.    altt|stmt| |decl| |function|
  184.       hfill $S,$altt$|force|,S$ $|big_force|,D$ $|big_force|,F$ &
  185.       |x=1;y=2;|cr
  186. +& |semi| & |stmt| hfill . $S$& empty statementcr
  187. +dagtheprodno& |lproc| altt |if_like| |else_like| |define_like| & |lproc| &
  188.          maltt {{bf #include}} {bf#else} {bf#define} cr
  189. +& |lproc| |rproc| & |insert| & {bf#endif} cr
  190. +& |lproc| alt {|exp| [|exp|]} |function| |rproc| & |insert| hfill
  191.     $I$. alt {$E{[.{ \5}E]}$} {$F$} &
  192.  malt{{bf#define} $a$enspace 1} {{bf#define} $a$enspace${,b;,}$} cr
  193. +& |section_scrap| |semi| & |stmt|hfill $MS$ |force|
  194.    &$langle,$section name$,rangle$;cr
  195. +& |section_scrap| & |exp| &$langle,$section name$,rangle$cr
  196. +& |insert| |any| & |any| & .{v#includev}cr
  197. +& |prelangle| & |binop| hfill .< & $<$ not in templatecr
  198. +& |prerangle| & |binop| hfill .> & $>$ not in templatecr
  199. +& |langle| |exp| |prerangle| & |cast| & $langle,0,rangle$cr
  200. +& |langle| |prerangle| & |cast| hfill $L.{\,}P$ & $langle,rangle$cr
  201. +& |langle| alt|decl_head| |int_like| |prerangle| & |cast| &
  202.      $langle&{class},&Crangle$cr
  203. +& |langle| alt|decl_head| |int_like| |comma| & |langle| hfill
  204.      $L$,alt $D$ $I$ C,|opt|9 & $langle&{class},&C,$cr
  205. +& |public_like| |colon| & |tag| & &{private}:cr
  206. +& |public_like| & |int_like| & &{private}cr
  207. +& |colcol| alt|exp| |int_like| & alt|exp| |int_like| & |::x|cr
  208. +dagtheprodno&
  209.      |new_like| alt|exp| |raw_int| & |new_like| hfill $N. E$ & |new(1)|cr
  210. +& |new_like| alt|raw_unorbin| |colcol| & |new_like| & |new ::*|cr
  211. +& |new_like| |cast| & |exp| & |new(*)|cr
  212. +dagtheprodno& |new_like| & |exp| & |new|cr
  213. +dagtheprodno& |operator_like| altt|binop| |unop| |unorbinop| & |exp|
  214.     hfill $O$.{altt $B$ $U$ $U$unskip .} & |operator+|cr
  215. +& |operator_like| alt|new_like| |sizeof_like| & |exp| hfill $O. N$
  216.     & |operator delete|cr
  217. +& |operator_like| & |new_like| & conversion operatorcr
  218. +& |catch_like| alt|cast| |exp| & |fn_decl| hfill $CE,\{in},\{in}$ &
  219.     |catch (...)|cr
  220. +& |base| |public_like| |exp| |comma| & |base| hfill $BP. EC$ &
  221.      : &{public} $a$,cr
  222. +& |base| |public_like| |exp| & |base| |int_like| hfill $I=P. E$ &
  223.      : &{public} $a$cr
  224. +dagtheprodno& |raw_rpar| |const_like| & |raw_rpar| hfill $R. C$ &
  225.      ) &{const};cr
  226. +& |raw_rpar| & |rpar| & );cr
  227. +& |raw_unorbin| |const_like| & |raw_unorbin| hfill $RC$.{\ }
  228.      & $*$&{const} |x|cr
  229. +& |raw_unorbin| & |unorbinop| & $*$ |x|cr
  230. +& |const_like| & |int_like| & &{const} |x|cr
  231. +& |raw_int| |lpar| & |exp| & &{complex}$(x,y)$cr
  232. +& |raw_int| & |int_like|   & &{complex} |z|cr
  233. +& |begin_arg| |end_arg| & |exp| & .{@@[}&{char}$*$.{@@]}cr
  234. +& |any_other| |end_arg| & |end_arg| &    &{char}$*$.{@@]}cr
  235. yskip
  236. yskip
  237. yskip
  238. parindent=0pt
  239. dag{bf Notes}
  240. yskip
  241. Rule 35: The |exp| must not be immediately followed by |lpar| or~|exp|.
  242. Rule 38: The |int_like| must not be immediately followed by |colcol|.
  243. Rule 42: The |exp| must not be immediately followed by |lpar| or~|exp|.
  244. Rule 48: The |exp| or |int_like| must not be immediately followed by |base|.
  245. Rule 76: The |force| in the |stmt| line becomes \{bsp} if .{CWEAVE} has
  246. been invoked with the .{-f} option.
  247. Rule 78: The |define_like| case calls |make_underlined| on the following scrap.
  248. Rule 93: The |raw_int| must not be immediately followed by
  249. |prelangle| or |langle|.
  250. Rule 96: The |new_like| must not be immediately followed by |lpar|,
  251. |raw_int|, or |struct_like|.
  252. Rule 97: The operator after |operator_like|
  253. must not be immediately followed by a |binop|.
  254. Rule 103: The operator after |const_like| must be |semi|, |lbrace|, |comma|,
  255. |binop|, or |const_like|.
  256. endgroup