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

Paul Keir pkeir at dcs.gla.ac.uk
Thu Mar 27 06:38:20 EDT 2008

Thankyou all. Once I get more familiar with Parsec I might do my own
lexeme parser. For now I've changed its definition of "simpleSpace" to 

simpleSpace =
   skipMany1 (satisfy (\c -> (c /= '\n') && (isSpace c)))

so that it skips whitespace, but not newlines. My parser then explicitly
matches newlines whenever I need to.


-----Original Message-----
From: Brandon S. Allbery KF8NH [mailto:allbery at ece.cmu.edu] 
Sent: 26 March 2008 11:48
To: haskell-cafe at haskell.org Cafe; Paul Keir
Subject: Re: [Haskell-cafe] No newlines in the whitespace for Parsec
lexeme parsers

On Mar 26, 2008, at 7:42 , Bulat Ziganshin wrote:
> Wednesday, March 26, 2008, 2:32:53 PM, you wrote:
>>  I'm looking to parse a Fortran dialect using Parsec, and was
> afair, some months ago BASIC parsing was discussed here.
> the first solution one can imagine is to add preprocessing stage
> replacing line ends with ';'-alike

FWIW I just ignored the lexeme parser and did my own on top of the  
basic Parsec primitives.

You may need to do that anyway if you want to support older variants  
of Fortran, which don't actually have keywords and ignore spaces  
outside of string constants (Hollerith constants) --- Parsec's lexeme  
stuff doesn't even pretend to support this.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list