updated
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 10 Nov 2015 22:27:46 +0000
changeset 368 a9911966c0df
parent 367 04127a5aad23
child 369 43c0ed473720
updated
graphics.sty
progs/token2.scala
slides.sty
slides/slides06.pdf
slides/slides06.tex
--- a/graphics.sty	Sat Nov 07 21:37:03 2015 +0000
+++ b/graphics.sty	Tue Nov 10 22:27:46 2015 +0000
@@ -9,9 +9,11 @@
 \usepackage{graphicx} 
 \usepackage{pgfplots}
 
+
 \newenvironment{bubble}[1][]{%
-\begin{tikzpicture}%
+\addtolength{\leftmargini}{4mm}%
+\begin{tikzpicture}[baseline=(current bounding box.north)]%
 \draw (0,0) node[inner sep=2mm,fill=cream,ultra thick,draw=red,rounded corners=2mm]% 
 \bgroup\begin{minipage}{#1}\raggedright{}}
 {\end{minipage}\egroup;%
-\end{tikzpicture}}
+\end{tikzpicture}\bigskip}
--- a/progs/token2.scala	Sat Nov 07 21:37:03 2015 +0000
+++ b/progs/token2.scala	Tue Nov 10 22:27:46 2015 +0000
@@ -12,6 +12,7 @@
 case class RECD(x: String, r: Rexp) extends Rexp
 case class CRANGE(cs: String) extends Rexp
 case class PLUS(r: Rexp) extends Rexp
+case class OPT(r: Rexp) extends Rexp
 
 abstract class Val
 case object Empty extends Val
@@ -57,6 +58,7 @@
   case RECD(_, r) => nullable(r)
   case CRANGE(_) => false
   case PLUS(r) => nullable(r)
+  case OPT(_) => true
 }
 
 // derivative of a regular expression w.r.t. a character
@@ -72,6 +74,7 @@
   case RECD(_, r1) => der(c, r1)
   case CRANGE(cs) => if (cs.contains(c)) EMPTY else NULL
   case PLUS(r) => SEQ(der(c, r), STAR(r))
+  case OPT(r) => ALT(der(c, r), NULL)
 }
 
 // derivative w.r.t. a string (iterates der)
@@ -111,6 +114,7 @@
   case STAR(r) => Stars(Nil)
   case RECD(x, r) => Rec(x, mkeps(r))
   case PLUS(r) => Stars(List(mkeps(r)))
+  case OPT(_) => Right(Empty)
 }
 
 
@@ -125,6 +129,7 @@
   case (CRANGE(_), Empty) => Chr(c) 
   case (RECD(x, r1), _) => Rec(x, inj(r1, c, v))
   case (PLUS(r), Seq(v1, Stars(vs))) => Stars(inj(r, c, v1)::vs)
+  case (OPT(r), Left(v1)) => Left(inj(r, c, v1))
 }
 
 // main lexing function (produces a value)
@@ -137,6 +142,8 @@
 
 lexing(("ab" | "ab") ~ ("b" | EMPTY), "ab")
 
+lexing(OPT("ab"), "ab")
+
 // some "rectification" functions for simplification
 def F_ID(v: Val): Val = v
 def F_RIGHT(f: Val => Val) = (v:Val) => Right(f(v))
@@ -200,6 +207,8 @@
 
 lexing_simp(("a" | "ab") ~ ("b" | ""), "ab")
 
+lexing_simp(OPT("ab"), "ab")
+
 // Lexing Rules for a Small While Language
 
 val SYM = CRANGE("abcdefghijklmnopqrstuvwxyz")
--- a/slides.sty	Sat Nov 07 21:37:03 2015 +0000
+++ b/slides.sty	Tue Nov 10 22:27:46 2015 +0000
@@ -35,7 +35,7 @@
 \begin{tabular}{@{}c@{}}%
 \insertframetitle%
 \end{tabular}%
-\end{minipage}}%
+\end{minipage}\vspace{-10pt}}%
 }
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -58,6 +58,7 @@
 \setlength\leftmargini{2mm}
 \setlength\leftmarginii{0.6cm}
 \setlength\leftmarginiii{1.5cm}
+\setbeamertemplate{itemize/enumerate body end}{\vspace{-2mm}}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % blocks
Binary file slides/slides06.pdf has changed
--- a/slides/slides06.tex	Sat Nov 07 21:37:03 2015 +0000
+++ b/slides/slides06.tex	Tue Nov 10 22:27:46 2015 +0000
@@ -392,7 +392,6 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\mode<presentation>{
 \begin{frame}[c]
 \frametitle{\begin{tabular}{c}$\epsilon$-Removal\end{tabular}}
 
@@ -432,7 +431,7 @@
 \end{tabular}}
 
 \end{center}
-\end{frame}}
+\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%