518 \draw [->,line width=4mm] (B) -- (C); |
519 \draw [->,line width=4mm] (B) -- (C); |
519 \draw [->,line width=4mm] (C) -- (1); |
520 \draw [->,line width=4mm] (C) -- (1); |
520 \end{tikzpicture} |
521 \end{tikzpicture} |
521 \end{center} |
522 \end{center} |
522 |
523 |
523 We have lexer and parser. |
524 We have a lexer and a parser\ldots |
524 |
525 |
525 \end{frame} |
526 \end{frame} |
526 |
527 |
527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
528 \begin{frame}[c] |
529 \begin{frame}[c] |
529 |
530 |
530 \begin{center} |
531 \begin{center} |
531 \bl{\begin{tabular}{@{}lcl@{}} |
532 \bl{\begin{tabular}{@{}lcl@{}} |
532 \textit{Stmt} & $::=$ & $\texttt{skip}$\\ |
533 \meta{Stmt} & $::=$ & $\texttt{skip}$\\ |
533 & $|$ & \textit{Id}\;\texttt{:=}\;\textit{AExp}\\ |
534 & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\ |
534 & $|$ & \texttt{if}\; \textit{BExp} \;\texttt{then}\; \textit{Block} \;\texttt{else}\; \textit{Block}\\ |
535 & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\ |
535 & $|$ & \texttt{while}\; \textit{BExp} \;\texttt{do}\; \textit{Block}\\ |
536 & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\ |
536 & $|$ & \texttt{read}\;\textit{Id}\\ |
537 & $|$ & \texttt{read}\;\textit{Id}\\ |
537 & $|$ & \texttt{write}\;\textit{Id}\\ |
538 & $|$ & \texttt{write}\;\textit{Id}\\ |
538 & $|$ & \texttt{write}\;\textit{String}\medskip\\ |
539 & $|$ & \texttt{write}\;\textit{String}\medskip\\ |
539 \textit{Stmts} & $::=$ & \textit{Stmt} \;\texttt{;}\; \textit{Stmts}\\ |
540 \meta{Stmts} & $::=$ & \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\ |
540 & $|$ & \textit{Stmt}\medskip\\ |
541 & $|$ & \meta{Stmt}\medskip\\ |
541 \textit{Block} & $::=$ & \texttt{\{}\,\textit{Stmts}\,\texttt{\}}\\ |
542 \meta{Block} & $::=$ & \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\ |
542 & $|$ & \textit{Stmt}\medskip\\ |
543 & $|$ & \meta{Stmt}\medskip\\ |
543 \textit{AExp} & $::=$ & \ldots\\ |
544 \meta{AExp} & $::=$ & \ldots\\ |
544 \textit{BExp} & $::=$ & \ldots\\ |
545 \meta{BExp} & $::=$ & \ldots\\ |
545 \end{tabular}} |
546 \end{tabular}} |
546 \end{center} |
547 \end{center} |
547 \end{frame} |
548 \end{frame} |
548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
549 |
550 |
577 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause |
577 \item the interpreter has to record the value of \bl{$x$} before assigning a value to \bl{$y$}\pause |
578 \item \bl{\text{eval}(stmt, env)} |
578 \item \bl{\text{eval}(stmt, env)} |
579 \end{itemize} |
579 \end{itemize} |
580 |
580 |
581 |
581 |
582 \end{frame}} |
582 \end{frame} |
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
584 |
584 |
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
586 \mode<presentation>{ |
586 \begin{frame}[c] |
587 \begin{frame}[c] |
587 \frametitle{An Interpreter} |
588 \frametitle{\begin{tabular}{c}Interpreter\end{tabular}} |
|
589 |
588 |
590 \begin{center} |
589 \begin{center} |
591 \bl{\begin{tabular}{@{}lcl@{}} |
590 \bl{\begin{tabular}{@{}lcl@{}} |
592 $\text{eval}(n, E)$ & $\dn$ & $n$\\ |
591 $\text{eval}(n, E)$ & $\dn$ & $n$\\ |
593 $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\ |
592 $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\ |
598 $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\ |
597 $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\ |
599 $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\ |
598 $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\ |
600 \end{tabular}} |
599 \end{tabular}} |
601 \end{center} |
600 \end{center} |
602 |
601 |
603 \end{frame}} |
602 \end{frame} |
604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
604 |
606 \mode<presentation>{ |
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
607 \begin{frame}[c] |
606 \begin{frame}[c] |
608 \frametitle{\begin{tabular}{c}Interpreter (2)\end{tabular}} |
607 \frametitle{An Interpreter (2)} |
609 |
608 |
610 \begin{center} |
609 \begin{center} |
611 \bl{\begin{tabular}{@{}lcl@{}} |
610 \bl{\begin{tabular}{@{}lcl@{}} |
612 $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\ |
611 $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\ |
613 $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\ |
612 $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\ |
622 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
621 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
623 $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
622 $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
624 \end{tabular}} |
623 \end{tabular}} |
625 \end{center} |
624 \end{center} |
626 |
625 |
627 \end{frame}} |
626 \end{frame} |
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
629 |
628 |
630 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 \begin{frame}[c] |
630 \begin{frame}[c] |
632 \frametitle{\begin{tabular}{c}Test Program\end{tabular}} |
631 \frametitle{\begin{tabular}{c}Test Program\end{tabular}} |
671 |
670 |
672 \end{frame}} |
671 \end{frame}} |
673 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
674 |
673 |
675 |
674 |
|
675 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
676 \begin{frame}[c] |
|
677 \frametitle{Coursework: MkEps} |
|
678 |
|
679 \begin{center} |
|
680 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
681 \bl{$mkeps([c_1 c_2 \ldots c_n])$} & \bl{$\dn$} & $\bl{undefined}$\\ |
|
682 \bl{$mkeps(r^*)$} & \bl{$\dn$} & $\bl{Stars\,[]}$\\ |
|
683 \bl{$mkeps(r^{\{n\}})$} & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\ |
|
684 \bl{$mkeps(r^{\{n..\}})$} & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\\ |
|
685 \bl{$mkeps(r^{\{..n\}})$} & \bl{$\dn$} & $\bl{Stars\,[]}$\\ |
|
686 \bl{$mkeps(r^{\{n..m\}})$} & \bl{$\dn$} & $\bl{Stars\,(mkeps(r))^n}$\medskip\\ |
|
687 |
|
688 \bl{$mkeps(r^+)$} & \bl{$\dn$} & \bl{$mkeps(r^{\{1..\}})$}\\ |
|
689 \bl{$mkeps(r^?)$} & \bl{$\dn$} & \bl{$mkeps(r^{\{..1\}})$}\\ |
|
690 \end{tabular} |
|
691 \end{center} |
|
692 |
|
693 \end{frame} |
|
694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
695 |
|
696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
697 \begin{frame}[c] |
|
698 \frametitle{Coursework: Inj} |
|
699 |
|
700 \begin{center} |
|
701 \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} |
|
702 \bl{$inj([c_1 c_2 \ldots c_n])\,c\,Empty$} & \bl{$\dn$} & $\bl{Chr\,c}$\\ |
|
703 \bl{$inj(r^*)\,c\;(Seq\,v\,(Stars\,vs))$} & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\ |
|
704 \bl{$inj(r^{\{n\}})\,c\;(Seq\,v\,(Stars\,vs))$} & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\ |
|
705 \bl{$inj(r^{\{n..\}})\,c\;(Seq\,v\,(Stars\,vs))$} & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\ |
|
706 \bl{$inj(r^{\{..n\}})\,c\;(Seq\,v\,(Stars\,vs))$} & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\\ |
|
707 \bl{$inj(r^{\{n..m\}})\,c\;(Seq\,v\,(Stars\,vs))$} & \bl{$\dn$} & $\bl{Stars\,(inj\,r\,c\,v::vs)}$\medskip\\ |
|
708 |
|
709 \bl{$inj(r^+)\,c\,v$} & \bl{$\dn$} & \bl{$inj(r^{\{1..\}})\,c\,v$}\\ |
|
710 \bl{$inj(r^?)\,c\,v$} & \bl{$\dn$} & \bl{$inj(r^{\{..1\}})\,c\,v$}\\ |
|
711 \end{tabular} |
|
712 \end{center} |
|
713 |
|
714 \end{frame} |
|
715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
716 |
|
717 |
|
718 |
676 \end{document} |
719 \end{document} |
677 |
720 |
678 %%% Local Variables: |
721 %%% Local Variables: |
679 %%% mode: latex |
722 %%% mode: latex |
680 %%% TeX-master: t |
723 %%% TeX-master: t |