Generate and parse Python code from C# application

偶尔善良 提交于 2019-12-09 18:01:28

问题


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?


回答1:


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




回答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.




回答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).

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



来源:https://stackoverflow.com/questions/1432998/generate-and-parse-python-code-from-c-sharp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!