Parsing Haskell

View: New views
8 Messages — Rating Filter:   Alert me  

Parsing Haskell

by Eric-175 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Parsing Haskell

by John A. De Goes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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@...
> http://www.haskell.org/mailman/listinfo/haskell-cafe

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

Re: Parsing Haskell

by Simon Marlow-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


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

Re: Re: Parsing Haskell

by Niklas Broberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: Parsing Haskell

by S. Doaitse Swierstra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> http://www.haskell.org/mailman/listinfo/haskell-cafe

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

Re: Parsing Haskell

by Eric-175 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
>>http://www.haskell.org/mailman/listinfo/haskell-cafe

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

Parent Message unknown Re: Re: Parsing Haskell

by Eric-175 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It has indeed reached me. Thanks!

At 16:23 06/11/2009, Niklas Broberg wrote:

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

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

Re: Parsing Haskell

by Malcolm Wallace :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> The UHC compiler contains a combinator based Haskell parser from  
> which you can borrow fragments,

... and the nhc98/yhc compiler likewise has a combinator parser for  
full Haskell'98 (the combinators are in applicative style).

Regards,
    Malcolm

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