I need to create converter from Scala to another language. I'm looking for scala code parser that converts code to syntax tree without compilation.
Let me make it simple: there is no way to generate a Scala program's AST with parser alone. It is absolutely necessary to run the typer, and that means type inference and implicits.
After that, you can do whatever you want. But these first few phases of the compiler (four on most recent versions, counting the typer) are necessary.
Coincidentally, that's the phases ran by the presentation compiler, which is used by the Scala IDE for Eclipse. It seems to me that this might be the perfect interface for you.
ENSIME also uses it, which seems to be the best source of information about it, and you might also want to take a look at the Scala Refactoring tool, since it uses the compiler's AST as well.
Finally, you can try compiling the code with -Ybrowse:typer
to see the tree after typer. Use -Xshow-phases
to display the existing phases, or -Xprint:typer
to print the "source" after typer (or any other phase).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With