7

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

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

3
  • What do you mean by "Oslo". The link is broken. Commented Sep 24, 2018 at 13:37
  • @IvanKochurkin "Oslo" used to be a Microsoft project. You can find more at searchwindevelopment.techtarget.com/tip/…. Commented Dec 12, 2018 at 22:18
  • So, please fix the link in your question :) Commented Dec 13, 2018 at 10:34

3 Answers 3

11

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
This question was answered a long time ago, but I'd like to know: did you get anywhere with this approach?
Am I the only one that finds the IronPython documentation unreadable?
2

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

Comments

0

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.

2 Comments

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.
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.