简体   繁体   English

从C#应用程序生成并解析Python代码

[英]Generate and parse Python code from C# application

I need to generate Python code to be more specific IronPyton . 我需要生成Python代码以更具体的IronPyton I also need to be able to parse the code and to load it into AST . 我还需要能够解析代码并将其加载到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. 我只是简单地看了一下Coco / R ,看起来很有前途。

Does anyone use Coco/R? 有没有人使用Coco / R? If you did what's your experience with the tool Can you recommend some other tool? 如果你使用该工具做了什么经验你能推荐一些其他工具吗?

IronPython实现本身包括一个解析器一个 Python程序的AST表示 ,可以使用PythonWalker

Not really my area of expertise but you might want to try ANTLR 4 . 不是我的专业领域,但你可能想尝试ANTLR 4 It has support for generating Python 2 and Python 3 . 它支持生成Python 2Python 3

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). 这将是.Net和C#(内存中的.Net 4)的某些更高版本的标准部分。

I've used it to compile and execute Python code generated at runtime, but I haven't played with all the AST stuff yet. 我已经用它来编译和执行在运行时生成的Python代码,但我还没有玩过所有AST的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM