[Haskell-cafe] Parsing workflow

S D Swierstra doaitse at uu.nl
Fri Jan 20 16:32:00 CET 2012


On Oct 31, 2010, at 17:15 , Nils Schweinsberg wrote:

> Am 31.10.2010 16:53, schrieb Vo Minh Thu:
>> I can't really tell from your description, but maybe this is because
>> of the way Parsec works when it deals with alternatives. When you
>> combine several parsers with e.g. '<|>' or 'choice', an alternative
>> that can consume some input but fails will make the whole combined
>> parser fail too. So you have to either factorize you parsers or use
>> the 'try'. See the documentation for 'try' at
>> http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Prim.html
>> .
>> 
> 
> This is exactly what gives me headaches. It's hard to tell where you need try/lookAhead and where you don't need them. And I don't really feel comfortable wrapping everything into try blocks...

This is precisely why you should use a more general parser library like uu-parsing and try to avoid the more low-level techniques used in Parsec; uu-parsinglib avoids all the confusion arising from the use of try constructs. It furthermore gives you an online result, error correction and nice error messages. Its Utils module contains a lot of useful "standards" elements you might want to recognise.

Thus far i have only happy users, and if you are having any problems please let me know.


   Doaitse

PS: for all parsing libraries it holds that parsing times are negligeable when compared to the time spent on what you want to do with the parsed result.


> _______________________________________________
> 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