Thursday, April 28, 2005

Lexical Analysis, Python-style

I've always wanted to be able to do lexical analysis Python-style and I've always had the feeling that it should be done with regexps instead of character by character. Now Jason Diamond and Frederik Lundh have presented recipes for doing just that. I'll have to try out these techniques and see if a re-write of the parser for Founder makes things cleaner.

1 comment:

Anonymous said...

For truly pythonic lexers and parsers, try out these (just in case you didn't know):

* PLY http://systems.cs.uchicago.edu/ply/

* SPARK
http://pages.cpsc.ucalgary.ca/~aycock/spark/

(Also, you might want to check out this article on SPARK at http://www-106.ibm.com/developerworks/library/l-spark.html)

BTW, Iain, thanks for your nice comment about by recipe.