
Hi all, I was hoping to use Language.Haskell.Parser to parse fragments of Haskell code. However, it appears that one can only use this module to parse complete Haskell programs. Is there anyway around this, or must I write a Haskell parser from scratch? Eric M.

You need a bottom-up parser to do fragment parsing. I'm not sure one exists for Haskell. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Nov 6, 2009, at 7:49 AM, Eric Macaulay wrote:
Hi all,
I was hoping to use Language.Haskell.Parser to parse fragments of Haskell code. However, it appears that one can only use this module to parse complete Haskell programs. Is there anyway around this, or must I write a Haskell parser from scratch?
Eric M.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 06/11/2009 15:17, John A. De Goes wrote:
You need a bottom-up parser to do fragment parsing. I'm not sure one exists for Haskell.
In Happy you can define multiple entry points to a grammar, which is how GHCi parses statements using the same parser that is used to parse complete modules. You'd have to modify the parser in haskell-src(-exts) to do add the entry points, though. Cheers, Simon

You'd have to modify the parser in haskell-src(-exts) to do add the entry points, though.
Actually haskell-src-exts already defines entry points for Module, Stmt, Exp, Pat and Type (as well as [Module] in 1.3.x). Not sure if this message reaches the original poster though. Cheers, /Niklas

The UHC compiler contains a combinator based Haskell parser from which you can borrow fragments, Doaitse Swierstra On 6 nov 2009, at 15:49, Eric Macaulay wrote:
Hi all,
I was hoping to use Language.Haskell.Parser to parse fragments of Haskell code. However, it appears that one can only use this module to parse complete Haskell programs. Is there anyway around this, or must I write a Haskell parser from scratch?
Eric M.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks, I'll check it out. At 22:03 06/11/2009, S. Doaitse Swierstra wrote:
The UHC compiler contains a combinator based Haskell parser from which you can borrow fragments,
Doaitse Swierstra
On 6 nov 2009, at 15:49, Eric Macaulay wrote:
Hi all,
I was hoping to use Language.Haskell.Parser to parse fragments of Haskell code. However, it appears that one can only use this module to parse complete Haskell programs. Is there anyway around this, or must I write a Haskell parser from scratch?
Eric M.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (6)
-
Eric Macaulay
-
John A. De Goes
-
Malcolm Wallace
-
Niklas Broberg
-
S. Doaitse Swierstra
-
Simon Marlow