diff -r 6ee22f196884 -r 451a95e1bc25 handouts/ho06.tex --- a/handouts/ho06.tex Wed Oct 24 13:07:13 2018 +0100 +++ b/handouts/ho06.tex Wed Oct 24 16:03:07 2018 +0100 @@ -85,7 +85,7 @@ grammar for arithmetic expressions we might be interested in the actual integer number the arithmetic expression, say \texttt{1 + 2 * 3}, stands for. In this way we can use parser combinators to -implement relativaley easily a calculator. +implement relatively easily a calculator. The main idea of parser combinators is that we can easily build parser combinators out of smaller components following very closely the @@ -230,7 +230,7 @@ \end{center} \noindent Later on we will use again Scala mechanism for introducing some -more readable shorthand notation for this, like \texttt{"a" || "b"}. Let us look in detail at what this parser combinator produces with some somple strings +more readable shorthand notation for this, like \texttt{"a" || "b"}. Let us look in detail at what this parser combinator produces with some sample strings \begin{center} \begin{tabular}{rcl} @@ -314,7 +314,7 @@ \end{center} \noindent Later on we will use again Scala mechanism for introducing some -more readable shorthand notation for this, like \texttt{"a" || "b"}. Let us look in detail at what this parser combinator produces with some somple strings +more readable shorthand notation for this, like \texttt{"a" || "b"}. Let us look in detail at what this parser combinator produces with some sample strings \begin{center} \begin{tabular}{rcl} @@ -353,7 +353,7 @@ unprocessed parts of both parsers is the unprocessed parts the second parser $q$ produces as left-over. The processed parts of both parsers is just the pair of the outputs -$(\textit{output}_1, \textit{output}_2)$. This behavious can be +$(\textit{output}_1, \textit{output}_2)$. This behaviour can be implemented in Scala as follows: \begin{center} @@ -393,7 +393,7 @@ the empty set, then \texttt{parse} will also produce the empty set. Notice that we have now two output types for the sequence parser combinator, because in general \textit{p} and \textit{q} might produce -differetn things (for example first we recognise a number and then a +different things (for example first we recognise a number and then a string corresponding to an operator). @@ -413,13 +413,13 @@ \end{tabular} \end{center} -\noindent In the first line we have a sucessful parse, because the +\noindent In the first line we have a successful parse, because the string started with \texttt{ab}, which is the prefix we are looking for. But since the parsing combinator is constructed as sequence of the two simple (atomic) parsers for \texttt{a} and \texttt{b}, the result is a nested pair of the form \texttt{((a, b), cde)}. It is -\emph{not} a simple pair \texttt{(ab, cde)} as one might errorneously -expects. The parser returns the ampty set in the other examples, +\emph{not} a simple pair \texttt{(ab, cde)} as one might erroneously +expects. The parser returns the empty set in the other examples, because they do not fit with what the parser is supposed to parse.