Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread Lennart Augustsson
Implementing exactly Haskell's rule for indentation is incredibly hard. In fact, no known Haskell compiler gets it right. But if you make a slightly simpler one, it's easy. The simple one is the one based only on indentation. There are different ways you can do this. For instance, you can

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread Neil Brown
Bas van Gijzel wrote: Hello everyone, I'm doing a bachelor project focused on comparing parsers. One of the parser libraries I'm using is Parsec (2) and I'm going to implement a very small subset of haskell with it, with as most important feature the off-side rule (indentation based parsing)

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread Bas van Gijzel
Hey, Thanks for the help thusfar. These are interesting suggestions, and I think the occam-pi compiler would help a bit as example. I'll force myself to learn some more about the state monad, but I haven't found really good examples except in Real World Haskell until now so I hope I'll manage.

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread S. Doaitse Swierstra
As Lennart said, the complete offside rule as found in Haskell is almost impossible to get right. This is mainly due to the way in which it is formulated: in terms of error correction. This makes it very difficult to build a parser for such rules which have error correction built into

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread Bernie Pope
2009/4/28 Bas van Gijzel neneko...@gmail.com I'm doing a bachelor project focused on comparing parsers. One of the parser libraries I'm using is Parsec (2) and I'm going to implement a very small subset of haskell with it, with as most important feature the off-side rule (indentation based

[Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Bas van Gijzel
Hello everyone, I'm doing a bachelor project focused on comparing parsers. One of the parser libraries I'm using is Parsec (2) and I'm going to implement a very small subset of haskell with it, with as most important feature the off-side rule (indentation based parsing) used in function

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Jason Dagit
On Mon, Apr 27, 2009 at 2:41 PM, Bas van Gijzel neneko...@gmail.com wrote: Hello everyone, I'm doing a bachelor project focused on comparing parsers. One of the parser libraries I'm using is Parsec (2) and I'm going to implement a very small subset of haskell with it, with as most important

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-27 Thread Ryan Ingram
I don't have experience solving this problem, but I've read a few horror stories from people who had state affect the results of parsing in Parsec. Haskell's layout rules replace indentation levels with braces and semicolons; you could run an initial tokenizing parser that builds tokens including