[Haskell-cafe] Parsing R5RS Scheme with Parsec
Alex Queiroz
asandroq at gmail.com
Tue Oct 2 10:56:40 EDT 2007
Hallo,
On 10/2/07, Brandon S. Allbery KF8NH <allbery at ece.cmu.edu> wrote:
>
> Sorry, just woke up and still not quite tracking right, so I modified
> the wrong snippet of code. The trick is to wrap parseLeftList in a
> try, so the parser retries the next alternative when it fails.
>
Since "..." can only appear at the end of a list, I removed "..."
from the possible symbols and added a new function:
parseThreeDottedList :: [SchDatum] -> Parser SchDatum
parseThreeDottedList ls = do
string "..."
many parseAtmosphere
char ')'
return $ SchList $ ls ++ [SchSymbol "..."]
parseList :: Parser SchDatum
parseList = do
ls <- parseLeftList
try (parseThreeDottedList ls) <|> (parseDottedList ls) <|>
(parseProperList ls)
Thanks for the help.
Cheers,
--
-alex
http://www.ventonegro.org/
More information about the Haskell-Cafe
mailing list