slides/slides09.tex
changeset 336 3cb200fa6d6a
parent 335 06d5fc15594d
child 337 92a718b88e14
--- a/slides/slides09.tex	Wed Nov 26 10:15:43 2014 +0000
+++ b/slides/slides09.tex	Thu Nov 27 17:52:17 2014 +0000
@@ -3,29 +3,16 @@
 \usepackage{../langs}
 \usepackage{../graphics}
 \usepackage{../grammar}
+
 %\usepackage{soul}
 
-\makeatletter
-\newenvironment<>{btHighlight}[1][]
-{\begin{onlyenv}#2\begingroup\tikzset{bt@Highlight@par/.style={#1}}\begin{lrbox}{\@tempboxa}}
-{\end{lrbox}\bt@HL@box[bt@Highlight@par]{\@tempboxa}\endgroup\end{onlyenv}}
-
-\newcommand<>\btHL[1][]{%
-  \only#2{\begin{btHighlight}[#1]\bgroup\aftergroup\bt@HL@endenv}%
-}
-\def\bt@HL@endenv{%
-  \end{btHighlight}%   
-  \egroup
-}
-\newcommand{\bt@HL@box}[2][]{%
-  \tikz[#1]{%
-    \pgfpathrectangle{\pgfpoint{1pt}{0pt}}{\pgfpoint{\wd #2}{\ht #2}}%
-    \pgfusepath{use as bounding box}%
-    \node[anchor=base west, fill=orange!30,outer sep=0pt,inner xsep=1pt, inner ysep=0pt, rounded corners=3pt, minimum height=\ht\strutbox+1pt,#1]{\raisebox{1pt}{\strut}\strut\usebox{#2}};
-  }%
-}
-\makeatother
-
+%\newcommand\hl[1]{%
+%    \tikz[baseline,%
+%      outer sep=-15pt, inner sep = 0pt%
+%    ]%
+%   \node[decorate,rectangle,fill=yellow,anchor=text]{#1};%
+%}%
+\newcommand{\hl}[1]{#1}
 
 % beamer stuff 
 \renewcommand{\slidecaption}{APP 09, King's College London}
@@ -864,7 +851,7 @@
          | \meta{var}\\
 : \meta{Stmt} ::= \meta{label} :
          | \meta{var} := \meta{Exp}
-         | jump? \meta{Exp} \meta{label}
+         | jmp? \meta{Exp} \meta{label}
          | goto \meta{label}\\
 : \meta{Prog} ::= \meta{Stmt} \ldots\\
 \end{plstx}}
@@ -884,7 +871,7 @@
          | \meta{var}\\
 : \meta{Stmt} ::= \meta{label} :
          | \meta{var} := \meta{Exp}
-         | jump? \meta{Exp} \meta{label}
+         | jmp? \meta{Exp} \meta{label}
          | goto \meta{label}\\
 : \meta{Prog} ::= \meta{Stmt} \ldots\\
 \end{plstx}}
@@ -897,7 +884,7 @@
                    language={},xleftmargin=3mm]
       a := 1
       n := 5 
-top:  jump? n = 0 done 
+top:  jmp? n = 0 done 
       a := a * n 
       n := n + -1 
       goto top 
@@ -970,13 +957,13 @@
 \end{center}
 
 \footnotesize
-\begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-5mm]
+\begin{lstlisting}[numbers=none,xleftmargin=-5mm]
 def eval_exp(e: Exp, env: Env) : Int = e match {
-  case Num(n) & n
-  case Var(x) & env(x)
-  case Plus(e1, e2) & eval_exp(e1, env) + eval_exp(e2, env)
-  case Times(e1, e2) & eval_exp(e1, env) * eval_exp(e2, env)
-  case Equ(e1, e2) & 
+  case Num(n) => n
+  case Var(x) => env(x)
+  case Plus(e1, e2) => eval_exp(e1, env) + eval_exp(e2, env)
+  case Times(e1, e2) => eval_exp(e1, env) * eval_exp(e2, env)
+  case Equ(e1, e2) => 
     if (eval_exp(e1, env) == eval_exp(e2, env)) 1 else 0
 }
 \end{lstlisting}
@@ -1088,14 +1075,14 @@
 \begin{lstlisting}[language=Scala,numbers=none,xleftmargin=-5mm]
 def eval(sn: Snips) : Env = {
   def eval_stmts(sts: Stmts, env: Env) : Env = sts match {
-    case Nil & env
-    case Label(l)::rest & eval_stmts(rest, env)
-    case Assign(x, e)::rest & 
+    case Nil => env
+    case Label(l)::rest => eval_stmts(rest, env)
+    case Assign(x, e)::rest => 
       eval_stmts(rest, env + (x -> eval_exp(e, env)))
-    case Jump(b, l)::rest & 
+    case Jmp(b, l)::rest => 
       if (eval_exp(b, env) == 1) eval_stmts(sn(l), env) 
       else eval_stmts(rest, env)
-    case Goto(l)::rest & eval_stmts(sn(l), env)
+    case Goto(l)::rest => eval_stmts(sn(l), env)
   }
 
   eval_stmts(sn(""), Map())
@@ -1138,12 +1125,12 @@
                    language={},
                    basicstyle=\ttfamily,
                    xleftmargin=1mm,
-                   escapeinside={(*@}{@*)}]
-      a := (*@\hl{'+'}@*)
-      n := (*@\hl{'+'}@*) 
-top:  jmp? n = (*@\hl{'0'}@*) done 
+                   escapeinside={(*}{*)}]
+      a := (*\hl{'+'}*)
+      n := (*\hl{'+'}*) 
+top:  jmp? n = (*\hl{'0'}*) done 
       a := a * n 
-      n := n + (*@\hl{'-'}@*) 
+      n := n + (*\hl{'-'}*) 
       goto top 
 done:
 \end{lstlisting}