7 \frametitle{\textsc{SPL
}}
8 \begin{block
}{Features
}
10 \item Implementation language:
11 Clean (
{\tiny\url{http://clean.cs.ru.nl
}})
15 \item Higher order functions
17 \item Using parser combinator library
\textsc{Yard
}
20 \item Positional data available for easy locating of errors.
22 \item Standardized parser errors. This means you can set it as
23 \texttt{buildprg
} in
\texttt{vim
} and you can then use the
29 \begin{frame
}[fragile
]
30 \frametitle{\textsc{YARD
}}
31 \framesubtitle{A minimal home grown monadic parser combinator library
}
33 \item Inspired by
\textsc{parsec
}: $
1pc=
3.375\cdot10^
{16}yd$~
\footnote{
34 A yard is exactly $
36$ inch and an inch is exactly the length
38 :: Error = PositionalError Int Int String | Error String
39 :: Parser a b = Parser (
[a
] -> (Either Error b,
[a
]))
42 \item Result is either Error or
\texttt{b
}, not a
\texttt{[b
]} as
43 described Hutton \& Meijer
\footnote{G. Hutton and E. Meijer.
44 Monadic parser combinators.
1996.
}
46 \item Matches longest left-most parser
48 \item Stops immediately on error
\pause\\
53 \begin{frame
}[fragile
]
54 \frametitle{\textsc{YARD
} Combinators
}
55 \framesubtitle{Designed to be minimal, just
14 parsers/combinators
}
56 YARD is designed to be minimal and defines just
14 primitives:
58 \begin{column
}{0.5\textwidth}
64 (until) :: (Parser a b)
67 satisfy :: (a -> Bool)
71 item :: a -> Parser a a
72 list ::
[a
] -> Parser a
[a
]
75 \begin{column
}{0.5\textwidth}
87 optional :: (Parser a b)
94 \begin{frame
}[fragile
]
95 \frametitle{\textsc{YARD
} Combinators
}
96 \framesubtitle{Designed to be minimal, just
\textbf{7} parsers/combinators
}
97 Actually, scrap that, just
\textbf{7} primitives:
99 \begin{column
}{0.5\textwidth}
107 \begin{column
}{0.5\textwidth}
109 (>>=) :: (Parser a b)
112 (<|>) :: (Parser a b)
118 All others can be (and are) derived from these. e.g.
120 satisfy :: (a -> Bool) -> Parser a a
121 satisfy f = top >>=
\c -> if (f c) (return c) fail
125 \section{Design choices
}
127 \frametitle{Adapting the grammar
}
129 \item Remove left recursion
130 \item Fixing associativity
131 \item Added small features such as escape characters
\texttt{
132 \textbackslash n
\textbackslash b
}
134 \item Show grammar now
\ldots
139 \frametitle{Two-phase design
}
140 \framesubtitle{Lexing
}
141 Also done with
\textsc{YARD
} because
143 \item Multiline comments
149 \begin{frame
}[fragile
]
150 \frametitle{Two-phase design
}
151 \framesubtitle{Parsing
}
152 Read from stdin, write to stdout\\
153 Added some handy primitives
155 parseBlock :: Parser Token
[Stmt
]
157 parseOpR :: (Parser Token Op2) (Parser Token Expr) -> Parser Token Expr
158 parseOpL :: (Parser Token Op2) (Parser Token Expr) -> Parser Token Expr
160 trans2 :: TokenValue (TokenValue -> a) -> Parser Token a
161 trans1 :: TokenValue a -> Parser Token a
163 peekPos :: Parser Token Pos
167 \begin{frame
}[fragile
]
168 \frametitle{Statistics
}
169 \framesubtitle{Lines of code
}
170 \lstinputlisting{|"wc -l ../../*.
[di
]cl"
}
173 \emph{``Measuring programming progress by lines of code is like
174 measuring aircraft building progress by weight.''
}\\
180 \frametitle{Statistics
}
181 \framesubtitle{Hours of work
}
182 We have no clue how much time we have worked on it
\ldots
185 \emph{``Choose a job you love, and you will never have to work a day in
193 \frametitle{Weird inputs
}
195 \item \pause Heap full
196 \pause\ldots Increase heap\\
197 \texttt{\$ ./spl -h
2000M
}
198 \item \pause Stack full
199 \pause\ldots Increase stack\\
200 \texttt{\$ ./spl -s
200M
}
201 \item \pause Segmentation fault
202 \pause\ldots Enable memory overcommitting\\
203 \texttt{\# echo
1 > /proc/sys/vm/overcommit
\_memory}
204 \item \pause Still segmentation fault
205 \pause\ldots Buy more
\textsc{RAM
}
206 \item \pause Still segmentation fault?
207 \pause\ldots Divide into modules and parse separatly~
\footnote{To be
209 \item \pause Thus, we are only limited by hardware
\ldots
214 \frametitle{Learned lessons
}
216 \item \pause Parser combinators are elegant!
217 \item \pause Positional errors are a must!