--- a/hw08.tex Fri Nov 23 21:21:27 2012 +0000
+++ b/hw08.tex Sat Nov 24 07:08:51 2012 +0000
@@ -16,48 +16,30 @@
\item Suppose the following grammar for the WHILE-language:
\begin{center}
-\begin{tabular}{l}
-$S \rightarrow N\cdot P$\\
-$P \rightarrow V\cdot N$\\
-$N \rightarrow N\cdot N$\\
-$N \rightarrow A \cdot N$\\
-$N \rightarrow \texttt{student} \;|\; \texttt{trainer} \;|\; \texttt{team} \;|\; \texttt{trains}$\\
-$V \rightarrow \texttt{trains} \;|\; \texttt{team}$\\
-$A \rightarrow \texttt{The} \;|\; \texttt{the}$\\
+\begin{tabular}{lcl}
+$Stmt$ & $\rightarrow$ & $\text{skip}$\\
+ & $|$ & $Id := AExp$\\
+ & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\
+ & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\medskip\\
+$Stmt$ & $\rightarrow$ & $Stmt \;\text{;}\; Stmts$\\
+ & $|$ & $Stmt$\medskip\\
+$Block$ & $\rightarrow$ & $\{ Stmts \}$\\
+ & $|$ & $Stmt$\medskip\\
+$AExp$ & $\rightarrow$ & $AExp + AExp$\\
+ & $|$ & $AExp * AExp$\\
+ & $|$ & $( AExp )$\\
+ & $|$ & $Num$\\
+ & $|$ & $Id$\medskip\\
+$BExp$ & $\rightarrow$ & $AExp = AExp$\\
+ & $|$ & $AExp \not= AExp$\\
+ & $|$ & $\text{false}$\\
+ & $|$ & $\text{true}$\\
+
\end{tabular}
\end{center}
-
-\item Consider the following grammar
-
-\begin{center}
-\begin{tabular}{l}
-$S \rightarrow N\cdot P$\\
-$P \rightarrow V\cdot N$\\
-$N \rightarrow N\cdot N$\\
-$N \rightarrow A \cdot N$\\
-$N \rightarrow \texttt{student} \;|\; \texttt{trainer} \;|\; \texttt{team} \;|\; \texttt{trains}$\\
-$V \rightarrow \texttt{trains} \;|\; \texttt{team}$\\
-$A \rightarrow \texttt{The} \;|\; \texttt{the}$\\
-\end{tabular}
-\end{center}
+Transform this grammar into Chomsky normalform.
-where $S$ is the start symbol and $S$, $P$, $N$, $V$ and $A$ are non-terminals.
-Using the CYK-algorithm, check whether or not the following string can be parsed
-by the grammar:
-
-\begin{center}
-\texttt{The trainer trains the student team}
-\end{center}
-
-\item {\bf (Optional)} The task is to match strings where the letters are in alphabetical order---for example,
-\texttt{abcfjz} would pass, but \texttt{acb} would not. Whitespace should be ignored---for example
-\texttt{ab c d} should pass. The point is to try to get the regular expression as short as possible!
-See:
-
-\begin{center}
-\url{http://callumacrae.github.com/regex-tuesday/challenge11.html}
-\end{center}
\end{enumerate}
\end{document}