# HG changeset patch # User Christian Urban # Date 1415877928 0 # Node ID 23045b2b0b7b3c56d19519af698b76adc1ea874e # Parent 1daaf6f6e45b9b76f2aa490cee08efa1487c9e1c updated diff -r 1daaf6f6e45b -r 23045b2b0b7b hws/hw07.pdf Binary file hws/hw07.pdf has changed diff -r 1daaf6f6e45b -r 23045b2b0b7b hws/hw07.tex --- a/hws/hw07.tex Mon Nov 10 09:18:36 2014 +0000 +++ b/hws/hw07.tex Thu Nov 13 11:25:28 2014 +0000 @@ -1,6 +1,5 @@ \documentclass{article} \usepackage{../style} -\usepackage{../graphics} \begin{document} @@ -57,6 +56,35 @@ \noindent into Chomsky normal form. +\item Consider the following grammar $G$ + +\begin{center} +\begin{tabular}{l} +$S \rightarrow \texttt{if0} \cdot E \cdot \texttt{then} \cdot S$\\ +$S \rightarrow \texttt{print} \cdot S$\\ +$S \rightarrow \texttt{begin} \cdot B\cdot \texttt{end}$\\ +$B \rightarrow S\cdot \texttt{;}$\\ +$B \rightarrow S\cdot \texttt{;} \cdot B$\\ +$E \rightarrow num$ +\end{tabular} +\end{center} + +where $S$ is the start symbol and $S$, $E$ and $B$ are +non-terminals. + +Check each rule below and decide whether, when added to $G$, +the combined grammar is ambiguous. If yes, give a string that +has more than one parse tree. + +\begin{center} +\begin{tabular}{rl} +(i) & $S \rightarrow \texttt{if0} \cdot E\cdot \texttt{then} \cdot S\cdot \texttt{else} \cdot S$\\ +(ii) & $B \rightarrow B \cdot B$\\ +(iii) & $E \rightarrow ( \cdot E \cdot )$\\ +(iv) & $E \rightarrow E \cdot + \cdot E$ +\end{tabular} +\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