How to analyze Java source files with Clojure

后端 未结 2 1888
遇见更好的自我
遇见更好的自我 2021-01-18 21:16

I\'m trying to analyze Java source files with Clojure but I couldn\'t find a way to do that.

First, I thought using Eclipse AST plugin(by copying necessary JAR\'s to

2条回答
  •  耶瑟儿~
    2021-01-18 21:38

    It depends a bit on what you want to do - what are you hoping to get from the analysis?

    If you want to actually compile Java or at least build an AST, then you probably need to go the ANTLR or Eclipse AST route. Java isn't that bad of a language to parse, but you still probably don't want to be reinventing too many wheels..... so you might as well build on the Eclipse and OpenJDK work.

    If however you are just interesting in parsing the basic syntax and analysing certain features, it might be easier to use a simpler general purpose parser combinator library. Options to explore:

    • fnparse (Clojure, not sure how well maintained)
    • jparsec (Java, but can probably be used quite easily from Clojure)

提交回复
热议问题