- This is a Scala port of language-java from Haskell
https://hackage.haskell.org/package/language-java - Consists of a Lexer, a Parser and a Pretty Printer, written in Scala
If you are using SBT to manage your project, to add this library as a dependency in your project, include the following in the build.sbt file
resolvers +="obsidian binary github repo" at "https://raw.githubusercontent.com/obsidian-java/binrepo/master/"
libraryDependencies +="obsidian.lang.java"%%"scalangj"%"0.1.5"importobsidian.lang.java.scalangj.Parser.*importobsidian.lang.java.scalangj.Pretty.*objectMainextendsApp {
valSTRING=""" public class Fib{ public static int fib(int n) { int f1 = 0; int f2 = 1; int i=0; while(i<n) { int t = f2; f2 = f1 + f2; f1 = t; i++; } return f2; } public static void main(String argv[]) { System.out.println(fib(10)); }}"""valeCU= parseCompilationUnit(STRING)
eCU match {
caseLeft(error_msg) => println(error_msg)
caseRight(cu) => println(prettyPrint(cu)) }
}