[Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters
Brent Yorgey
byorgey at seas.upenn.edu
Sat Mar 2 18:33:20 CET 2013
Hi Sean,
I haven't read your entire message carefully, but I read "I am
attempting to parse Haskell declarations" and I would like to ask: is
there a reason you cannot/do not want to use the 'haskell-src-exts'
package?
-Brent
On Sat, Mar 02, 2013 at 04:57:14PM +0000, Sean Cormican wrote:
> Hi,
>
> 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
>
> seqOfExpr8 =
> 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!
>
> Seán
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list