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

2008-03-27 Thread Paul Keir
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.

Cheers,
Paul

-Original Message-
From: Brandon S. Allbery KF8NH [mailto:[EMAIL PROTECTED] 
Sent: 26 March 2008 11:48
To: haskell-cafe@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] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-03-26 Thread Paul Keir
Hi,

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,
Paul
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-03-26 Thread Bulat Ziganshin
Hello Paul,

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


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-03-26 Thread Andrew Coppin

Paul Keir wrote:


Hi,

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.




If you mean Text.ParserCombinators.Parsec.Token, can't you just change 
the setting of whiteSpace in TokenParser?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-03-26 Thread Brandon S. Allbery KF8NH


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] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe