7172aa29c6a1a279836446129c68a72e472ee87d
[cc1516.git] / deliverables / report / pars.tex
1 \section{Lexing \& parsing}\label{sec:pars}
2 \subsection{\Yard}
3 For both lexing and parsing we use proof of concept state of the art minimal
4 parser combinators library called \Yard. \Yard{} is inspired by the well-known
5 \textsc{Parsec} library. Where \Yard{} only has 9 parser combinators
6 \textsc{Parsec} already has 9 categories of parser combinators with in every
7 category there are numerous combinators.
8
9 \begin{lstlisting}[language=Clean]
10 :: Error = PositionalError Int Int String | Error String
11 :: Parser a b = Parser ([a] -> (Either Error b, [a]))
12
13 (<?>) :: (Parser a b) Error -> Parser a b
14 fail :: Parser a b
15 top :: Parser a a
16 peek :: Parser a a
17 satisfy :: (a -> Bool) -> Parser a a
18 check :: (a -> Bool) -> Parser a a
19 (until) infix 2 :: (Parser a b) (Parser a c) -> Parser a [b]
20 item :: a -> Parser a a | Eq a
21 list :: [a] -> Parser a [a] | Eq a
22 eof :: Parser a Void
23 \end{lstlisting}
24
25 \subsection{Lexing}
26
27 \subsection{Parsing}
28 %On March 10 you have to give a very brief presentation. In this presentation you tell the other
29 %students and us how your parser is constructed and demonstrate your parser and pretty printer.
30 %You should mention things like implementation language used, changes to the grammar, and other
31 %interesting points of your program.
32 %For this demonstration you have to prepare at least 10 test programs in
33 %SPL
34 %. In your presentation
35 %you have to show only the most interesting or challenging example. You can use the program
36 %4
37 %above as a starting point. Hand in the test programs, and a document containing the transformed
38 %grammar as used by your parser. Indicate what parts of the semantic analysis are handled by your
39 %scanner