(1-ⅰ) | { a = a ; } など |
(1-ⅱ) | a = a ; など |
(1-ⅲ) | ✘ |
(1-ⅳ) | ✘ |
(2) |
\(\begin{array}{lcl}
E & \rightarrow & \textbf{a}\ E' & \cdots ⑦ \\
& | & \texttt{(}\ E\ \texttt{)}\ E' & \cdots ⑧ \\
\\
E' & \rightarrow & \texttt{(}\ E\ \texttt{)}\ E' & \cdots ⑨ \\
& | & \texttt{[}\ E\ \texttt{]}\ E' & \cdots ⑩\\
& | & \varepsilon & \cdots ⑪ \\
\\
\end{array}\)
|
(3) | \(\left\{\ \textbf{a}, \textbf{if}, \textbf{while}, “\texttt{\{}” \ \right\}\) |
(4) | \(\left\{\ “\texttt{\}}”\ \right\}\ \) |
(5) | \(\left\{\ “\texttt{;}”, “\texttt{)}”, “\texttt{]}”\ \right\}\ \) |
(6) |
|
a |
= |
; |
if |
( |
) |
else |
while |
{ |
} |
[ |
] |
$ |
\(S \rightarrow\) |
① |
✘ |
✘ |
② |
✘ |
✘ |
✘ |
③ |
④ |
✘ |
✘ |
✘ |
✘ |
\(T \rightarrow\) |
⑤ |
✘ |
✘ |
⑤ |
✘ |
✘ |
✘ |
⑤ |
⑤ |
⑥ |
✘ |
✘ |
✘ |
|
(7) |
|
a |
= |
; |
if |
( |
) |
else |
while |
{ |
} |
[ |
] |
$ |
\(E \rightarrow\) |
⑦ |
✘ |
✘ |
✘ |
⑧ |
✘ |
✘ |
✘ |
✘ |
✘ |
✘ |
✘ |
✘ |
\(E' \rightarrow\) |
✘ |
✘ |
⑪ |
✘ |
⑨ |
⑪ |
✘ |
✘ |
✘ |
✘ |
⑩ |
⑪ |
✘ |
|
(8) |
void E(void) {
switch(token) {
case A: eat(A); E1(); break;
case '(': eat('('); E(); eat(')'); E1(); break;
default: reportError();
}
}
void E1(void) {
switch(token) {
case '(': eat('('); E(); eat(')'); E1(); break;
case '[': eat('['); E(); eat(']'); E1(); break;
case ';': case ')': case ']': break;
default: reportError();
}
}
|