Created
August 24, 2011 17:55
-
-
Save gregturn/1168692 to your computer and use it in GitHub Desktop.
Embedding scala compiler in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Settings settings = new Settings(); | |
settings.usejavacp().tryToSetFromPropertyValue("true"); | |
settings.stopAfter().tryToSetColon(Nil.$colon$colon("dce")); // same as "dce" :: Nil in scala | |
settings.debug().tryToSetFromPropertyValue("true"); | |
System.out.println("About to compile " + new String(sourceUnit.getContents())); | |
PrintWriter out = new PrintWriter("output.txt"); | |
IMain main = new IMain(settings, out); | |
boolean success = main.compileString(new String(sourceUnit.getContents())); | |
System.out.println("Compiled? " + success); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment