-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmonadic-parsing.tex
115 lines (90 loc) · 2.81 KB
/
monadic-parsing.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
% Kompilieren mit: TEXINPUTS=minted/source: xelatex -shell-escape %
\documentclass[12pt,compress,ngerman,utf8,t]{beamer}
\usepackage[ngerman]{babel}
\usepackage{comment}
\usepackage{minted}
\setminted{linenos}
\usepackage[protrusion=true,expansion=false]{microtype}
\DeclareSymbolFont{extraup}{U}{zavm}{m}{n}
\DeclareMathSymbol{\varheart}{\mathalpha}{extraup}{86}
\DeclareMathSymbol{\vardiamond}{\mathalpha}{extraup}{87}
\title{Monadische Parserkombinatoren}
\author[Curry Club Augsburg]{\texorpdfstring{
\includegraphics[scale=0.26]{images/regex} \\[0.7em]
\scriptsize Ingo Blechschmidt \\\texttt{<[email protected]>}
}{Ingo Blechschmidt}}
\date{23. April 2015}
\usetheme{Warsaw}
\useinnertheme{rectangles}
\usecolortheme{seahorse}
\definecolor{mypurple}{RGB}{150,0,255}
\setbeamercolor{structure}{fg=mypurple}
\usefonttheme{serif}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Linux Libertine O}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{headline}{}
\setbeamertemplate{title page}[default][colsep=-1bp,rounded=false,shadow=false]
\setbeamertemplate{frametitle}[default][colsep=-2bp,rounded=false,shadow=false,center]
\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
\oldmacro\hfill\insertframenumber\,/\,\inserttotalframenumber\hfill}
\newcommand{\hil}[1]{{\usebeamercolor[fg]{item}{\textbf{#1}}}}
\begin{document}
\frame{\titlepage}
\begin{frame}[fragile]\frametitle{Ziel: S-Ausdr"ucke parsen}
\begin{minted}{haskell}
data Exp = Atom String | List [Exp]
-- Eingabe:
(+ 1 (* 2 3) (* 4 5))
-- Syntaxbaum:
List
[ Atom "+"
, Atom "1"
, List [ Atom "*", Atom "2", Atom "3" ]
, List [ Atom "*", Atom "4", Atom "5" ]
]
\end{minted}
\end{frame}
\begin{frame}[fragile]\frametitle{Ziel: S-Ausdr"ucke parsen}
\begin{minted}{haskell}
data Exp = Atom String | List [Exp]
parseExp :: Parser Exp
parseExp = choice [ parseSymbol, parseList ]
parseSymbol :: Parser Exp
parseSymbol =
fmap Atom $ many1 alphaNum `andThen` spaces
parseList :: Parser Exp
parseList = do
token "("
elems <- many parseExp
token ")"
return $ List elems
\end{minted}
\end{frame}
\begin{frame}
\begin{center}
% http://learnyouahaskell.com/introduction
\includegraphics[scale=0.5]{images/bird}
\huge
Live-Coding
\bigskip
\large
\texttt{\$ vim parsen-macht-spa"s.hs}
\end{center}
\end{frame}
\begin{frame}\frametitle{Was fehlt noch?}
\begin{itemize}
\item Unsere naive Bibliothek leckt Speicher.
\item Wir geben keine guten Parse-Fehlermeldungen aus.
\item Wir haben keine Kombinatoren zum Parsen von Termen mit Operatoren.
\end{itemize}
\end{frame}
\begin{frame}
\begin{center}
\includegraphics[scale=0.4]{images/monadic-parser-combinators.jpeg}
\end{center}
\end{frame}
\end{document}