[Haskell-cafe] Parsec combinator like Prolog's cut operator?

S. Doaitse Swierstra doaitse at swierstra.net
Sat Jul 3 04:31:08 EDT 2010

If you use the uu-parsing libraries you will get a breadth-first search, instead of a non-backtrcaking depth-first search of Parsec; furthermore you do not suffer from space leaks and get your results online. In addition you get error correction, with high-quality error messages.

The principles of the library are explained in 

	Author = {Swierstra, S.~Doaitse},
	Booktitle = {Language Engineering and Rigorous Software Development},
	Date-Added = {2009-05-23 11:08:01 +0200},
	Date-Modified = {2009-05-31 22:35:25 +0200},
	Editor = {Bove, A. and Barbosa, L. and Pardo, A. and and Sousa Pinto, J.},
	Pages = {252-300},
	Place = {Piriapolis},
	Publisher = {Spinger},
	Series = {{LNCS}},
	Title = {Combinator Parsers: a short tutorial},
	Volume = {5520},
	Year = {2009}}

which is also available as a technical report:

	Author = {Swierstra, S. Doaitse},
	Date-Added = {2009-01-07 13:47:34 +0100},
	Date-Modified = {2009-01-16 17:36:52 +0100},
	Institution = {Department of Information and Computing Sciences, Utrecht University},
	Number = {UU-CS-2008-044},
	Pubcat = {techreport},
	Title = {Combinator Parsing: A Short Tutorial},
	Urlpdf = {{http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf}}

Follow the link to the pdf in this last Bibtex record.

In the uu-parsing package you will find a file with examples, which you can just run to see the different constructs at work. Because te library is doing the hard work, writing parsers becomes simpler.


On 30 jun 2010, at 05:26, Erik de Castro Lopo wrote:

> Hi all,
> I'm reading John Hughes' paper "Generalizing Monads to Arrows" and found
> the statement regarding parser combinators:
>   "... depend on the programmer using an additional combinator similar
>   to Prolog's 'cut' operator do declare that a parser need never
>   backtrack beyond a certain point."
> Does something like this already exist in Parsec? If not is there a way
> to write it?
> Having this would really help with a parsing problem I have.
> Cheers,
> Erik
> -- 
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list