9 % beamer stuff   | 
     9 % beamer stuff   | 
    10 \renewcommand{\slidecaption}{CFL 07, King's College London} | 
    10 \renewcommand{\slidecaption}{CFL 07, King's College London} | 
    11 \newcommand{\bl}[1]{\textcolor{blue}{#1}}        | 
    11 \newcommand{\bl}[1]{\textcolor{blue}{#1}}        | 
    12   | 
    12   | 
    13 \begin{document} | 
    13 \begin{document} | 
         | 
    14   | 
         | 
    15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
         | 
    16 \begin{frame}[t] | 
         | 
    17 \frametitle{% | 
         | 
    18   \begin{tabular}{@ {}c@ {}} | 
         | 
    19   \\[-3mm]  | 
         | 
    20   \LARGE Compilers and \\[-2mm]   | 
         | 
    21   \LARGE Formal Languages\\[3mm]   | 
         | 
    22   \end{tabular}} | 
         | 
    23   | 
         | 
    24   \normalsize  | 
         | 
    25   \begin{center} | 
         | 
    26   \begin{tabular}{ll} | 
         | 
    27     Email:  & christian.urban at kcl.ac.uk\\  | 
         | 
    28     %Office Hours: & Thursdays 12 -- 14\\  | 
         | 
    29     %Location: & N7.07 (North Wing, Bush House)\\  | 
         | 
    30     Slides \& Progs: & KEATS (also homework is there)\\    | 
         | 
    31   \end{tabular} | 
         | 
    32   \end{center} | 
         | 
    33   | 
         | 
    34   \begin{center} | 
         | 
    35     \begin{tikzpicture} | 
         | 
    36       \node[drop shadow,fill=white,inner sep=0pt]   | 
         | 
    37       {\footnotesize\rowcolors{1}{capri!10}{white} | 
         | 
    38         \begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline | 
         | 
    39           1 Introduction, Languages          & 6 While-Language \\  | 
         | 
    40           2 Regular Expressions, Derivatives & 7 Compilation, JVM \\  | 
         | 
    41           3 Automata, Regular Languages      & \cellcolor{blue!50} 8 Compiling Functional Languages \\ | 
         | 
    42           4 Lexing, Tokenising               & 9 Optimisations \\  | 
         | 
    43           5 Grammars, Parsing                & 10 LLVM \\ \hline  | 
         | 
    44         \end{tabular}% | 
         | 
    45       };  | 
         | 
    46     \end{tikzpicture} | 
         | 
    47   \end{center} | 
         | 
    48 \end{frame} | 
         | 
    49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
         | 
    50   | 
    14   | 
    51   | 
    15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
    52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
    16 \begin{frame}[t] | 
    53 \begin{frame}[t] | 
    17 \frametitle{% | 
    54 \frametitle{% | 
    18   \begin{tabular}{@ {}c@ {}} | 
    55   \begin{tabular}{@ {}c@ {}} | 
  1035   | 
  1072   | 
  1036 \end{frame} | 
  1073 \end{frame} | 
  1037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   | 
  1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   | 
  1038   | 
  1075   | 
  1039   | 
  1076   | 
         | 
  1077   | 
         | 
  1078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
         | 
  1079 \begin{frame}[t, fragile] | 
         | 
  1080 \frametitle{Function Definitions} | 
         | 
  1081   | 
         | 
  1082 \footnotesize  | 
         | 
  1083 \begin{lstlisting}[language=JVMIS,  | 
         | 
  1084                    xleftmargin=2mm,   | 
         | 
  1085                    numbers=none]  | 
         | 
  1086 .method public static write(I)V   | 
         | 
  1087    .limit locals 1  | 
         | 
  1088    .limit stack 2  | 
         | 
  1089    getstatic java/lang/System/out Ljava/io/PrintStream;   | 
         | 
  1090    iload 0   | 
         | 
  1091    invokevirtual java/io/PrintStream/println(I)V   | 
         | 
  1092    return   | 
         | 
  1093 .end method  | 
         | 
  1094 \end{lstlisting}\bigskip | 
         | 
  1095   | 
         | 
  1096 \small We will need methods for definitions like\footnotesize\medskip  | 
         | 
  1097   | 
         | 
  1098 \begin{lstlisting}[language=JVMIS,  | 
         | 
  1099                    xleftmargin=2mm,   | 
         | 
  1100                    numbers=none]  | 
         | 
  1101 def fname (x1, ... , xn) = ...                     | 
         | 
  1102                      | 
         | 
  1103 .method public static fname (I...I)I  | 
         | 
  1104   .limit locals ??  | 
         | 
  1105   .limit stack ??   | 
         | 
  1106   ??  | 
         | 
  1107 .end method  | 
         | 
  1108 \end{lstlisting} | 
         | 
  1109   | 
         | 
  1110 \end{frame} | 
         | 
  1111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     | 
         | 
  1112   | 
         | 
  1113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
         | 
  1114 \begin{frame}[c, fragile] | 
         | 
  1115 \frametitle{Stack Estimation} | 
         | 
  1116 \small  | 
         | 
  1117 \mbox{}\\[-15mm] | 
         | 
  1118   | 
         | 
  1119 \bl{\begin{center} | 
         | 
  1120 \begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}} | 
         | 
  1121 $\textit{estimate}(n)$ & $\dn$ & $1$\\ | 
         | 
  1122 $\textit{estimate}(x)$ & $\dn$ & $1$\\ | 
         | 
  1123 $\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ & | 
         | 
  1124 $\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ | 
         | 
  1125 $\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ &  | 
         | 
  1126 $\textit{estimate}(b) +$\\  | 
         | 
  1127 & & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ | 
         | 
  1128 $\textit{estimate}(\pcode{write}(e))$ & $\dn$ &  | 
         | 
  1129 $\textit{estimate}(e) + 1$\\ | 
         | 
  1130 $\textit{estimate}(e_1 ; e_2)$ & $\dn$ &  | 
         | 
  1131 $max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ | 
         | 
  1132 $\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ &  | 
         | 
  1133 $\sum_{i = 1..n}\;estimate(e_i)$\medskip\\ | 
         | 
  1134 $\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ & | 
         | 
  1135 $\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ | 
         | 
  1136 \end{tabular} | 
         | 
  1137 \end{center}} | 
         | 
  1138   | 
         | 
  1139 \end{frame} | 
         | 
  1140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   | 
         | 
  1141   | 
         | 
  1142   | 
  1040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
  1143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  | 
  1041 \mode<presentation>{ | 
  1144 \mode<presentation>{ | 
  1042 \begin{frame}[c] | 
  1145 \begin{frame}[c] | 
  1043 \frametitle{Backend} | 
  1146 \frametitle{Backend} | 
  1044   | 
  1147   |