将 Scala AST 转换为源代码 [英] Convert Scala AST to source code
问题描述
给定一个 Scala AST,有没有办法生成 Scala 源代码?
Given a Scala AST, is there a way to generate Scala source code?
我正在研究通过解析/分析其他 Scala 源来自动生成 Scala 源的方法.任何提示将不胜感激!
I'm looking into ways to autogenerate Scala source by parsing/analyzing other Scala source. Any tips would be appreciated!
推荐答案
我已经成功地使用了 Mirko Stocker 的 Scala-Refactoring这个任务.
I have been successfully using Scala-Refactoring by Mirko Stocker for this task.
对于综合构建 AST,它强烈依赖于现有的 Tree DSL.
For synthetically constructing ASTs, it relies strongly on the existing Tree DSL of Scala's NSC.
虽然代码有点乱,但你可以在我的项目ScalaCollider-UGens中找到示例用法.
Although the code is a bit messy, you can find an example usage in my project ScalaCollider-UGens.
我还遇到了一个非常有用的类,约翰内斯·鲁道夫.
I have also come across a very useful class by Johannes Rudolph.
这篇关于将 Scala AST 转换为源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!