[Haskell-cafe] Parsing R5RS Scheme with Parsec

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Tue Oct 2 10:28:42 EDT 2007

On Oct 2, 2007, at 9:52 , Alex Queiroz wrote:

>   (parseDottedList ls) <|> (parseProperList ls)
>      I've factored out the common left sub-expression in
> parseLeftList. The problem is that "..." is a valid identifier so when
> inside the left of the list the parser sees a single dot, it tries to
> match it with "...", which fails. Can anybody give advice on how to
> rewrite these list parsing functions?

   try (parseDottedList ls) <|> parseProperList ls

Overuse of try is a bad idea because it's slow, but sometimes it's  
the only way to go; it insures backtracking in cases like this.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list