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.6 --- May
2000
7 @ Here is a table of all the productions. Each production that
8 combines two or more consecutive scraps implicitly inserts a
{\tt \$
}
9 where necessary
, that is
, between scraps whose abutting boundaries
10 have different |mathness|. In this way we never get double
{\tt\$\$
}.
12 % The following kludge is needed because \newcount
, \newdimen
, and \
+
13 % are
"\outer" control sequences that cannot be used in skipped text
!
14 \fi \newcount\prodno \newdimen\midcol \let\
+\relax \ifon
17 \mathchardef\RA
="3221 % right arrow
18 \mathchardef\BA="3224 % double arrow
20 A translation is provided when the resulting scrap is not merely a
21 juxtaposition of the scraps it comes from. An asterisk$^
*$ next to a scrap
22 means that its first identifier gets an underlined entry in the index
,
23 via the function |make_underlined|. Two asterisks$^
{**}$ means that both
24 |make_underlined| and |make_reserved| are called
; that is
, the
25 identifier's ilk becomes |raw_int|. A dagger \dag\ before the
26 production number refers to the notes at the end of this section
,
27 which deal with various exceptional cases.
29 We use \\
{in
}, \\
{out
}, \\
{back
} and
30 \\
{bsp
} as shorthands for |indent|
, |outdent|
, |backup| and
31 |break_space|
, respectively.
33 \begingroup \lineskip
=4pt
35 {$\displaystyle\Bigl\
{\
!\matrix
{\strut\hbox
{#
1}\cr
36 \strut\hbox
{#
2}\cr
}\
!\Bigr\
}$
}
38 {$\displaystyle\Biggl\
{\
!\matrix
{\strut\hbox
{#
1}\cr\hbox
{#
2}\cr
39 \strut\hbox
{#
3}\cr
}\
!\Biggr\
}$
}
41 {$\displaystyle\matrix
{\strut\hbox
{#
1}\hfill\cr\strut\hbox
{#
2}\hfill\cr
}$
}
43 {$\displaystyle\matrix
{\strut\hbox
{#
1}\hfill\cr\hbox
{#
2}\hfill\cr
44 \strut\hbox
{#
3}\hfill\cr
}$
}
46 \prodno
=0 \midcol
=2.5in
47 \def\theprodno
{\number\prodno \global\advance\prodno by1\enspace
}
48 \def\dagit
{\dag\theprodno
}
49 \def\
+#
1\cr{\def\next{#1}%
50 \line
{\hbox to
2em
{\hss
51 \ifx\next\empty\theprodno\else\next\fi
}\strut
52 \ignorespaces#
2\hfil\hbox to\midcol
{$\RA$
53 \ignorespaces#
3\hfil
}\quad \hbox to1.45in
{\ignorespaces#
4\hfil
}}}
54 \
+\relax
& LHS & RHS \hfill Translation & Example\cr
56 \
+& \altt\\{any} {\\{any} \\{any}} {\\{any} \\{any} \\{any}}
57 |insert|
& \altt\\{any} {\\{any} \\{any}} {\\{any} \\{any} \\{any}}
58 & stmt; \ /$\ast\,$comment$\,*$/\cr
59 \
+& |exp| \altt|lbrace| |int_like| |decl|
60 & |fn_decl| \altt|lbrace| |int_like| |decl|
61 \hfill $F
=E^
*\
,|in|\
,|in|$
& \malt {\\{main}()$\{$}
62 {\\
{main
}$
(\\
{ac
},\\
{av
})$ \
&{int} \\{ac};} \cr
63 \
+& |exp| |unop| & |exp| & |x++|\cr
64 \
+& |exp| \alt |binop| |ubinop| |exp| & |exp| & \malt {|x/y|} {|x+y|} \cr
65 \
+& |exp| |comma| |exp| & |exp| \hfill $EC\,|opt|9\,E$& |f(x,y)|\cr
66 \
+& |exp| \alt {|lpar| |rpar|} |cast| |colon| &
67 |exp| \alt
{|lpar| |rpar|
} |cast| |base|
&
68 \malt \
&C|()|: {\&C|int i)|:} \cr
69 \
+& |exp| |semi| & |stmt| & |x=0;|\cr
70 \
+& |exp| |colon| & |tag| \hfill $E^*C$ & |found:|\cr
71 \
+& |exp| |rbrace| & |stmt| |rbrace| & end of \&{enum} list\cr
72 \
+& |exp| \alt {|lpar| |rpar|} |cast| \alt|const_like| |case_like| &
73 |exp| \alt
{|lpar| |rpar|
} |cast| \hfill
74 \alt $R
=R\.\ C$ $C_1
=C_1\.\ C_2$
&
75 \malt
{|f
() const|
} {|f
(int
) throw|
} \cr
76 \
+& |exp| \alt |exp| |cast| & |exp| & |time()|\cr
77 \
+& |lpar| \alt |exp| |ubinop| |rpar| & |exp| & \malt{|(x)|} {|(*)|} \cr
78 \
+& |lpar| |rpar| & |exp| \hfill $L\.{\\,}R$ & functions, declarations\cr
79 \
+& |lpar| \altt |decl_head| |int_like| |cast| |rpar| & |cast| & |(char*)|\cr
80 \
+& |lpar| \altt |decl_head| |int_like| |exp| |comma| & |lpar| \hfill
81 $L$\
,\altt $D$ $I$ $E$ $C$\
,|opt|
9 & |(int,|\cr
82 \
+& |lpar| \alt |stmt| |decl| & |lpar| \hfill \alt {$LS\.\ $} {$LD\.\ $} &
83 \malt
{|
(k
=5;|
} {|
(int k
=5;|
} \cr
84 \
+& |unop| \alt |exp| |int_like| & |exp| &
86 \
+& |ubinop| |cast| |rpar| & |cast| |rpar| \hfill
87 $C
=\.\
{U\.\
}C$
& |*|\&{CPtr}) \cr
88 \
+& |ubinop| \alt|exp| |int_like| & \alt|exp| |int_like| \hfill
89 \.\
{$U$\.\
}\alt$E$ $I$
& \malt |*x| |*|\&{CPtr} \cr
90 \
+& |ubinop| |binop| & |binop| \hfill $|math_rel|\,U\.\{B\.\}\.\}$ & |*=|\cr
91 \
+& |binop| |binop| & |binop| \hfill
92 $|math_rel|\
,\.\
{B_1\.\
}\.\
{B_2\.\
}\.\
}$
& |>>=|\cr
93 \
+& |cast| \alt |lpar| |exp| & \alt |lpar| |exp| \hfill
94 \alt $CL$ $C\.\ E$
& \malt |(double)(x+2)| |(double)x| \cr
95 \
+& |cast| |semi| & |exp| |semi| & |(int);|\cr
96 \
+& |sizeof_like| |cast| & |exp| & |sizeof (double)|\cr
97 \
+& |sizeof_like| |exp| & |exp| \hfill $S\.\ E$ & |sizeof x|\cr
98 \
+& |int_like| \alt|int_like| |struct_like| &
99 \alt|int_like| |struct_like| \hfill $I\.\ $\alt $I$ $S$
100 \unskip
& |extern char|\cr
101 \
+& |int_like| |exp| \alt|raw_int| |struct_like| &
102 |int_like| \alt|raw_int| |struct_like|
& |extern "Ada" int|\cr
103 \
+& |int_like| \altt|exp| |ubinop| |colon| &
104 |decl_head| \altt|exp| |ubinop| |colon| \hfill
105 $D
=I$\.\
& \maltt|int x| |int*x| |unsigned:| \cr
106 \
+& |int_like| \alt |semi| |binop| & |decl_head| \alt |semi| |binop| &
107 \malt |int x
;|
{\
&{int} $f(\&{int}=4)$} \cr
108 \
+& |public_like| |colon| & |tag| & \&{private}:\cr
109 \
+& |public_like| & |int_like| & \&{private}\cr
110 \
+& |colcol| \alt|exp| |int_like| & \alt|exp| |int_like| \hfill
111 |qualifier| $C$ \alt$E$ $I$
& \&C\DC$x$\cr
112 \
+& |colcol| |colcol| & |colcol| & \&C\DC\&B\DC\cr
113 \
+& |decl_head| |comma| & |decl_head| \hfill $DC\.\ $ & |int x,|\cr
114 \
+& |decl_head| |ubinop| & |decl_head| \hfill $D\.\{U\.\}$ & |int *|\cr
115 \
+\dagit
& |decl_head| |exp| & |decl_head| \hfill $DE^*$ & |int x|\cr
116 \
+& |decl_head| \alt|binop| |colon| |exp| \altt|comma| |semi| |rpar| &
117 |decl_head| \altt|comma| |semi| |rpar| \hfill
118 $D
=D$\alt $B$ $C$ \unskip$E$
& \malt {\&{int} $f(\&{int}\ x=2)$} |int b:1| \cr
119 \
+& |decl_head| |cast| & |decl_head| & |int f(int)|\cr
120 \
+& |decl_head| \altt|int_like| |lbrace| |decl| & |fn_decl|
121 \altt|int_like| |lbrace| |decl| \hfill $F
=D\
,|in|\
,|in|$
122 & |long time () {|\cr
123 \
+& |decl_head| |semi| & |decl| & |int n;|\cr
124 \
+& |decl| |decl| & |decl| \hfill $D_1\,|force|\,D_2$ & |int n;double x;|\cr
125 \
+& |decl| \alt|stmt| |function| & \alt|stmt| |function|
126 \hfill $D\
,|big_force|\
,$\alt $S$ $F$ \unskip
& \&{extern} $n$;
128 \
+& |base| \alt |int_like| |exp| |comma| & |base| \hfill
129 $B$\.\ \alt $I$ $E$ \unskip$C$\
,|opt|
9
130 & \malt {: \&{public} \&A,} {: $i(5)$,} \cr
131 \
+& |base| \alt |int_like| |exp| |lbrace| & |lbrace| \hfill
132 $B$\.\ \alt $I$ $E$ \unskip\.\ $L$
& \&D : \&{public} \&A $\{$\cr
133 \
+& |struct_like| |lbrace| & |struct_head| \hfill $S\.\ L$ & |struct {|\cr
134 \
+& |struct_like| \alt|exp| |int_like| |semi| & |decl_head| |semi|
135 \hfill $S\.\ $\alt $E^
{**}$ $I^
{**}$
& \&{struct} \&{forward};\cr
136 \
+& |struct_like| \alt|exp| |int_like| |lbrace| & |struct_head| \hfill
137 $S\.\ $\alt $E^
{**}$ $I^
{**}$ \unskip $\.\ L$
&
138 \
&{struct} \&{name\_info} $\{$\cr
139 \
+& |struct_like| \alt|exp| |int_like| |colon| &
140 |struct_like| \alt|exp| |int_like| |base|
& |class| \&C :\cr
141 \
+\dagit
& |struct_like| \alt|exp| |int_like| & |int_like|
142 \hfill $S\.\ $\alt$E$ $I$
& \&{struct} \&{name\_info} $z$;\cr
143 \
+& |struct_head| \altt|decl| |stmt| |function| |rbrace| & |int_like|\hfill
144 $S\
,\\
{in
}\
,|force|$\altt$D$ $S$ $F$ $\\
{out
}\
,|force|\
,R$
&
145 |struct
{| declaration |
}|\cr
146 \
+& |struct_head| |rbrace| & |int_like|\hfill $S\.{\\,}R$ & |class C{}|\cr
147 \
+& |fn_decl| |decl| & |fn_decl| \hfill $F\,|force|\,D$
148 & $f(z)$ \&{double} $z$; \cr
149 \
+& |fn_decl| |stmt| & |function| \hfill $F\,|out|\,|out|\,|force|\,S$
150 & \\{main}() {\dots}\cr
151 \
+& |function| \altt|stmt| |decl| |function| & \altt |stmt| |decl| |function|
152 \hfill $F\
,|big_force|\
,$\altt $S$ $D$ $F$
& outer block\cr
153 \
+& |lbrace| |rbrace| & |stmt| \hfill $L\.{\\,}R$ & empty statement\cr
155 \
+& |lbrace| \altt|stmt| |decl| |function| |rbrace| & |stmt| \hfill
156 $|force|\
,L\
,\\
{in
}\
,|force|\
,S\
,
157 |force|\
,\\
{back
}\
,R\
,\\
{out
}\
,|force|$
& compound statement\cr
159 \
+& |lbrace| |exp| [|comma|] |rbrace| & |exp| & initializer\cr
160 \
+& |if_like| |exp| & |if_clause| \hfill $I\.{\ }E$ & |if (z)|\cr
161 \
+& |else_like| |colon| & |else_like| |base| & \&{try} :\cr
162 \
+& |else_like| |lbrace| & |else_head| |lbrace| & \&{else} $\{$\cr
163 \
+& |else_like| |stmt| & |stmt| \hfill
164 $|force|\
,E\
,\\
{in
}\
,\\
{bsp
}\
,S\
,\\
{out
}\
,|force|$
& |else x=0;|\cr
165 \
+& |else_head| \alt|stmt| |exp| & |stmt| \hfill
166 $|force|\
,E\
,\\
{bsp
}\
,|noop|\
,|cancel|\
,S\
,\\
{bsp
}$
& |else{x=0;}|\cr
167 \
+& |if_clause| |lbrace| & |if_head| |lbrace| & |if (x) {|\cr
168 \
+& |if_clause| |stmt| |else_like| |if_like| & |if_like| \hfill
169 $|force|\
,I\
,\\
{in
}\
,\\
{bsp
}\
,S\
,\\
{out
}\
,|force|\
,E\
,\.\ I$
&
170 |if
(x
) y
; else if|\cr
171 \
+& |if_clause| |stmt| |else_like| & |else_like| \hfill
172 $|force|\
,I\
,\\
{in
}\
,\\
{bsp
}\
,S\
,\\
{out
}\
,|force|\
,E$
&
174 \
+& |if_clause| |stmt| & |else_like| |stmt| & |if (x)|\cr
175 \
+& |if_head| \alt|stmt| |exp| |else_like| |if_like| & |if_like| \hfill
176 $|force|\
,I\
,\\
{bsp
}\
,|noop|\
,|cancel|\
,S\
,|force|\
,E\
,\.\ I$
&
177 |if
(x
){y
;}else if|\cr
178 \
+& |if_head| \alt|stmt| |exp| |else_like| & |else_like| \hfill
179 $|force|\
,I\
,\\
{bsp
}\
,|noop|\
,|cancel|\
,S\
,|force|\
,E$
&
181 \
+& |if_head| \alt|stmt| |exp| & |else_head| \alt|stmt| |exp| & |if (x){y;}|\cr
183 \
+& |do_like| |stmt| |else_like| |semi| & |stmt| \hfill
184 $D\
,\\
{bsp
}\
,|noop|\
,|cancel|\
,S\
,|cancel|\
,|noop|\
,\\
{bsp
}\
,ES$
%
185 & |do f(x); while (g(x));|\cr
187 \
+& |case_like| |semi| & |stmt| & |return;|\cr
188 \
+& |case_like| |colon| & |tag| & |default:|\cr
189 \
+& |case_like| |exp| & |exp| \hfill $C\.\ E$ & |return 0|\cr
190 \
+& |catch_like| \alt|cast| |exp| & |fn_decl| \hfill
191 $C$\alt $C$ $E$ \\
{in
}\
,\\
{in
} & |catch (...)|\cr
192 \
+& |tag| |tag| & |tag| \hfill $T_1\,\\{bsp}\,T_2$ & |case 0: case 1:|\cr
193 \
+& |tag| \altt|stmt| |decl| |function| & \altt|stmt| |decl| |function|
194 \hfill $|force|\
,\\
{back
}\
,T\
,\\
{bsp
}\
,S$
& |case 0: z=0;|\cr
195 \
+\dagit
& |stmt| \altt|stmt| |decl| |function| &
196 \altt|stmt| |decl| |function|
197 \hfill $S\
,$\altt$|force|\
,S$ $|big_force|\
,D$ $|big_force|\
,F$
&
199 \
+& |semi| & |stmt| \hfill \.\ $S$& empty statement\cr
200 \
+\dagit
& |lproc| \altt |if_like| |else_like| |define_like| & |lproc| &
201 \maltt
{{\bf \#include
}} {\bf\#else
} {\bf\#define
} \cr
202 \
+& |lproc| |rproc| & |insert| & {\bf\#endif} \cr
203 \
+& |lproc| \alt {|exp| [|exp|]} |function| |rproc| & |insert| \hfill
204 $I$\.\ \alt
{$E
{[\.
{\ \\
5}E
]}$
} {$F$
} &
205 \malt
{{\bf\#define
} $a$\enspace
1} {{\bf\#define
} $a$\enspace$\
{\
,b
;\
,\
}$
} \cr
206 \
+& |section_scrap| |semi| & |stmt|\hfill $MS$ |force|
207 &$\langle\,$section name$\,\rangle$;\cr
208 \
+& |section_scrap| & |exp| &$\langle\,$section name$\,\rangle$\cr
209 \
+& |insert| |any| & |any| & \.{\v\#include\v}\cr
210 \
+& |prelangle| & |binop| \hfill \.< & $<$ not in template\cr
211 \
+& |prerangle| & |binop| \hfill \.> & $>$ not in template\cr
212 \
+& |langle| |prerangle| & |cast| \hfill $L\.{\\,}P$ & $\langle\,\rangle$\cr
213 \
+& |langle| \altt|decl_head| |int_like| |exp| |prerangle| & |cast| &
214 $\langle\
&{class}\,\&C\rangle$\cr
215 \
+& |langle| \altt|decl_head| |int_like| |exp| |comma| & |langle| \hfill
216 $L$\
,\altt $D$ $I$ $E$ $C$\
,|opt|
9 & $\langle\&{class}\,\&C,$\cr
217 \
+& |template_like| |exp| |prelangle| & |template_like| |exp| |langle| &
218 \
&{template} $a\langle100\rangle$\cr
219 \
+& |template_like| \alt|exp| |raw_int| & \alt|exp| |raw_int| \hfill
220 $T$\.\ \alt$E$ $R$
& \&C\DC\&{template} |a()|\cr
221 \
+& |template_like| & |raw_int| & \&{template}$\langle\&{class}\,\&T\rangle$\cr
222 \
+& |new_like| |lpar| |exp| |rpar| & |new_like| & \&{new}(\\{nothrow})\cr
223 \
+& |new_like| |cast| & |exp| \hfill $N\.\ C$ & |new(int*)|\cr
224 \
+\dagit
& |new_like| & |new_exp| & \&{new} \&C|()|\cr
225 \
+& |new_exp| \alt|int_like| |const_like| & |new_exp| \hfill
226 $N$\.\ \alt $I$ $C$
& |new const int|\cr
227 \
+& |new_exp| |struct_like| \alt |exp| |int_like| & |new_exp| \hfill
228 $N\.\ S$\.\ \alt $E$ $I$
& \&{new} \&{struct} \&S\cr
229 \
+& |new_exp| |raw_ubin| & |new_exp| \hfill $N\.\{R\.\}$ & |new int*[2]|\cr
230 \
+& |new_exp| \alt |lpar| |exp| & |exp| \alt |lpar| |exp| \hfill
231 $E
=N$\
,\alt
{} {\.\
} & \malt |operator[](int)| {|new int(2)|} \cr
232 \
+\dagit
& |new_exp| & |exp| & |new int;|\cr
233 \
+& |ftemplate| |prelangle| & |ftemplate| |langle| & |make_pair<int,int>|\cr
234 \
+& |ftemplate| & |exp| & |make_pair(1,2)|\cr
235 \
+& |for_like| |exp| & |else_like| \hfill $F\.\ E$ & |while (1)|\cr
236 \
+& |raw_ubin| |const_like| & |raw_ubin| \hfill $RC$\.{\\\ }
237 & $*$\&{const} |x|\cr
238 \
+& |raw_ubin| & |ubinop| & $*$ |x|\cr
239 \
+& |const_like| & |int_like| & \&{const} |x|\cr
240 \
+& |raw_int| |prelangle| & |raw_int| |langle| & \&C$\langle$\cr
241 \
+& |raw_int| |colcol| & |colcol| & \&C\DC\cr
242 \
+& |raw_int| |cast| & |raw_int| & \&C$\langle\&{class}\ \&T\rangle$\cr
243 \
+& |raw_int| |lpar| & |exp| |lpar| & \&{complex}$(x,y)$\cr
244 \
+\dagit
& |raw_int| & |int_like| & \&{complex} |z|\cr
245 \
+\dagit
& |operator_like| \altt|binop| |unop| |ubinop| & |exp|
246 \hfill $O$\.\
{\altt $B$ $U$ $U$ \unskip\.\
} & |operator+|\cr
247 \
+& |operator_like| \alt|new_like| |delete_like| & |exp| \hfill
248 $O$\.\ \alt $N$ $S$
& |operator delete|\cr
249 \
+& |operator_like| |comma| & |exp| & \&{operator},\cr
250 \
+\dagit
& |operator_like| & |new_exp| & |operator char*|\cr
252 \
+& |typedef_like| \alt|int_like| |cast| \alt|comma| |semi| &
253 |typedef_like| |exp| \alt|comma| |semi|
& \&{typedef} \&{int} \&I,\cr
255 \
+& |typedef_like| |int_like| & |typedef_like| \hfill $T\.\ I$ &
256 \
&{typedef} \&{char}\cr
257 \
+\dagit
& |typedef_like| |exp| & |typedef_like| \hfill $T\.\ E^{**}$ &
258 \
&{typedef} \&I \.{@@[@@]} (|*|\&P)\cr
259 \
+& |typedef_like| |comma| & |typedef_like| \hfill $TC\.\ $ &
260 \
&{typedef} \&{int} \&x,\cr
261 \
+& |typedef_like| |semi| & |decl| & \&{typedef} \&{int} $\&x,\&y$;\cr
262 \
+& |typedef_like| |ubinop| \alt |cast| |ubinop| &
263 |typedef_like| \alt |cast| |ubinop| \hfill
264 \alt $C
=\.\
{U\.\
}C$ $U_2
=\.\
{U_1\.\
}U_2$ \unskip
&
265 \
&{typedef} |*|{}|*|(\&{CPtr})\cr
266 \
+& |delete_like| |lpar| |rpar| & |delete_like|\hfill $DL\.{\\,}R$ &
268 \
+& |delete_like| |exp| & |exp| \hfill $D\.\ E$ & |delete p| \cr
269 \
+\dagit
& |question| |exp| \alt |colon| |base| & |binop| &
270 \malt |?x
:| |?f
():| \cr
271 \
+& |begin_arg| |end_arg| & |exp| & \.{@@[}\&{char}$*$\.{@@]}\cr
272 \
+& |any_other| |end_arg| & |end_arg| & \&{char}$*$\.{@@]}\cr
279 Rule
35: The |exp| must not be immediately followed by |lpar|
, |exp|
,
282 Rule
48: The |exp| or |int_like| must not be immediately followed by |base|.
284 Rule
76: The |force| in the |stmt| line becomes \\
{bsp
} if \.
{CWEAVE
} has
285 been invoked with the \.
{-f
} option.
287 Rule
78: The |define_like| case calls |make_underlined| on the following scrap.
289 Rule
94: The |new_like| must not be immediately followed by |lpar|.
291 Rule
99: The |new_exp| must not be immediately followed by |raw_int|
,
292 |struct_like|
, or |colcol|.
294 Rule
110: The |raw_int| must not be immediately followed by |langle|.
296 Rule
111: The operator after |operator_like|
297 must not be immediately followed by a |binop|.
299 Rule
114: The |operator_like| must not be immediately followed by
302 Rule
117: The |exp| must not be immediately followed by |lpar|
, |exp|
,
305 Rule
123: The mathness of the |colon| or |base| changes to `yes'.