[Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters
seancormican1 at gmail.com
Sat Mar 2 17:57:14 CET 2013
I'm working with expressions in which I use parsec libraries lexeme
parsers: identifier, integer, whiteSpace etc.
I am attempting to parse haskell declarations and I am facing some
difficulty when trying to delimit the declarations which span multiple
lines using eol character for some reason ( I am led to believe is due to
the removal of whitespace with lexemes )
data Express = Seq [Express]
| ID String
| Num Integer
| BoolConst Bool
| EmptyList String
do list <- (sepBy1 expr8 eol)
return $ if length list == 1 then head list else Seq list
where Seq list is a data declaration for a list of expression8's
The parser works correctly unless trying to parse a lexeme parser token
such as an identifier. Upon reading a lexeme token the parser will stop and
output all tokens up until and including that token but no tokens past it.
Also when trying to separate declarations that span multiple lines, does
anyone have an idea on how to achieve this? I have been thinking that the
parser should ignore any end line characters that are followed by
whitespace ( as whitespace is used in Haskell layout rules )
Any thoughts on how I might solve this would be greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners