slides08.tex
changeset 69 cc3f7908b942
parent 67 1419b60f6b0e
child 70 e6868bd2942b
equal deleted inserted replaced
68:a09ecb1e7384 69:cc3f7908b942
   568 \end{center}
   568 \end{center}
   569 
   569 
   570 \end{frame}}
   570 \end{frame}}
   571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   572 
   572 
   573 
       
   574 
       
   575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   573 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   576 \mode<presentation>{
   574 \mode<presentation>{
   577 \begin{frame}[c]
   575 \begin{frame}[c]
   578 \frametitle{\begin{tabular}{c}What about Left-Recursion?\end{tabular}}
   576 \frametitle{\begin{tabular}{c}What about Left-Recursion?\end{tabular}}
   579 
   577 
   580 \begin{itemize}
   578 \begin{itemize}
   581 \item we record when we recursively called a parser\bigskip
   579 \item we record when we recursively called a parser\bigskip
   582 \item whenever the is a recursion, the parser must have consumed something --- so
   580 \item whenever the is a recursion, the parser must have consumed something --- so
   583 I can decrease the input string/list of token by one (at the end)
   581 I can decrease the input string/list of token by one (at the end)
   584 \end{itemize}
   582 \end{itemize}
       
   583 \end{frame}}
       
   584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   585 
       
   586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   587 \mode<presentation>{
       
   588 \begin{frame}[c]
       
   589 \frametitle{\begin{tabular}{c}While-Language\end{tabular}}
       
   590 
       
   591 
       
   592 \begin{center}
       
   593 \bl{\begin{tabular}{lcl}
       
   594 $Stmt$ & $\rightarrow$ &  $\text{skip}$\\
       
   595               & $|$ & $Id := AExp$\\
       
   596               & $|$ & $\text{if}\; B\!Exp \;\text{then}\; Block \;\text{else}\; Block$\\
       
   597               & $|$ & $\text{while}\; B\!Exp \;\text{do}\; Block$\bigskip\\
       
   598 $Stmt$ & $\rightarrow$ &  $Stmt \;\text{;}\; Stmts$\\
       
   599               & $|$ & $Stmt$\bigskip\\
       
   600 $Block$ & $\rightarrow$ &  $\{ Stmts \}$\\
       
   601                 & $|$ & $Stmt$\\
       
   602 \end{tabular}}
       
   603 \end{center}
       
   604 
       
   605 
       
   606 \end{frame}}
       
   607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   608 
       
   609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   610 \mode<presentation>{
       
   611 \begin{frame}[c]
       
   612 \frametitle{\begin{tabular}{c}An Interpreter\end{tabular}}
       
   613 
       
   614 \begin{center}
       
   615 \bl{\begin{tabular}{l}
       
   616 $\{$\\
       
   617 \;\;$x := 5 \text{;}$\\
       
   618 \;\;$y := x * 3\text{;}$\\
       
   619 \;\;$y := x * 4\text{;}$\\
       
   620 \;\;$x := u * 3$\\
       
   621 $\}$
       
   622 \end{tabular}}
       
   623 \end{center}
       
   624 
       
   625 \begin{itemize}
       
   626 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause
       
   627 \item \bl{\text{eval}(stmt, env)}
       
   628 \end{itemize}
       
   629 
       
   630 
   585 \end{frame}}
   631 \end{frame}}
   586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   587 
   633 
   588 \end{document}
   634 \end{document}
   589 
   635