Monday, August 28, 2006

Future Python parsing strategy?

ANTLR 3.0 generates code for plain old C and someone has already written a Python grammar. I should learn enough about ANTLR to figure out if it could generate an AST for Python directly. It's certainly a richer toolkit.

3 comments:

Anonymous said...

What's the goal here? I'm not sure I see making Python's parser easier to change as a good thing :-)

Better introspection would be nice though.

Jeremy Hylton said...

One goal would be to get an abstract syntax tree without the manual effort of the ast.c module. I'll bet a nickel we haven't fixed the last bug there.

Unknown said...

I have used ANTLR in two compiler courses and the biggest complaint I have is the lack of documentation. My prof (who taught both courses) basically had to write us an intro doc in order to use the tool (I can send it to you if you want; I think I still have the PDF).

Plus the syntax is a little odd to me.

But I do agree that it would probably be worth our while to come up with a way to map the grammar to AST and have the code that handle the translation auto-generated.