3

I'm developing a small programming language based mostly of the C99 standard and I've already written a fairly decent lexer in java and now I'm looking to generate a Java Parser from the grammar. I know there's Bison, but that seems to only generate C code. I'm looking for a application that will allow me to input my grammar and create a full parser class in java code. Reading other SO posts on related topics, I've found ANTLR, but I'm wondering if anyone in the SO knows about a better tool?

thanks!

HipsterZipster
  • 1,326
  • 1
  • 14
  • 34
  • Nothing else was really mentioned here, and for good reason: http://stackoverflow.com/questions/611820/which-java-oriented-lexer-parser-for-simple-project-antlr-diy-etc – Nikhil Mar 30 '09 at 06:41
  • I forgot about Cup... nice find on the duplicate question. – TofuBeer Mar 31 '09 at 02:14

3 Answers3

3

Another couple to look at are JavaCC and SableCC (it has been a long time since I looked at SableCC).

TofuBeer
  • 60,850
  • 18
  • 118
  • 163
  • +1 for JavaCC. It's been years since I used it but found it orders of magnitude easier than lex + yacc – tddmonkey Mar 30 '09 at 08:04
  • I checked out JavaCC, but I'm not sure how it compares to ANTLR? What are the differences between the two? Is one simpler than the other and how? – HipsterZipster Mar 30 '09 at 15:03
  • It has been too long since I used JavaCC and I haven't used ANTLR enough to make a really fair comparison. This might help: http://stackoverflow.com/questions/382211/whats-better-antlr-or-javacc – TofuBeer Mar 30 '09 at 19:18
2

I've been quite impressed by BNFC, which is able to generate parsers in Java as well as in C, C++, C#, F#, Haskell, and OCaml.

Ray Myers
  • 533
  • 5
  • 14
0

The JFlex home page at http://jflex.de indicates where to find Bison-like tools that can target Java:

http://byaccj.sourceforge.net/ http://www2.cs.tum.edu/projects/cup/ http://www.antlr.org/

michael aubert
  • 6,836
  • 1
  • 16
  • 32