views:

254

answers:

3

I need to generate Python code to be more specific IronPyton. I also need to be able to parse the code and load it into AST. I just started looking at some tools. I played with "Oslo" and made decision that it's not the right tool for me. I just looked very briefly at Coco/R and it looks promising.

Does any one used Coco/R?
If you did what's your experience with the tool? Can you recommend some other tool?

A: 

I think you should look at the Dynamic Language Runtime. This will be a standard part of some later version of .Net and C# (.Net 4 from memory).

I've used it to compile and execute Python code generated at runtime, but I haven't played with all the AST stuff yet.

Daniel Paull
I did look at DLR that's why I want to generate IronPython code that is a DLR language. Unfortunately, C# 4 doesn't going to have all the features of dynamic language. So far you only can use dynamic keyword in C#4. But in any case it's not my question.
Vadim
You can do everything you want right now with IronPython and DLR. I suggest you read the page I linked to in my answer as it talks specifically about generating an AST from Python code. You do not need C# 4 to use the DLR. If you are using IronPython 2.0 onwards, you are using the DLR!
Daniel Paull
+4  A: 

The IronPython implementation itself includes a parser and an AST representation of Python programs which can be walked with a PythonWalker.

dtb
That's a great information for me. +1 for now. Let me research it and if it does for me what I think does, I'll accept your answer.
Vadim
A: 

Not really my area of expertise but you might want to try ANTLR. It has support for generating Python.

Richard Nienaber