I read the tutorial on parser co开发者_如何转开发mbinators for Scala, and I was wondering if there's something as "magical" for Java. The best thing I could find was JParsec.
JParsec seems to do the trick, but I cannot comment on its quality. Java has no operator overloading, which is the syntactic part of the "magic" in parser combinators.
You could also use Scala to implement parsers, then call them from Java. But then the benefit over a code generator such as JavaCC isn't as great.
I've come to enjoy jParsec, even if it isn't as hot as, say, the Newspeak parser combinator. We've shot an aweseome video tutorial on how to use JParsec.
Javacc, grammatica by percederberg.. Any one of these can be used.
精彩评论