[IronPython] Generated Code in the Iron Python Source

Dino Viehland dinov at exchange.microsoft.com
Mon Feb 12 18:10:59 CET 2007

We auto-generate the code via Python script files.   The source code for the generation ships w/ IronPython and is in Src\Scripts\generate.py and individual scripts (generate_*.py).  If you're looking for the code that handles a specific block you can grep/findstr for that block's region name minus the "Generated" part that's automatically included at the beginning.

Some of the scripts merely auto-generate based upon a pre-set table of one form or another (most of them). Other scripts reflect into the current running Python interpreter and generate based upon what they see there (e.g. exceptions). Finally some use Reflection to look at the types in the currently running interpreter and generate code based upon that (e.g. walker).  Using IronPython to generate these lets us use the most appropriate one at the time (although it makes things difficult if you've broken the interpreter so badly the scripts don't run anymore J).

Finally the scripts support checking the current source code and validating that there are no inconsistencies between what's on disk and what will be output.  You can run any generate_*.py w/ a "checkonly" option on the command line and it will return 0 if all generated files match.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of kak kak
Sent: Monday, February 12, 2007 7:18 AM
To: users at lists.ironpython.com
Subject: [IronPython] Generated Code in the Iron Python Source


I've recently started to peek around in the source code for IronPython and couldn't help but notice that some of the source code in the parser has comments about being autogenerated (i.e the Tokenizer class)

I assume you have been using a tool similar to ANTLR, I'm just curious about the what tools you have been using to autogenerate this code and are they publicly available?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070212/f52c2bc6/attachment.html>

More information about the Ironpython-users mailing list