--- a/langs.sty Wed Nov 26 10:15:43 2014 +0000
+++ b/langs.sty Thu Nov 27 17:52:17 2014 +0000
@@ -8,28 +8,10 @@
\definecolor{codepurple}{rgb}{0.5,0,0.35} % keywords
\definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc
\definecolor{codeblue}{rgb}{0.25,0.35,0.75} % types
-\definecolor{darkgray}{rgb}{.4,.4,.4}
\BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
\AfterEndEnvironment{lstlisting}{\end{minipage}\par}
-\lstdefinelanguage{JavaScript}{
- keywords={break,case,catch,continue,debugger,default,%
- delete,do,else,false,finally,for,function,if,in,instanceof,%
- new,null,return,switch,this,throw,true,try,typeof,var,void,while,with},
- morecomment=[l]{//},
- morecomment=[s]{/*}{*/},
- morestring=[b]',
- morestring=[b]",
- ndkeywords={class,export,boolean,throw,implements,import,this},
- keywordstyle=\color{codepurple}\bfseries,
- ndkeywordstyle=\color{darkgray}\bfseries,
- identifierstyle=\color{black},
- commentstyle=\color{codegreen}\ttfamily,
- stringstyle=\color{codegreen}\ttfamily,
- sensitive=true
-}
-
\lstdefinelanguage{Scala}{
morekeywords={abstract,case,catch,class,def,%
do,else,extends,false,final,finally,%
@@ -38,28 +20,28 @@
private,protected,requires,return,sealed,%
super,this,throw,trait,true,try,%
type,val,var,while,with,yield},%
- otherkeywords={=>,<-,<\%,<:,>:,\#,@},%
+ otherkeywords={=>,<-,<\%,<:,>:,\#},%
sensitive=true,%
%directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},%
%moredelim=*[directive]:,%
morecomment=[l]{//},%
morecomment=[n]{/*}{*/},
+ morestring=[s]{"""}{"""},
morestring=[b]",
morestring=[b]',
- morestring=[b]"""
}[keywords,comments,strings]
\lstdefinelanguage{While}{
- morekeywords={if,then,else,while,do,true,false,write,upto,for,skip},
- otherkeywords={=,!=,:=,<,>,;},
- sensitive=true,
+ morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip},
+ morecomment=[l]{//},
morecomment=[n]{/*}{*/},
-}
+ morestring=[b]",
+ otherkeywords={=,!=,:=,<,>,\%;*,/},
+}[keywords,comments,strings]
\lstdefinestyle{mystyle}
{basicstyle=\ttfamily,
keywordstyle=\color{codepurple}\bfseries,
- %directivestyle=\color{codeblue}\bfseries,
stringstyle=\color{codegreen},
commentstyle=\color{codegreen},
morecomment=[s][\color{codedocblue}]{/**}{*/},
@@ -72,7 +54,8 @@
showstringspaces=false,
xleftmargin=8mm,
emphstyle=\color{codeblue}\bfseries,
- keepspaces}
+ keepspaces
+}
\lstset{language=Scala,
style=mystyle}
@@ -80,4 +63,5 @@
\newcommand{\code}[1]{{\lstinline{#1}}}
\newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}}
+\newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}}
\makeatother
--- 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}