Monadic Parser Combinators in Python

Dominic Fox dominic.fox at gmail.com
Fri Mar 18 09:00:33 EST 2005


Python: Now More Like Haskell Than Ever Before!

I've implemented a small monadic parser combinator library in Python
(based on Haskell code in a paper by Graham Hutton and Eric Meijer).

http://codepoetics.com/poetix/index.php?p=94

It enables you to write things like this:

> token = isalpha |seq| many(isdigit)
> tokens = token |sepBy| whitespace
> runParser("p123 q456 hello world", tokens)
['p123', 'q456']

It is probably entirely unsuited for any serious purpose, but might
qualify as an interesting hack...

Dominic



More information about the Python-list mailing list