Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Scala AST to source code

Given a Scala AST, is there a way to generate Scala source code?

I'm looking into ways to autogenerate Scala source by parsing/analyzing other Scala source. Any tips would be appreciated!

like image 668
Pandora Lee Avatar asked Jun 21 '11 22:06

Pandora Lee


1 Answers

I have been successfully using Scala-Refactoring by Mirko Stocker for this task.

For synthetically constructing ASTs, it relies strongly on the existing Tree DSL of Scala's NSC.

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.

like image 170
0__ Avatar answered Sep 19 '22 14:09

0__