[Haskell-cafe] No newlines in the whitespace for Parsec lexeme parsers

Paul Keir pkeir at dcs.gla.ac.uk
Wed Mar 26 07:32:53 EDT 2008


I'm looking to parse a Fortran dialect using Parsec, and was hoping to use the ParsecToken module. Fortran though is unlike the Parsec examples, and prohibits default line continuation (requiring instead an explicit ampersand token &). The lexical parsers of the ParsecToken module skip whitespace after each symbol parsed (lexeme parsers); including the newline.

I was thinking of making a minor change to Parsec: In Token.hs, lexeme, whiteSpace, and simpleSpace are defined. lexeme uses whiteSpace which uses simpleSpace. simpleSpace is defined:

simpleSpace = skipMany1 (satisfy isSpace)

I could replace this locally with:

simpleSpace = skipMany1 (satisfy isSpacePlusAmpersandMinusNewline)

This approach may have other problems though. Has anyone experience of using Parsec to parse such a language? For example assembly or a preprocessor?

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080326/954a535b/attachment-0001.htm

More information about the Haskell-Cafe mailing list