Reputation: 537
I'm completely new to Java and clojure. But with previous experience in common lisp, I thought I would give clojure a try. I'm unable to figure out few very basic things.
This is the actual Java code.
import syntaxtree.*;
import visitor.*;
public class Main {
public static void main(String [] args) {
try {
Node root = new MicroJavaParser(System.in).Goal();
System.out.println("Program parsed successfully");
}
catch (ParseException e) {
System.out.println(e.toString());
}
}
}
When I run this code, the outcome is as expected.
└──╼ java Main < ../input/Factorial.java
Program parsed successfully
In Clojure I tried this :
(ns clj-assign2.core)
(defn -main
[]
(def root
(.Goal
(MicroJavaParser. (. System in))))
(println "Successfully parsed"))
But when this code is run, the following exception is raised :
└──╼ lein run < ../assign2/input/Factorial.java
Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: Goal for class MicroJavaParser
at clojure.lang.Reflector.getInstanceField(Reflector.java:271)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:300)
at clj_assign2.core$_main.invoke(core.clj:7)
< --- snipped --- >
What am I doing wrong here?
Upvotes: 2
Views: 943
Reputation: 34810
Maybe you are missing an import statement in your clojure program?
Upvotes: 1