Re: Haskell Parser in Hugs

1999-07-27 Thread Manuel M. T. Chakravarty

[EMAIL PROTECTED] (Martin Erwig) wrote,

 I am wondering what is the best way (in terms of
 easy-to-use and easy-to-install) to use a parser
 for Haskell in Hugs. As far as I know the parsers
 by Sven Panne and Manuel Chakravarty require ghc.

I didn't write a parser for parsing Haskell - I only wrote a
parser and lexer library for writing parsers in Haskell.
Sven and Sigbjorn(?)'s parser is not complete yet, as far as
I know.  Unfortunately, infix declarations etc make it quite
a hassle to write a parser for Haskell and to be honest, I
doubt that you get it to work in Hugs with reasonable
efficiency (maybe if you carefully hand code it)[1] - a
Happy-generated parser will definitely get too big.

However, what may be interesting is that Roman Lechtchinsky
[EMAIL PROTECTED] is currently implementing a parser
for at least a subset of Haskell using my libraries[2].
While he is working with GHC, there is nothing fundamental,
I believe, which would prevent you from using his code in
Hugs (apart from maybe the efficiency)[3].  The parser
library needs one non-standard feature (existential type
variables), but you have this in GHC and Hugs.

 In any case, wouldn't it be a good idea to include
 with each Haskell implementation a module "AST"
 that defines a representation of Haskell programs
 and offers functions like "parse" and "print"?

Would be cool.  Ideal would be a whole meta-programming
library, but its a lot of work, I believe.

Cheers,

Manuel

PS: If anybody ever needs a parser for C implemented in
Haskell, that's something where I could help out.


[1] "With reasonble efficiency" here means taking less than
5 minutes for a 10 line program (if you manage not to
run out of memory, that is).

[2] shameless plug
  There is now a paper on the self-optimising lexer
  library at

http://www.score.is.tsukuba.ac.jp/~chak/papers/Cha99.html
/shameless plug

[3] The whole Compiler Toolkit tries to be as portable as
possible, which means all system-dependent code is
located in a single module and only uses features, which
I expect - in one way or another - to be available in
any Haskell system.





Re: Haskell Parser in Hugs

1999-07-27 Thread Sven Panne

Simon Marlow wrote:
 [EMAIL PROTECTED] (Martin Erwig) wrote,
  I am wondering what is the best way (in terms of  easy-to-use and
  easy-to-install) to use a parser for Haskell in Hugs. [...]
 
 Our Haskell parser library works fine with Hugs: [...] It's not quite
 complete (it doesn't do fixity resolution, for example), it'll
 probably do what you want.  This parser was the prequel to GHC's new
 Happy-based parser.

A possible route to get a "real-world" (i.e. well debugged and
complete H98) module AST would be:

   * Throw all files needed by GHC's parser together in a subdir.

   * Remove everything GHC-specific, e.g. lexing the .hi stuff.

   * Track changes to the relevant sources in the CVS in AST. This
 should be very tedious, because those parts of GHC are quite
 stable by now.

The only tricky point is dealing correctly with infix ops in the
presence of the module system. Any *easy* suggestions for this?

Perhaps if I have some spare time... (Hmmm, not very probable at the
moment, the weather in Munich is too nice... :-)   But I wouldn't mind
if somebody else volunteered.

Cheers,
   Sven
-- 
Sven PanneTel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen  Oettingenstr. 67
mailto:[EMAIL PROTECTED]D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne





Re: Haskell Parser in Hugs

1999-07-27 Thread Marko Schuetz

 "Martin" == Martin Erwig [EMAIL PROTECTED] writes:

Martin I am wondering what is the best way (in terms of
Martin easy-to-use and easy-to-install) to use a parser
Martin for Haskell in Hugs. As far as I know the parsers
Martin by Sven Panne and Manuel Chakravarty require ghc.

There is also `lucky`, a parser generator using parser
combinators. It's compatible with happy 0.9, but the resulting parsers
are much smaller. A `lucky` file for Haskell 1.3 is available (it's
part of Norbert Kloses masters thesis). You can find it in
http://www.ki.informatik.uni-frankfurt.de/persons/marko/marko.html

Marko





Re: Haskell Parser in Hugs

1999-07-26 Thread Malcolm Wallace

 I am wondering what is the best way (in terms of
 easy-to-use and easy-to-install) to use a parser
 for Haskell in Hugs. As far as I know the parsers
 by Sven Panne and Manuel Chakravarty require ghc.

You could try using the parser from nhc98, written using
space-efficient parser combinators.

ftp://ftp.cs.york.ac.uk/pub/haskell/parsepp

I have stripped out almost everything except the parser and
pretty-printer (this one should really be called an ugly-printer).
See the README, and Main.hs.


Regards,
Malcolm

P.S.  With the help of dependencies generated automatically by hmake,
  creating and testing this package with hugs took about 15 minutes.