3 ms·
This looks really cool, but I'm having a tough time using it from within a Java app. My knowledge of Clojure is very limited, but it appears to run on the JVM
by ccleve 12y ago
This looks really cool, but I'm having a tough time using it from within a Java app.
My knowledge of Clojure is very limited, but it appears to run on the JVM and should work. It installs via Maven just fine. Running it, however, is currently beyond my ken.
A little sample Java code would open this fine piece of software to a much wider audience.
- jared314 12y agoCalling the Clojure api directly from Java would look something like the following: import clojure.java.api.*; import clojure.lang.IFn; import clojure.lang.PersistentVector; public class Core { public static void main(String[] args) { String grammar1 = "S = AB*\n" + "AB = A B\n" + "A = 'a'+\n" + "B = 'b'+"; Clojure.var("clojure.core", "require").invoke(Clojure.read("instaparse.core")); IFn parser = Clojure.var("instaparse.core", "parser"); IFn asandbs = (IFn)parser.invoke(grammar1); PersistentVector result = (PersistentVector)asandbs.invoke("aaaaabbbaaaabb"); System.out.println(result.get(0).toString()); } } But, my suggestion would be to build a Java friendly api in Clojure, with gen-class, and then consume that.