Regex: Parsing Lisp with Python

Thomas Guettler zopestoller at
Thu Aug 8 10:22:38 EDT 2002

Yigal Duppen wrote:

>>I need to parse lisp with python. Has anyone
>>experience with this?
> Yes I do :)
> Actually, I have a program that parses Scheme, but as far as the syntax is 
> concerned, that's probably OK.
> I used Plex for it -- much better than regular expressions for non-trivial 
> tokens.

Thank you for your quick reply.

I tried it like this, but this gives me all tokens
serialized. It is hard to get the second symbol without
counting all open and close tokens. Is there a way to get
the tokens in nested lists?

((a b) c) --> [[a b] c]

I tried it like this:

import lexer

while 1:
     if not line:
     print tokens


More information about the Python-list mailing list