# HG changeset patch # User Christian Urban # Date 1379981556 -3600 # Node ID dbe49327b6c58f3d7dd3db6bd6e74d6e2f9c18ec # Parent 9ea667baf097eef88e1d07ee16ea11439fbcb104 added new stuff diff -r 9ea667baf097 -r dbe49327b6c5 pics/ante1.jpg Binary file pics/ante1.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 pics/ante2.jpg Binary file pics/ante2.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 pics/hopper.jpg Binary file pics/hopper.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 pics/laptop.png Binary file pics/laptop.png has changed diff -r 9ea667baf097 -r dbe49327b6c5 pics/servers.png Binary file pics/servers.png has changed diff -r 9ea667baf097 -r dbe49327b6c5 progs/crawler1.scala --- a/progs/crawler1.scala Wed Aug 07 17:31:42 2013 +0100 +++ b/progs/crawler1.scala Tue Sep 24 01:12:36 2013 +0100 @@ -7,8 +7,8 @@ Source.fromURL(url).take(10000).mkString } catch { - case e => { - println(" Problem with: " + url) + case _ : Throwable => { + println(s" Problem with: $url") "" } } @@ -29,7 +29,7 @@ def crawl(url: String, n: Int) : Unit = { if (n == 0) () else { - println("Visiting: " + n + " " + url) + println(s"Visiting: $n $url") for (u <- get_all_URLs(get_page(url))) crawl(u, n - 1) } } @@ -42,4 +42,4 @@ // call on the command line crawl(startURL, 2) -crawl("""http://www.dcs.kcl.ac.uk/staff/urbanc/msc-projects-12.html""", 2) +crawl("""http://www.inf.kcl.ac.uk/staff/urbanc/bsc-projects-13.html""", 2) diff -r 9ea667baf097 -r dbe49327b6c5 progs/crawler2.scala --- a/progs/crawler2.scala Wed Aug 07 17:31:42 2013 +0100 +++ b/progs/crawler2.scala Tue Sep 24 01:12:36 2013 +0100 @@ -7,8 +7,8 @@ Source.fromURL(url).take(10000).mkString } catch { - case e => { - println(" Problem with: " + url) + case _ : Throwable => { + println(s" Problem with: $url") "" } } @@ -33,7 +33,7 @@ if (n == 0) () else if (my_urls.findFirstIn(url) == None) () else { - println("Visiting: " + n + " " + url) + println(s"Visiting: $n $url") for (u <- get_all_URLs(get_page(url))) crawl(u, n - 1) } } diff -r 9ea667baf097 -r dbe49327b6c5 progs/crawler3.scala --- a/progs/crawler3.scala Wed Aug 07 17:31:42 2013 +0100 +++ b/progs/crawler3.scala Tue Sep 24 01:12:36 2013 +0100 @@ -7,8 +7,8 @@ Source.fromURL(url).take(10000).mkString } catch { - case e => { - println(" Problem with: " + url) + case _ : Throwable => { + println(s" Problem with: $url") "" } } @@ -36,7 +36,7 @@ if (n == 0) () //else if (my_urls.findFirstIn(url) == None) () else { - println("Visiting: " + n + " " + url) + println(s"Visiting: $n $url") val page = get_page(url) println(email_pattern.findAllIn(page).mkString("\n")) for (u <- get_all_URLs(page)) crawl(u, n - 1) diff -r 9ea667baf097 -r dbe49327b6c5 progs/re-sulzmann-partial.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/re-sulzmann-partial.scala Tue Sep 24 01:12:36 2013 +0100 @@ -0,0 +1,136 @@ +import scala.language.implicitConversions +import scala.language.reflectiveCalls + +abstract class Rexp + +case object NULL extends Rexp +case object EMPTY extends Rexp +case class CHAR(c: Char) extends Rexp +case class ALT(r1: Rexp, r2: Rexp) extends Rexp +case class SEQ(r1: Rexp, r2: Rexp) extends Rexp +case class STAR(r: Rexp) extends Rexp + +abstract class Pat + +case class VAR(x: String, r: Rexp) extends Pat +case class GRP(x: String, p: Pat) extends Pat +case class PSEQ(p1: Pat, p2: Pat) extends Pat +case class PALT(p1: Pat, p2: Pat) extends Pat +case class PSTAR(p: Pat) extends Pat + + +def nullable (r: Rexp) : Boolean = r match { + case NULL => false + case EMPTY => true + case CHAR(_) => false + case ALT(r1, r2) => nullable(r1) || nullable(r2) + case SEQ(r1, r2) => nullable(r1) && nullable(r2) + case STAR(_) => true +} + +def down (p: Pat) : Rexp = p match { + case VAR(x: String, w: String, r: Rexp) => r + case GRP(x: String, w: String, p: Pat) => down(p) + case PSEQ(p1: Pat, p2: Pat) => SEQ(down(p1), down(p2)) + case PALT(p1: Pat, p2: Pat) => ALT(down(p1), down(p2)) + case PSTAR(p: Pat) => STAR(down(p)) +} + +def patnullable (p: Pat) : Boolean = p match { + case PVar(_, r) => nullable(r) + case PSEQ(p1, p2) => patnullable(p1) && patnullable(p2) + case PCHOICE(p1, p2) => patnullable(p1) || patnullable(p2) + case PSTAR(p) => true + case PatVar(_, p) => patnullable(p) +} + +//type Env = Set[List[(String, String)]] +type Env = Map[Int, String] + +def update(n: Int, c: Char) (env: Env) = + env + (n -> (env.getOrElse(n, "") + c.toString)) + +def pderivPat (p: Pat, c: Char) : Set[(Pat, Env => Env)] = p match { + case PVar(n: Int, r: Rexp) => { + val pds = pderiv(r, c) + if (pds.isEmpty) Set() + else Set((PVar(n, toRexp(pds.toList)), update(n, c))) + } + case PSEQ(p1: Pat, p2: Pat) => { + val pats : Set[(Pat, Env => Env)] = + for ((p, f) <- pderivPat(p1, c)) yield (PSEQ(p, p2), f) + if (nullable(strip(p1))) pats ++ pderivPat(p2, c) + else pats + } + case PCHOICE(p1: Pat, p2: Pat) => pderivPat(p1, c) ++ pderivPat(p2, c) + case PSTAR(p1: Pat) => + for ((p, f) <- pderivPat(p1, c)) yield (PSEQ(p, PSTAR(p1)), f) + case PatVar(n: Int, p1: Pat) => + for ((p, f) <- pderivPat(p1, c)) yield (PatVar(n, p), f compose (update (n, c))) +} + + +val p2 = PSEQ(PVar(1, STAR("A")), PVar(2, STAR("A"))) +pderivPat(p2, 'A').mkString("\n") + + +def greedy_aux(env: Set[(Pat, Env)], w: List[Char]) : Set[Env] = w match { + case Nil => + for ((p, e) <- env if patnullable(p)) yield e + case c::cs => { + val env2 = for ((p, e) <- env; (p1, f) <- pderivPat(p, c)) yield (p1, f(e)) + greedy_aux(env2, cs) + } +} + +def greedy(p: Pat, w: String) = { + val res = greedy_aux(Set((p, Map())), w.toList) + if (res.isEmpty) None else Some(res) +} + +// some convenience for typing in regular expressions +def charlist2rexp (s : List[Char]) : Rexp = s match { + case Nil => EMPTY + case c::Nil => CHAR(c) + case c::s => SEQ(CHAR(c), charlist2rexp(s)) +} +implicit def string2rexp (s : String) : Rexp = charlist2rexp(s.toList) + +implicit def RexpOps (r: Rexp) = new { + def | (s: Rexp) = ALT(r, s) + def % = STAR(r) + def ~ (s: Rexp) = SEQ(r, s) +} + +implicit def stringOps (s: String) = new { + def | (r: Rexp) = ALT(s, r) + def | (r: String) = ALT(s, r) + def % = STAR(s) + def ~ (r: Rexp) = SEQ(s, r) + def ~ (r: String) = SEQ(s, r) +} + +implicit def PatOps (p: Pat) = new { + def | (q: Pat) = PALT(p, q) + def % = PSTAR(p) + def ~ (q: Pat) = PSEQ(p, q) +} + +val p3 = PSTAR(PSEQ(PVar(1, "A"), PVar(2, "B"))) + +greedy2(Set((p3, Map())), "ABAB".toList) + + +val p4 = PVar(1, "A") +greedy2(Set((p4, Map())), "A".toList) + +val p5 = PSEQ(PVar(1, "A"), PVar(1, "B")) +greedy2(Set((p5, Map())), "AB".toList) + +val res = pderivPat(p5, 'A') +for ((_, f) <- res) yield f(Map()) + + +val p6 = PatVar(4,PSTAR(PCHOICE(PCHOICE(PVar(1, "A"), PVar(2, "AB")), PVar(3, "B")))) + +greedy(p6, "ABA") diff -r 9ea667baf097 -r dbe49327b6c5 progs/re-sulzmann.scala --- a/progs/re-sulzmann.scala Wed Aug 07 17:31:42 2013 +0100 +++ b/progs/re-sulzmann.scala Tue Sep 24 01:12:36 2013 +0100 @@ -43,7 +43,7 @@ case STAR(r) => SEQ(der(c, r), STAR(r)) } -def down(p: Pat) : Rexp = p match { +def down (p: Pat) : Rexp = p match { case VAR(x: String, w: String, r: Rexp) => r case GRP(x: String, w: String, p: Pat) => down(p) case PSEQ(p1: Pat, p2: Pat) => SEQ(down(p1), down(p2)) @@ -51,7 +51,7 @@ case PSTAR(p: Pat) => STAR(down(p)) } -def empty(p: Pat) : Pat = p match { +def empty (p: Pat) : Pat = p match { case VAR(x: String, w: String, r: Rexp) => if (nullable(r)) VAR(x, w, EMPTY) else VAR(x, w, NULL) @@ -61,7 +61,7 @@ case PSTAR(p: Pat) => PSTAR(empty(p)) } -def patder(c: Char, p: Pat) : Pat = p match { +def patder (c: Char, p: Pat) : Pat = p match { case VAR(x: String, w: String, r: Rexp) => VAR(x, w + c, der(c, r)) case GRP(x: String, w: String, p: Pat) => GRP(x, w + c, patder(c, p)) case PSEQ(p1: Pat, p2: Pat) => @@ -78,11 +78,10 @@ type Env = Set[List[(String, String)]] -def special(p: Pat, env: Env) : Env = +def special (p: Pat, env: Env) : Env = if (env == Set() && nullable(down(p))) Set(Nil) else env - -def env(p: Pat) : Env = p match { +def env (p: Pat) : Env = p match { case VAR(x: String, w: String, r: Rexp) => if (nullable(r)) Set(List((x, w))) else Set() case GRP(x: String, w: String, p1: Pat) => @@ -93,24 +92,24 @@ case PSTAR(p1: Pat) => special(p, env(p1)) } -def matcher(p: Pat, s: String) = env(empty(patders(s.toList, p))) +def matcher (p: Pat, s: String) = env(empty(patders(s.toList, p))) // some convenience for typing in regular expressions -def charlist2rexp(s : List[Char]) : Rexp = s match { +def charlist2rexp (s : List[Char]) : Rexp = s match { case Nil => EMPTY case c::Nil => CHAR(c) case c::s => SEQ(CHAR(c), charlist2rexp(s)) } -implicit def string2rexp(s : String) : Rexp = charlist2rexp(s.toList) +implicit def string2rexp (s : String) : Rexp = charlist2rexp(s.toList) -implicit def RexpOps(r: Rexp) = new { +implicit def RexpOps (r: Rexp) = new { def | (s: Rexp) = ALT(r, s) def % = STAR(r) def ~ (s: Rexp) = SEQ(r, s) } -implicit def stringOps(s: String) = new { +implicit def stringOps (s: String) = new { def | (r: Rexp) = ALT(s, r) def | (r: String) = ALT(s, r) def % = STAR(s) @@ -118,7 +117,7 @@ def ~ (r: String) = SEQ(s, r) } -implicit def PatOps(p: Pat) = new { +implicit def PatOps (p: Pat) = new { def | (q: Pat) = PALT(p, q) def % = PSTAR(p) def ~ (q: Pat) = PSEQ(p, q) @@ -162,3 +161,4 @@ val p7 = (VAR("x", "A") | VAR("y", "AB") | VAR("z", "B")).% matcher(p7, "AB") + diff -r 9ea667baf097 -r dbe49327b6c5 slides/beamerthemeplaincu.sty --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slides/beamerthemeplaincu.sty Tue Sep 24 01:12:36 2013 +0100 @@ -0,0 +1,115 @@ +%%\Providespackage{beamerthemeplainculight}[2003/11/07 ver 0.93] +\NeedsTeXFormat{LaTeX2e}[1995/12/01] + +% Copyright 2003 by Till Tantau . +% +% This program can be redistributed and/or modified under the terms +% of the LaTeX Project Public License Distributed from CTAN +% archives in directory macros/latex/base/lppl.txt. + +\newcommand{\slidecaption}{} + +\mode + +\usepackage{fontspec} +\usefonttheme{serif} +\defaultfontfeatures{Ligatures=TeX} +\setromanfont{Hoefler Text} +\setmonofont[Scale=MatchLowercase]{Consolas} +\newfontfamily{\consolas}{Consolas} +\newcommand{\tttext}[1]{{\consolas{#1}}} +%%\setttfont{Lucida Console} +%%\setmainfont[Mapping=tex-text]{Hoefler Text} + +%%\renewcommand\ttdefault{lmtt} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% comic fonts fonts +%\DeclareFontFamily{T1}{comic}{}% +%\DeclareFontShape{T1}{comic}{m}{n}{<->s*[.9]comic8t}{}% +%\DeclareFontShape{T1}{comic}{m}{it}{<->s*[.9]comic8t}{}% +%\DeclareFontShape{T1}{comic}{m}{sc}{<->s*[.9]comic8t}{}% +%\DeclareFontShape{T1}{comic}{b}{n}{<->s*[.9]comicbd8t}{}% +%\DeclareFontShape{T1}{comic}{b}{it}{<->s*[.9]comicbd8t}{}% +%\DeclareFontShape{T1}{comic}{m}{sl}{<->ssub * comic/m/it}{}% +%\DeclareFontShape{T1}{comic}{b}{sc}{<->sub * comic/m/sc}{}% +%\DeclareFontShape{T1}{comic}{b}{sl}{<->ssub * comic/b/it}{}% +%\DeclareFontShape{T1}{comic}{bx}{n}{<->ssub * comic/b/n}{}% +%\DeclareFontShape{T1}{comic}{bx}{it}{<->ssub * comic/b/it}{}% +%\DeclareFontShape{T1}{comic}{bx}{sc}{<->sub * comic/m/sc}{}% +%\DeclareFontShape{T1}{comic}{bx}{sl}{<->ssub * comic/b/it}{}% +% +%\renewcommand{\rmdefault}{comic}% +%\renewcommand{\sfdefault}{comic}% +\renewcommand{\mathfamilydefault}{cmr}% mathfont should be still the old one +% +\DeclareMathVersion{bold}% mathfont needs to be bold +\DeclareSymbolFont{operators}{OT1}{cmr}{b}{n}% +\SetSymbolFont{operators}{bold}{OT1}{cmr}{b}{n}% +\DeclareSymbolFont{letters}{OML}{cmm}{b}{it}% +\SetSymbolFont{letters}{bold}{OML}{cmm}{b}{it}% +\DeclareSymbolFont{symbols}{OMS}{cmsy}{b}{n}% +\SetSymbolFont{symbols}{bold}{OMS}{cmsy}{b}{n}% +\DeclareSymbolFont{largesymbols}{OMX}{cmex}{b}{n}% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Frametitles + +\setbeamerfont{frametitle}{size={\LARGE}} +\setbeamerfont{frametitle}{family={\fontspec{Hoefler Text Black}}} +%\setbeamerfont{frametitle}{family={\usefont{T1}{ptm}{b}{n}} +\setbeamercolor{frametitle}{fg=ProcessBlue,bg=white} + +\setbeamertemplate{frametitle}{% +\vskip 2mm % distance from the top margin +\hskip -3mm % distance from left margin +\vbox{% +\begin{minipage}{1.05\textwidth}% +\centering% +\insertframetitle% +\end{minipage}}% +} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Foot +% +\setbeamertemplate{navigation symbols}{} +\usefoottemplate{% +\vbox{% + \tinyline{% + \tiny\hfill\textcolor{gray!50}{\slidecaption{} -- + p.~\insertframenumber/\inserttotalframenumber}}}% +} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\beamertemplateballitem +\setlength\leftmargini{2mm} +\setlength\leftmarginii{0.6cm} +\setlength\leftmarginiii{1.5cm} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% blocks +%\definecolor{cream}{rgb}{1,1,.65} +\definecolor{cream}{rgb}{1,1,.8} +\setbeamerfont{block title}{size=\normalsize} +\setbeamercolor{block title}{fg=black,bg=cream} +\setbeamercolor{block body}{fg=black,bg=cream} + +\setbeamertemplate{blocks}[rounded][shadow=true] + +\setbeamercolor{boxcolor}{fg=black,bg=cream} + +\mode + + + + + + + diff -r 9ea667baf097 -r dbe49327b6c5 slides/mathpartir.sty --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/slides/mathpartir.sty Tue Sep 24 01:12:36 2013 +0100 @@ -0,0 +1,446 @@ +% Mathpartir --- Math Paragraph for Typesetting Inference Rules +% +% Copyright (C) 2001, 2002, 2003, 2004, 2005 Didier Rémy +% +% Author : Didier Remy +% Version : 1.2.0 +% Bug Reports : to author +% Web Site : http://pauillac.inria.fr/~remy/latex/ +% +% Mathpartir is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2, or (at your option) +% any later version. +% +% Mathpartir is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details +% (http://pauillac.inria.fr/~remy/license/GPL). +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% File mathpartir.sty (LaTeX macros) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mathpartir} + [2005/12/20 version 1.2.0 Math Paragraph for Typesetting Inference Rules] + +%% + +%% Identification +%% Preliminary declarations + +\RequirePackage {keyval} + +%% Options +%% More declarations + +%% PART I: Typesetting maths in paragraphe mode + +%% \newdimen \mpr@tmpdim +%% Dimens are a precious ressource. Uses seems to be local. +\let \mpr@tmpdim \@tempdima + +% To ensure hevea \hva compatibility, \hva should expands to nothing +% in mathpar or in inferrule +\let \mpr@hva \empty + +%% normal paragraph parametters, should rather be taken dynamically +\def \mpr@savepar {% + \edef \MathparNormalpar + {\noexpand \lineskiplimit \the\lineskiplimit + \noexpand \lineskip \the\lineskip}% + } + +\def \mpr@rulelineskip {\lineskiplimit=0.3em\lineskip=0.2em plus 0.1em} +\def \mpr@lesslineskip {\lineskiplimit=0.6em\lineskip=0.5em plus 0.2em} +\def \mpr@lineskip {\lineskiplimit=1.2em\lineskip=1.2em plus 0.2em} +\let \MathparLineskip \mpr@lineskip +\def \mpr@paroptions {\MathparLineskip} +\let \mpr@prebindings \relax + +\newskip \mpr@andskip \mpr@andskip 2em plus 0.5fil minus 0.5em + +\def \mpr@goodbreakand + {\hskip -\mpr@andskip \penalty -1000\hskip \mpr@andskip} +\def \mpr@and {\hskip \mpr@andskip} +\def \mpr@andcr {\penalty 50\mpr@and} +\def \mpr@cr {\penalty -10000\mpr@and} +\def \mpr@eqno #1{\mpr@andcr #1\hskip 0em plus -1fil \penalty 10} + +\def \mpr@bindings {% + \let \and \mpr@andcr + \let \par \mpr@andcr + \let \\\mpr@cr + \let \eqno \mpr@eqno + \let \hva \mpr@hva + } +\let \MathparBindings \mpr@bindings + +% \@ifundefined {ignorespacesafterend} +% {\def \ignorespacesafterend {\aftergroup \ignorespaces} + +\newenvironment{mathpar}[1][] + {$$\mpr@savepar \parskip 0em \hsize \linewidth \centering + \vbox \bgroup \mpr@prebindings \mpr@paroptions #1\ifmmode $\else + \noindent $\displaystyle\fi + \MathparBindings} + {\unskip \ifmmode $\fi\egroup $$\ignorespacesafterend} + +\newenvironment{mathparpagebreakable}[1][] + {\begingroup + \par + \mpr@savepar \parskip 0em \hsize \linewidth \centering + \mpr@prebindings \mpr@paroptions #1% + \vskip \abovedisplayskip \vskip -\lineskip% + \ifmmode \else $\displaystyle\fi + \MathparBindings + } + {\unskip + \ifmmode $\fi \par\endgroup + \vskip \belowdisplayskip + \noindent + \ignorespacesafterend} + +% \def \math@mathpar #1{\setbox0 \hbox {$\displaystyle #1$}\ifnum +% \wd0 < \hsize $$\box0$$\else \bmathpar #1\emathpar \fi} + +%%% HOV BOXES + +\def \mathvbox@ #1{\hbox \bgroup \mpr@normallineskip + \vbox \bgroup \tabskip 0em \let \\ \cr + \halign \bgroup \hfil $##$\hfil\cr #1\crcr \egroup \egroup + \egroup} + +\def \mathhvbox@ #1{\setbox0 \hbox {\let \\\qquad $#1$}\ifnum \wd0 < \hsize + \box0\else \mathvbox {#1}\fi} + + +%% Part II -- operations on lists + +\newtoks \mpr@lista +\newtoks \mpr@listb + +\long \def\mpr@cons #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter +{#2}\edef #2{\the \mpr@lista \the \mpr@listb}} + +\long \def\mpr@snoc #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter +{#2}\edef #2{\the \mpr@listb\the\mpr@lista}} + +\long \def \mpr@concat#1=#2\mpr@to#3{\mpr@lista \expandafter {#2}\mpr@listb +\expandafter {#3}\edef #1{\the \mpr@listb\the\mpr@lista}} + +\def \mpr@head #1\mpr@to #2{\expandafter \mpr@head@ #1\mpr@head@ #1#2} +\long \def \mpr@head@ #1#2\mpr@head@ #3#4{\def #4{#1}\def#3{#2}} + +\def \mpr@flatten #1\mpr@to #2{\expandafter \mpr@flatten@ #1\mpr@flatten@ #1#2} +\long \def \mpr@flatten@ \\#1\\#2\mpr@flatten@ #3#4{\def #4{#1}\def #3{\\#2}} + +\def \mpr@makelist #1\mpr@to #2{\def \mpr@all {#1}% + \mpr@lista {\\}\mpr@listb \expandafter {\mpr@all}\edef \mpr@all {\the + \mpr@lista \the \mpr@listb \the \mpr@lista}\let #2\empty + \def \mpr@stripof ##1##2\mpr@stripend{\def \mpr@stripped{##2}}\loop + \mpr@flatten \mpr@all \mpr@to \mpr@one + \expandafter \mpr@snoc \mpr@one \mpr@to #2\expandafter \mpr@stripof + \mpr@all \mpr@stripend + \ifx \mpr@stripped \empty \let \mpr@isempty 0\else \let \mpr@isempty 1\fi + \ifx 1\mpr@isempty + \repeat +} + +\def \mpr@rev #1\mpr@to #2{\let \mpr@tmp \empty + \def \\##1{\mpr@cons ##1\mpr@to \mpr@tmp}#1\let #2\mpr@tmp} + +%% Part III -- Type inference rules + +\newif \if@premisse +\newbox \mpr@hlist +\newbox \mpr@vlist +\newif \ifmpr@center \mpr@centertrue +\def \mpr@htovlist {% + \setbox \mpr@hlist + \hbox {\strut + \ifmpr@center \hskip -0.5\wd\mpr@hlist\fi + \unhbox \mpr@hlist}% + \setbox \mpr@vlist + \vbox {\if@premisse \box \mpr@hlist \unvbox \mpr@vlist + \else \unvbox \mpr@vlist \box \mpr@hlist + \fi}% +} +% OLD version +% \def \mpr@htovlist {% +% \setbox \mpr@hlist +% \hbox {\strut \hskip -0.5\wd\mpr@hlist \unhbox \mpr@hlist}% +% \setbox \mpr@vlist +% \vbox {\if@premisse \box \mpr@hlist \unvbox \mpr@vlist +% \else \unvbox \mpr@vlist \box \mpr@hlist +% \fi}% +% } + +\def \mpr@item #1{$\displaystyle #1$} +\def \mpr@sep{2em} +\def \mpr@blank { } +\def \mpr@hovbox #1#2{\hbox + \bgroup + \ifx #1T\@premissetrue + \else \ifx #1B\@premissefalse + \else + \PackageError{mathpartir} + {Premisse orientation should either be T or B} + {Fatal error in Package}% + \fi \fi + \def \@test {#2}\ifx \@test \mpr@blank\else + \setbox \mpr@hlist \hbox {}% + \setbox \mpr@vlist \vbox {}% + \if@premisse \let \snoc \mpr@cons \else \let \snoc \mpr@snoc \fi + \let \@hvlist \empty \let \@rev \empty + \mpr@tmpdim 0em + \expandafter \mpr@makelist #2\mpr@to \mpr@flat + \if@premisse \mpr@rev \mpr@flat \mpr@to \@rev \else \let \@rev \mpr@flat \fi + \def \\##1{% + \def \@test {##1}\ifx \@test \empty + \mpr@htovlist + \mpr@tmpdim 0em %%% last bug fix not extensively checked + \else + \setbox0 \hbox{\mpr@item {##1}}\relax + \advance \mpr@tmpdim by \wd0 + %\mpr@tmpdim 1.02\mpr@tmpdim + \ifnum \mpr@tmpdim < \hsize + \ifnum \wd\mpr@hlist > 0 + \if@premisse + \setbox \mpr@hlist + \hbox {\unhbox0 \hskip \mpr@sep \unhbox \mpr@hlist}% + \else + \setbox \mpr@hlist + \hbox {\unhbox \mpr@hlist \hskip \mpr@sep \unhbox0}% + \fi + \else + \setbox \mpr@hlist \hbox {\unhbox0}% + \fi + \else + \ifnum \wd \mpr@hlist > 0 + \mpr@htovlist + \mpr@tmpdim \wd0 + \fi + \setbox \mpr@hlist \hbox {\unhbox0}% + \fi + \advance \mpr@tmpdim by \mpr@sep + \fi + }% + \@rev + \mpr@htovlist + \ifmpr@center \hskip \wd\mpr@vlist\fi \box \mpr@vlist + \fi + \egroup +} + +%%% INFERENCE RULES + +\@ifundefined{@@over}{% + \let\@@over\over % fallback if amsmath is not loaded + \let\@@overwithdelims\overwithdelims + \let\@@atop\atop \let\@@atopwithdelims\atopwithdelims + \let\@@above\above \let\@@abovewithdelims\abovewithdelims + }{} + +%% The default + +\def \mpr@@fraction #1#2{\hbox {\advance \hsize by -0.5em + $\displaystyle {#1\mpr@over #2}$}} +\def \mpr@@nofraction #1#2{\hbox {\advance \hsize by -0.5em + $\displaystyle {#1\@@atop #2}$}} + +\let \mpr@fraction \mpr@@fraction + +%% A generic solution to arrow + +\def \mpr@make@fraction #1#2#3#4#5{\hbox {% + \def \mpr@tail{#1}% + \def \mpr@body{#2}% + \def \mpr@head{#3}% + \setbox1=\hbox{$#4$}\setbox2=\hbox{$#5$}% + \setbox3=\hbox{$\mkern -3mu\mpr@body\mkern -3mu$}% + \setbox3=\hbox{$\mkern -3mu \mpr@body\mkern -3mu$}% + \dimen0=\dp1\advance\dimen0 by \ht3\relax\dp1\dimen0\relax + \dimen0=\ht2\advance\dimen0 by \dp3\relax\ht2\dimen0\relax + \setbox0=\hbox {$\box1 \@@atop \box2$}% + \dimen0=\wd0\box0 + \box0 \hskip -\dimen0\relax + \hbox to \dimen0 {$% + \mathrel{\mpr@tail}\joinrel + \xleaders\hbox{\copy3}\hfil\joinrel\mathrel{\mpr@head}% + $}}} + +%% Old stuff should be removed in next version +\def \mpr@@nothing #1#2 + {$\lower 0.01pt \mpr@@nofraction {#1}{#2}$} +\def \mpr@@reduce #1#2{\hbox + {$\lower 0.01pt \mpr@@fraction {#1}{#2}\mkern -15mu\rightarrow$}} +\def \mpr@@rewrite #1#2#3{\hbox + {$\lower 0.01pt \mpr@@fraction {#2}{#3}\mkern -8mu#1$}} +\def \mpr@infercenter #1{\vcenter {\mpr@hovbox{T}{#1}}} + +\def \mpr@empty {} +\def \mpr@inferrule + {\bgroup + \ifnum \linewidth<\hsize \hsize \linewidth\fi + \mpr@rulelineskip + \let \and \qquad + \let \hva \mpr@hva + \let \@rulename \mpr@empty + \let \@rule@options \mpr@empty + \let \mpr@over \@@over + \mpr@inferrule@} +\newcommand {\mpr@inferrule@}[3][] + {\everymath={\displaystyle}% + \def \@test {#2}\ifx \empty \@test + \setbox0 \hbox {$\vcenter {\mpr@hovbox{B}{#3}}$}% + \else + \def \@test {#3}\ifx \empty \@test + \setbox0 \hbox {$\vcenter {\mpr@hovbox{T}{#2}}$}% + \else + \setbox0 \mpr@fraction {\mpr@hovbox{T}{#2}}{\mpr@hovbox{B}{#3}}% + \fi \fi + \def \@test {#1}\ifx \@test\empty \box0 + \else \vbox +%%% Suggestion de Francois pour les etiquettes longues +%%% {\hbox to \wd0 {\RefTirName {#1}\hfil}\box0}\fi + {\hbox {\RefTirName {#1}}\box0}\fi + \egroup} + +\def \mpr@vdotfil #1{\vbox to #1{\leaders \hbox{$\cdot$} \vfil}} + +% They are two forms +% \inferrule [label]{[premisses}{conclusions} +% or +% \inferrule* [options]{[premisses}{conclusions} +% +% Premisses and conclusions are lists of elements separated by \\ +% Each \\ produces a break, attempting horizontal breaks if possible, +% and vertical breaks if needed. +% +% An empty element obtained by \\\\ produces a vertical break in all cases. +% +% The former rule is aligned on the fraction bar. +% The optional label appears on top of the rule +% The second form to be used in a derivation tree is aligned on the last +% line of its conclusion +% +% The second form can be parameterized, using the key=val interface. The +% folloiwng keys are recognized: +% +% width set the width of the rule to val +% narrower set the width of the rule to val\hsize +% before execute val at the beginning/left +% lab put a label [Val] on top of the rule +% lskip add negative skip on the right +% left put a left label [Val] +% Left put a left label [Val], ignoring its width +% right put a right label [Val] +% Right put a right label [Val], ignoring its width +% leftskip skip negative space on the left-hand side +% rightskip skip negative space on the right-hand side +% vdots lift the rule by val and fill vertical space with dots +% after execute val at the end/right +% +% Note that most options must come in this order to avoid strange +% typesetting (in particular leftskip must preceed left and Left and +% rightskip must follow Right or right; vdots must come last +% or be only followed by rightskip. +% + +%% Keys that make sence in all kinds of rules +\def \mprset #1{\setkeys{mprset}{#1}} +\define@key {mprset}{andskip}[]{\mpr@andskip=#1} +\define@key {mprset}{lineskip}[]{\lineskip=#1} +\define@key {mprset}{flushleft}[]{\mpr@centerfalse} +\define@key {mprset}{center}[]{\mpr@centertrue} +\define@key {mprset}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite} +\define@key {mprset}{atop}[]{\let \mpr@fraction \mpr@@nofraction} +\define@key {mprset}{myfraction}[]{\let \mpr@fraction #1} +\define@key {mprset}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}} +\define@key {mprset}{sep}{\def\mpr@sep{#1}} + +\newbox \mpr@right +\define@key {mpr}{flushleft}[]{\mpr@centerfalse} +\define@key {mpr}{center}[]{\mpr@centertrue} +\define@key {mpr}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite} +\define@key {mpr}{myfraction}[]{\let \mpr@fraction #1} +\define@key {mpr}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}} +\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax + \advance \hsize by -\wd0\box0} +\define@key {mpr}{width}{\hsize #1} +\define@key {mpr}{sep}{\def\mpr@sep{#1}} +\define@key {mpr}{before}{#1} +\define@key {mpr}{lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}} +\define@key {mpr}{Lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}} +\define@key {mpr}{narrower}{\hsize #1\hsize} +\define@key {mpr}{leftskip}{\hskip -#1} +\define@key {mpr}{reduce}[]{\let \mpr@fraction \mpr@@reduce} +\define@key {mpr}{rightskip} + {\setbox \mpr@right \hbox {\unhbox \mpr@right \hskip -#1}} +\define@key {mpr}{LEFT}{\setbox0 \hbox {$#1$}\relax + \advance \hsize by -\wd0\box0} +\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax + \advance \hsize by -\wd0\box0} +\define@key {mpr}{Left}{\llap{$\TirName {#1}\;$}} +\define@key {mpr}{right} + {\setbox0 \hbox {$\;\TirName {#1}$}\relax \advance \hsize by -\wd0 + \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}} +\define@key {mpr}{RIGHT} + {\setbox0 \hbox {$#1$}\relax \advance \hsize by -\wd0 + \setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}} +\define@key {mpr}{Right} + {\setbox \mpr@right \hbox {\unhbox \mpr@right \rlap {$\;\TirName {#1}$}}} +\define@key {mpr}{vdots}{\def \mpr@vdots {\@@atop \mpr@vdotfil{#1}}} +\define@key {mpr}{after}{\edef \mpr@after {\mpr@after #1}} + +\newcommand \mpr@inferstar@ [3][]{\setbox0 + \hbox {\let \mpr@rulename \mpr@empty \let \mpr@vdots \relax + \setbox \mpr@right \hbox{}% + $\setkeys{mpr}{#1}% + \ifx \mpr@rulename \mpr@empty \mpr@inferrule {#2}{#3}\else + \mpr@inferrule [{\mpr@rulename}]{#2}{#3}\fi + \box \mpr@right \mpr@vdots$} + \setbox1 \hbox {\strut} + \@tempdima \dp0 \advance \@tempdima by -\dp1 + \raise \@tempdima \box0} + +\def \mpr@infer {\@ifnextchar *{\mpr@inferstar}{\mpr@inferrule}} +\newcommand \mpr@err@skipargs[3][]{} +\def \mpr@inferstar*{\ifmmode + \let \@do \mpr@inferstar@ + \else + \let \@do \mpr@err@skipargs + \PackageError {mathpartir} + {\string\inferrule* can only be used in math mode}{}% + \fi \@do} + + +%%% Exports + +% Envirnonment mathpar + +\let \inferrule \mpr@infer + +% make a short name \infer is not already defined +\@ifundefined {infer}{\let \infer \mpr@infer}{} + +\def \TirNameStyle #1{\small \textsc{#1}} +\def \tir@name #1{\hbox {\small \TirNameStyle{#1}}} +\let \TirName \tir@name +\let \DefTirName \TirName +\let \RefTirName \TirName + +%%% Other Exports + +% \let \listcons \mpr@cons +% \let \listsnoc \mpr@snoc +% \let \listhead \mpr@head +% \let \listmake \mpr@makelist + + + + +\endinput diff -r 9ea667baf097 -r dbe49327b6c5 slides/pics/ante1.jpg Binary file slides/pics/ante1.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/pics/ante2.jpg Binary file slides/pics/ante2.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/pics/hopper.jpg Binary file slides/pics/hopper.jpg has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/pics/laptop.png Binary file slides/pics/laptop.png has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/pics/servers.png Binary file slides/pics/servers.png has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/slides01.pdf Binary file slides/slides01.pdf has changed diff -r 9ea667baf097 -r dbe49327b6c5 slides/slides01.tex --- a/slides/slides01.tex Wed Aug 07 17:31:42 2013 +0100 +++ b/slides/slides01.tex Tue Sep 24 01:12:36 2013 +0100 @@ -1,7 +1,7 @@ -\documentclass[dvipsnames,14pt,t]{beamer} -\usepackage{beamerthemeplainculight} -\usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc} +\documentclass[dvipsnames,14pt,t,xelatex]{beamer} +\usepackage{beamerthemeplaincu} + \usepackage{fontenc,xltxtra,xunicode} +\defaultfontfeatures{Mapping=tex-text} \usepackage{mathpartir} \usepackage[absolute,overlay]{textpos} \usepackage{ifthen} @@ -9,7 +9,7 @@ \usepackage{pgf} \usepackage{calc} \usepackage{ulem} -\usepackage{courier} +%%\usepackage{courier} \usepackage{listings} \renewcommand{\uline}[1]{#1} \usetikzlibrary{arrows} @@ -25,6 +25,11 @@ \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc +\makeatletter +\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}} +\@empty\z@\@empty +\makeatother + \lstset{language=Java, basicstyle=\ttfamily, keywordstyle=\color{javapurple}\bfseries, @@ -96,7 +101,7 @@ \begin{center} \begin{tabular}{ll} Email: & christian.urban at kcl.ac.uk\\ - Of$\!$fice: & S1.27 (1st floor Strand Building)\\ + Office: & S1.27 (1st floor Strand Building)\\ Slides: & KEATS \end{tabular} \end{center} @@ -196,7 +201,7 @@ \frametitle{\begin{tabular}{c}This Course\end{tabular}} \begin{itemize} -\item the ultimate goal is to implement a small web-browser (really small one)\bigskip +\item the ultimate goal is to implement a small compiler (really small one)\bigskip \end{itemize} Let's start with: @@ -255,7 +260,7 @@ \footnotesize a simple Scala function for reading webpages\\[-3mm] {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app0.scala}}}\pause +\texttt{\lstinputlisting{../progs/app0.scala}}}\pause {\lstset{language=Scala}\fontsize{8}{10}\selectfont \texttt{\lstinline{get_page("""http://www.inf.kcl.ac.uk/staff/urbanc/""")}}}\pause\bigskip @@ -264,7 +269,7 @@ \footnotesize {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app1.scala}}} +\texttt{\lstinputlisting{../progs/app1.scala}}} \end{frame}} @@ -318,7 +323,7 @@ \begin{frame}[c] {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app2.scala}}}\medskip +\texttt{\lstinputlisting{../progs/app2.scala}}}\medskip {\lstset{language=Scala}\fontsize{8}{10}\selectfont \texttt{crawl(some\_start\_URL, 2)}}\ @@ -334,7 +339,7 @@ a version that only ``crawls'' links in my domain: {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app3.scala}}} +\texttt{\lstinputlisting{../progs/app3.scala}}} \end{frame}} @@ -348,7 +353,7 @@ a little email ``harvester'': {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app4.scala}}}\bigskip +\texttt{\lstinputlisting{../progs/app4.scala}}}\bigskip \tiny \textcolor{gray}{\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/}} @@ -388,7 +393,7 @@ {\lstset{language=Scala}\fontsize{8}{10}\selectfont -\texttt{\lstinputlisting{app51.scala}}} +\texttt{\lstinputlisting{../progs/app51.scala}}} \end{frame}}