updated
authorChristian Urban <urbanc@in.tum.de>
Thu, 14 Nov 2019 01:21:02 +0000
changeset 686 05cfce0fdef7
parent 685 75d9f9e5906f
child 687 8865f4f2be59
updated
coursework/cw03.pdf
coursework/cw03.tex
handouts/ho05.tex
progs/comb1.scala
progs/comb1a.scala
progs/comb2.scala
progs/detokenise.scala
slides/slides06.pdf
slides/slides06.tex
slides/slides07.pdf
slides/slides07.tex
Binary file coursework/cw03.pdf has changed
--- a/coursework/cw03.tex	Thu Nov 07 00:07:16 2019 +0000
+++ b/coursework/cw03.tex	Thu Nov 14 01:21:02 2019 +0000
@@ -34,6 +34,7 @@
   previous coursework, that is \pcode{+}, \pcode{-}, \pcode{*},
   \pcode{/} and \pcode{\%})
 \item boolean expressions (with the operations \pcode{==}, \pcode{<}, \pcode{>},
+  \code{>=}, \code{<=}, 
   \code{!=}, \pcode{&&}, \pcode{||}, \pcode{true} and \pcode{false})
 \item single statements (that is \pcode{skip}, assignments, \pcode{if}s,
   \pcode{while}-loops, \pcode{read} and \pcode{write})
--- a/handouts/ho05.tex	Thu Nov 07 00:07:16 2019 +0000
+++ b/handouts/ho05.tex	Thu Nov 14 01:21:02 2019 +0000
@@ -71,7 +71,12 @@
 
 \noindent
 from natural languages were the meaning of \emph{flies} depends on the
-surrounding \emph{context} are avoided as much as possible.
+surrounding \emph{context} are avoided as much as possible. Here is
+an interesting video about C++ being not a context-free language
+
+\begin{center}
+\url{https://www.youtube.com/watch?v=OzK8pUu4UfM}
+\end{center}  
 
 Context-free languages are usually specified by grammars. For example
 a grammar for well-parenthesised expressions can be given as follows:
--- a/progs/comb1.scala	Thu Nov 07 00:07:16 2019 +0000
+++ b/progs/comb1.scala	Thu Nov 14 01:21:02 2019 +0000
@@ -60,18 +60,18 @@
 implicit def char2parser(c: Char) = CharParser(c)
 
 implicit def ParserOps[I, T](p: Parser[I, T])(implicit ev: I => Seq[_]) = new {
-  def || (q : => Parser[I, T]) = new AltParser[I, T](p, q)
+  def ||(q : => Parser[I, T]) = new AltParser[I, T](p, q)
   def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f)
   def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
 }
 
 implicit def StringOps(s: String) = new {
-  def || (q : => Parser[String, String]) = new AltParser[String, String](s, q)
-  def || (r: String) = new AltParser[String, String](s, r)
+  def ||(q : => Parser[String, String]) = new AltParser[String, String](s, q)
+  def ||(r: String) = new AltParser[String, String](s, r)
   def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f)
-  def ~[S] (q : => Parser[String, S]) = 
+  def ~[S](q : => Parser[String, S]) = 
     new SeqParser[String, String, S](s, q)
-  def ~ (r: String) = 
+  def ~(r: String) = 
     new SeqParser[String, String, String](s, r)
 }
 
@@ -131,15 +131,6 @@
 lazy val F: Parser[String, Int] = 
   ("(" ~ E ~ ")") ==> { case ((x, y), z) => y } || NumParserInt
 
-/* same parser but producing a string
-lazy val E: Parser[String, String] = 
-  (T ~ "+" ~ E) ==> { case ((x, y), z) => "(" + x + ")+(" + z + ")"} || T 
-lazy val T: Parser[String, String] = 
-  (F ~ "*" ~ T) ==> { case ((x, y), z) => "(" + x + ")*("+ z + ")"} || F
-lazy val F: Parser[String, String] = 
-  ("(" ~ E ~ ")") ==> { case ((x, y), z) => y } || NumParser
-*/
-
 println(E.parse_all("1+3+4"))
 println(E.parse("1+3+4"))
 println(E.parse_all("4*2+3"))
@@ -150,7 +141,14 @@
 println(E.parse_all("(1+2)+3"))
 println(E.parse_all("1+2+3"))  
 
-
+/* same parser but producing a string
+lazy val E: Parser[String, String] = 
+  (T ~ "+" ~ E) ==> { case ((x, y), z) => "(" + x + ")+(" + z + ")"} || T 
+lazy val T: Parser[String, String] = 
+  (F ~ "*" ~ T) ==> { case ((x, y), z) => "(" + x + ")*("+ z + ")"} || F
+lazy val F: Parser[String, String] = 
+  ("(" ~ E ~ ")") ==> { case ((x, y), z) => y } || NumParser
+*/
 
 // no left-recursion allowed, otherwise will loop
 lazy val EL: Parser[String, Int] = 
@@ -166,7 +164,7 @@
 
 // ambiguous
 lazy val S : Parser[String, String] =
-  ("1" ~ S ~ S) ==> { case ((x, y), z) => x + y + z } || ""
+  ("1" ~ S ~ S ~ S) ==> { case (((x, y), z), v) => x + y + z } || ""
 
 S.parse("1" * 10)
 
@@ -199,14 +197,14 @@
 One.parse("111")
 
 (One ~ One).parse("111")
-(One ~ One ~ One).parse("111")
+(One ~ One ~ One).parse("1111")
 (One ~ One ~ One ~ One).parse("1111")
 
 (One || Two).parse("111")
 
 
 // a problem with the arithmetic expression parser -> gets 
-// slow with deep nestedness
+// slow with deeply nested parentheses
 E.parse("1")
 E.parse("(1)")
 E.parse("((1))")
@@ -214,3 +212,15 @@
 E.parse("((((1))))")
 E.parse("((((((1))))))")
 E.parse("(((((((1)))))))")
+
+
+
+
+/*
+
+starting symbols
+tokenise/detokenise
+:paste
+pairs in sequences
+
+*/
\ No newline at end of file
--- a/progs/comb1a.scala	Thu Nov 07 00:07:16 2019 +0000
+++ b/progs/comb1a.scala	Thu Nov 14 01:21:02 2019 +0000
@@ -66,18 +66,18 @@
 implicit def char2parser(c: Char) = CharParser(c)
 
 implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new {
-  def || (q : => Parser[I, T]) = new AltParser[I, T](p, q)
+  def ||(q : => Parser[I, T]) = new AltParser[I, T](p, q)
   def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f)
   def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
 }
 
 implicit def StringOps(s: String) = new {
-  def || (q : => Parser[String, String]) = new AltParser[String, String](s, q)
-  def || (r: String) = new AltParser[String, String](s, r)
+  def ||(q : => Parser[String, String]) = new AltParser[String, String](s, q)
+  def ||(r: String) = new AltParser[String, String](s, r)
   def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f)
-  def ~[S] (q : => Parser[String, S]) = 
+  def ~[S](q : => Parser[String, S]) = 
     new SeqParser[String, String, S](s, q)
-  def ~ (r: String) = 
+  def ~(r: String) = 
     new SeqParser[String, String, String](s, r)
 }
 
@@ -106,20 +106,20 @@
 // Arithmetic Expressions (Terms and Factors)
 
 lazy val E: Parser[String, Int] = 
-  (T ~ "+" ~ E) ==> { case x ~ y ~ z => x + z } ||
-  (T ~ "-" ~ E) ==> { case x ~ y ~ z => x - z } || T 
+  (T ~ "+" ~ E) ==> { case x ~ _ ~ z => x + z } ||
+  (T ~ "-" ~ E) ==> { case x ~ _ ~ z => x - z } || T 
 lazy val T: Parser[String, Int] = 
-  (F ~ "*" ~ T) ==> { case x ~ y ~ z => x * z } || F
+  (F ~ "*" ~ T) ==> { case x ~ _ ~ z => x * z } || F
 lazy val F: Parser[String, Int] = 
-  ("(" ~ E ~ ")") ==> { case x ~ y ~ z => y } || NumParserInt
+  ("(" ~ E ~ ")") ==> { case _ ~ y ~ _ => y } || NumParserInt
 
 /* same parser but producing a string
 lazy val E: Parser[String, String] = 
-  (T ~ "+" ~ E) ==> { case ((x, y), z) => "(" + x + ")+(" + z + ")"} || T 
+  (T ~ "+" ~ E) ==> { case x ~ y ~ z => "(" + x + ")+(" + z + ")"} || T 
 lazy val T: Parser[String, String] = 
-  (F ~ "*" ~ T) ==> { case ((x, y), z) => "(" + x + ")*("+ z + ")"} || F
+  (F ~ "*" ~ T) ==> { case x ~ y ~ z => "(" + x + ")*("+ z + ")"} || F
 lazy val F: Parser[String, String] = 
-  ("(" ~ E ~ ")") ==> { case ((x, y), z) => y } || NumParser
+  ("(" ~ E ~ ")") ==> { case x ~ y ~ z => y } || NumParser
 */
 
 println(E.parse_all("1+3+4"))
@@ -191,7 +191,7 @@
 
 
 // a problem with the arithmetic expression parser -> gets 
-// slow with deep nestedness
+// slow with deeply nested parentheses
 println("Runtime problem")
 E.parse("1")
 E.parse("(1)")
--- a/progs/comb2.scala	Thu Nov 07 00:07:16 2019 +0000
+++ b/progs/comb2.scala	Thu Nov 14 01:21:02 2019 +0000
@@ -54,18 +54,18 @@
 implicit def string2parser(s : String) = StringParser(s)
 
 implicit def ParserOps[I : IsSeq, T](p: Parser[I, T]) = new {
-  def || (q : => Parser[I, T]) = new AltParser[I, T](p, q)
+  def ||(q : => Parser[I, T]) = new AltParser[I, T](p, q)
   def ==>[S] (f: => T => S) = new FunParser[I, T, S](p, f)
-  def ~[S] (q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
+  def ~[S](q : => Parser[I, S]) = new SeqParser[I, T, S](p, q)
 }
 
 implicit def StringOps(s: String) = new {
-  def || (q : => Parser[String, String]) = new AltParser[String, String](s, q)
-  def || (r: String) = new AltParser[String, String](s, r)
+  def ||(q : => Parser[String, String]) = new AltParser[String, String](s, q)
+  def ||(r: String) = new AltParser[String, String](s, r)
   def ==>[S] (f: => String => S) = new FunParser[String, String, S](s, f)
   def ~[S](q : => Parser[String, S]) = 
     new SeqParser[String, String, S](s, q)
-  def ~ (r: String) = 
+  def ~(r: String) = 
     new SeqParser[String, String, String](s, r)
 }
 
@@ -102,6 +102,7 @@
   }
 }
 
+// arithmetic expressions
 lazy val AExp: Parser[String, AExp] = 
   (Te ~ "+" ~ AExp) ==> { case x ~ _ ~ z => Aop("+", x, z): AExp } ||
   (Te ~ "-" ~ AExp) ==> { case x ~ _ ~ z => Aop("-", x, z): AExp } || Te 
@@ -140,7 +141,7 @@
 
 // blocks (enclosed in curly braces)
 lazy val Block: Parser[String, Block] =
-  (("{" ~ Stmts ~ "}") ==> { case x ~ y ~ z => y} || 
+  (("{" ~ Stmts ~ "}") ==> { case _ ~ y ~ _ => y } || 
    (Stmt ==> (s => List(s))))
 
 
--- a/progs/detokenise.scala	Thu Nov 07 00:07:16 2019 +0000
+++ b/progs/detokenise.scala	Thu Nov 14 01:21:02 2019 +0000
@@ -32,8 +32,8 @@
 def main(args: Array[String]) = {
   val fname = args(0)
   val tks = deserialise[List[Token]](fname).getOrElse(Nil)
-  println(s"Reading back from ${fname}:\n${tks.mkString("\n")}")  
+  println(s"Reading back from ${fname}:\n${tks.mkString(", ")}")  
 }
 
 
-}
\ No newline at end of file
+}
Binary file slides/slides06.pdf has changed
--- a/slides/slides06.tex	Thu Nov 07 00:07:16 2019 +0000
+++ b/slides/slides06.tex	Thu Nov 14 01:21:02 2019 +0000
@@ -146,7 +146,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
 
-Alternative parser (code \bl{$p\;||\;q$})\bigskip
+Alternative parser (code \bl{$p\;|\;q$})\bigskip
 
 \begin{itemize}
 \item apply \bl{$p$} and also \bl{$q$}; then combine 
@@ -218,7 +218,7 @@
 \end{center}\pause
 
 \item {\bf Alternative}: if \bl{$p$} returns results of type \bl{$T$} then  \bl{$q$} \alert{must} also have results of type \bl{$T$},
-and \bl{$p \;||\; q$} returns results of type
+and \bl{$p \;|\; q$} returns results of type
 
 \begin{center}
 \bl{$T$}
@@ -700,6 +700,8 @@
 \item suite of compiler tools
 \item SSA-based intermediate language
 \item no need to allocate registers
+\item source languages: C, C++, Rust, Go, Swift
+\item target CPUs: x86, ARM, PowerPC, \ldots
 \end{itemize}  
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Binary file slides/slides07.pdf has changed
--- a/slides/slides07.tex	Thu Nov 07 00:07:16 2019 +0000
+++ b/slides/slides07.tex	Thu Nov 14 01:21:02 2019 +0000
@@ -1,3 +1,4 @@
+% !TEX program = xelatex
 \documentclass[dvipsnames,14pt,t]{beamer}
 \usepackage{../slides}
 \usepackage{../langs}
@@ -23,9 +24,10 @@
   \normalsize
   \begin{center}
   \begin{tabular}{ll}
-  Email:  & christian.urban at kcl.ac.uk\\
-  Office: & N\liningnums{7.07} (North Wing, Bush House)\\
-  Slides: & KEATS (also homework is there)\\
+    Email:  & christian.urban at kcl.ac.uk\\
+    Office Hours: & Thursdays 12 -- 14\\
+    Location: & N7.07 (North Wing, Bush House)\\
+    Slides \& Progs: & KEATS (also homework is there)\\  
   \end{tabular}
   \end{center}
 
@@ -53,6 +55,25 @@
  
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[c]
+\frametitle{CW3}
+
+Atomic parsers for tokens
+
+\begin{center}
+\bl{$\texttt{T\_Num(123)}::rest \;\Rightarrow\; \{(\texttt{T\_Num(123)}, rest)\}$} 
+\end{center}\bigskip
+
+\begin{itemize}
+\item you consume one or more token from the\\ 
+  input (stream)
+\item \bl{\texttt{T\_NUM(1), T\_OP(+), T\_NUM(2)}}
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
 \begin{textblock}{10}(0.5,0.5)
   \LARGE
   \fontspec{Hoefler Text Black}
@@ -196,42 +217,42 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%\begin{frame}[t]
+%\frametitle{Interpreted Code}
+%
+%\begin{center}
+%\begin{tikzpicture}
+%\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
+%\addplot+[smooth] file {interpreted.data};
+%\end{axis}
+%\end{tikzpicture}
+%\end{center}
+%
+%\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%\begin{frame}[c]
+%\frametitle{Java Virtual Machine}
+%
+%\begin{itemize}
+%\item introduced in 1995
+%\item is a stack-based VM (like Postscript, CLR of .Net)
+%\item contains a JIT compiler
+%\item many languages take advantage of JVM's infrastructure (JRE)
+%\item is garbage collected $\Rightarrow$ no buffer overflows
+%\item some languages compiled to the JVM: Scala, Clojure\ldots
+%\end{itemize}
+%
+%\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t]
-\frametitle{Interpreted Code}
-
-\begin{center}
-\begin{tikzpicture}
-\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
-\addplot+[smooth] file {interpreted.data};
-\end{axis}
-\end{tikzpicture}
-\end{center}
-
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Java Virtual Machine}
-
-\begin{itemize}
-\item introduced in 1995
-\item is a stack-based VM (like Postscript, CLR of .Net)
-\item contains a JIT compiler
-\item many languages take advantage of JVM's infrastructure (JRE)
-\item is garbage collected $\Rightarrow$ no buffer overflows
-\item some languages compiled to the JVM: Scala, Clojure\ldots
-\end{itemize}
-
-\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \begin{frame}[t,fragile]
 \frametitle{Compiling AExps}
 
-For example \liningnums{\bl{$1 + ((2 * 3) + (4 - 3))$}}:\medskip
+For example \textbf{\bl{1 + ((2 * 3) + (4 - 3))}}:\medskip
   
 \begin{columns}[T]
 \begin{column}{.3\textwidth}
@@ -269,7 +290,7 @@
 \begin{frame}[t,fragile]
 \frametitle{Compiling AExps}
 
-\liningnums{\textbf{\Large\bl{1 + 2 + 3}}}
+\liningnums{\textbf{\Large\bl{(1 + 2) + 3}}}
 
 \begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm]  
 ldc 1
@@ -791,25 +812,39 @@
 \end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
-\frametitle{\begin{tabular}{c}Next Compiler Phases\end{tabular}}
+\frametitle{Next Compiler Phases}
 
 \begin{itemize}
 \item assembly $\Rightarrow$ byte code (class file)
 \item labels $\Rightarrow$ absolute or relative jumps\bigskip\bigskip
 \item \texttt{javap} is a disassembler for class files
+\item jasmin and krakatau are assemblers for jvm code
 \end{itemize}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[t]
-\frametitle{\begin{tabular}{c}Compiled Code\end{tabular}}
+\frametitle{Recall: Interpreted Code}
+
+\begin{center}
+\begin{tikzpicture}
+\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small]
+\addplot+[smooth] file {interpreted.data};
+\end{axis}
+\end{tikzpicture}
+\end{center}
+
+Loop program
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[t]
+\frametitle{Compiled Code}
 
 \begin{center}
 \begin{tikzpicture}
@@ -819,15 +854,12 @@
 \end{tikzpicture}
 \end{center}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
-
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[t]
-\frametitle{\begin{tabular}{c}Compiler vs.~Interpreter\end{tabular}}
+\frametitle{Compiler vs.~Interpreter}
 
 \begin{center}
 \begin{tikzpicture}
@@ -842,10 +874,122 @@
 \end{tikzpicture}
 \end{center}
 
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+  \frametitle{A ``Compiler'' for BF*** to C}
+  
+  \begin{center}
+  \begin{tabular}{lcl}
+  \bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\
+  \bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\
+  \bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\
+  \bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\
+  \bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\
+  \bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\
+  \bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\
+  \bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\
+                  & $\Rightarrow$ & ignore everything else\\
+  \end{tabular}  
+  \end{center}\bigskip  
+  
+  \texttt{char field[30000]\\ char *ptr = \&field[15000]}
+  
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+    
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+\frametitle{BF***}
+
+we need some big array, say \texttt{arr} and 7 (8) instructions:\medskip
+
+\begin{itemize}
+\item \texttt{>} move \texttt{ptr++}
+\item \texttt{<} move \texttt{ptr-{}-}
+\item \texttt{+} add \texttt{arr[ptr]++}
+\item \texttt{-} subtract \texttt{arr[ptr]-{}-}
+\item \texttt{.} print out \texttt{arr[ptr]} as ASCII
+\item \texttt{[} if \texttt{arr[ptr] == 0} jump just after the corresponding \texttt{]}; otherwise \texttt{ptr++}
+\item \texttt{]} if \texttt{arr[ptr] != 0} jump just after the corresponding \texttt{[}; otherwise \texttt{ptr++}
+
+\end{itemize}  
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+\frametitle{Arrays in While}
+
+\begin{itemize}
+\item \texttt{new arr[15000]}\medskip 
+\item \texttt{x := 3 + arr[3 + y]}\medskip 
+\item \texttt{arr[42 * n] := ...}
+\end{itemize}  
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+\frametitle{New Arrays}
+
+\begin{lstlisting}[mathescape,numbers=none,language=While]
+  new arr[number]
+\end{lstlisting}\bigskip\bigskip
+
+\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
+  ldc number
+  newarray int
+  astore loc_var
+\end{lstlisting}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+\frametitle{Array Update}
+
+\begin{lstlisting}[mathescape,numbers=none,language=While]
+  arr[...] := 
+\end{lstlisting}\bigskip\bigskip
+
+\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
+  aload loc_var
+  index_aexp
+  value_aexp
+  iastore
+\end{lstlisting}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c,fragile]
+\frametitle{Array Lookup in AExp}
+
+\begin{lstlisting}[mathescape,numbers=none,language=While]
+  ...arr[...]... 
+\end{lstlisting}\bigskip\bigskip
+
+\begin{lstlisting}[mathescape,numbers=none,language=JVMIS]
+  aload loc_var
+  index_aexp
+  iaload
+\end{lstlisting}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \mode<presentation>{
 \begin{frame}[c]
 \frametitle{Backend}