On Wed, Feb 20, 2013 at 1:09 AM, Sean Cormican seancormic...@gmail.comwrote:
Thanks that is exactly what I was looking for, one further question I
might ask is how I might allow for either a integer or a string to be
parsed. As it is now I get a complaint if I try and parse either a String
or
Thanks that is exactly what I was looking for, one further question I might
ask is how I might allow for either a integer or a string to be parsed. As
it is now I get a complaint if I try and parse either a String or an
Integer without creating a data declaration for say Express containing:
data
I have been trying to create a parser for a functional programming
language, but there is no need to create an AST but merely check that the
code is valid according to the grammar.
In the following tutorial I have been trying to take some pointers from,
data declarations are used to create an AST
If all you want to do is check that the code is valid (i.e., you aren't
going to interpret the code), you can just return a Bool. If you want to
interpret it, but don't want to have a Stmt type, you can return IO ()
actions. In that case, the parser's type will be
Parser (IO ())
I think an
Come to think of it, a parsec parser already wraps over Either, so if all
you want to do is check if a result is valid, you can abuse the Either
semantics so that your type is:
Parser () -- the parser which returns nothing on success or an error on
failure.
On Tue, Feb 19, 2013 at 3:20 PM,