hw/hw08.tex
changeset 93 4794759139ea
parent 77 49c0beef79a1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hw/hw08.tex	Sat Jun 15 09:23:18 2013 -0400
@@ -0,0 +1,52 @@
+\documentclass{article}
+\usepackage{charter}
+\usepackage{hyperref}
+\usepackage{amssymb}
+\usepackage{amsmath}
+\usepackage{tikz}
+\usetikzlibrary{automata}
+
+\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
+
+\begin{document}
+
+\section*{Homework 8}
+
+\begin{enumerate}
+\item Suppose the following grammar for the WHILE-language:
+
+\begin{center}
+\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\\
+$Stmts$ & $\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}
+
+Transform this grammar into Chomsky normalform.
+
+\item Write a program in the WHILE-language that calculates the factorial function.
+
+\end{enumerate}
+
+\end{document}
+
+%%% Local Variables: 
+%%% mode: latex
+%%% TeX-master: t
+%%% End: