# HG changeset patch # User Christian Urban # Date 1383104680 0 # Node ID fa187fa5b64233886f8cdeb04d14f532eb6f9270 # Parent 57df3d7b4a25eeca8113e4d58694c7beccd92c59 added slides diff -r 57df3d7b4a25 -r fa187fa5b642 progs/app8.scala --- a/progs/app8.scala Wed Oct 30 03:36:10 2013 +0000 +++ b/progs/app8.scala Wed Oct 30 03:44:40 2013 +0000 @@ -1,3 +1,9 @@ +class AltParser[I, T](p: => Parser[I, T], + q: => Parser[I, T]) + extends Parser[I, T] { + def parse(sb: I) = p.parse(sb) ++ q.parse(sb) +} + class SeqParser[I, T, S](p: => Parser[I, T], q: => Parser[I, S]) extends Parser[I, (T, S)] { @@ -7,14 +13,8 @@ yield ((head1, head2), tail2) } -class AltParser[I, T](p: => Parser[I, T], - q: => Parser[I, T]) - extends Parser[I, T] { - def parse(sb: I) = p.parse(sb) ++ q.parse(sb) -} - class FunParser[I, T, S](p: => Parser[I, T], f: T => S) - extends Parser[I, S] { + extends Parser[I, S] { def parse(sb: I) = for ((head, tail) <- p.parse(sb)) yield (f(head), tail) diff -r 57df3d7b4a25 -r fa187fa5b642 slides/slides06.pdf Binary file slides/slides06.pdf has changed diff -r 57df3d7b4a25 -r fa187fa5b642 slides/slides06.tex --- a/slides/slides06.tex Wed Oct 30 03:36:10 2013 +0000 +++ b/slides/slides06.tex Wed Oct 30 03:44:40 2013 +0000 @@ -152,6 +152,21 @@ \end{frame}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\mode{ +\begin{frame}[c] +\frametitle{\begin{tabular}{c}Regular Languages\end{tabular}} + +While regular expressions are very useful for lexing, +there is no regular expression that can recognise the language \bl{$a^nb^n$}.\bigskip + +\begin{center} +\bl{$(((()()))())$} \;\;vs.\;\; \bl{$(((()()))()))$} +\end{center} + + +\end{frame}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\qq}{\mbox{\texttt{"}}} @@ -649,7 +664,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode{ \begin{frame}[c] -\frametitle{Abstract Parsers} +\frametitle{Abstract Parser Class} \mbox{\lstset{language=Scala}\fontsize{10}{12}\selectfont \texttt{\lstinputlisting{../progs/app7.scala}}}