1 \section{Lexing \& parsing
}\label{sec:pars
}
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.
9 \begin{lstlisting
}[language=Clean
]
10 :: Error = PositionalError Int Int String | Error String
11 :: Parser a b = Parser (
[a
] -> (Either Error b,
[a
]))
13 (<?>) :: (Parser a b) Error -> Parser a b
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
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
34 %. In your presentation
35 %you have to show only the most interesting or challenging example. You can use the program
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