tags:

views:

281

answers:

4

Hello.

I'm working on a compiler design project in Java. Lexical analysis is done (using jflex) and I'm wondering which yacc-like tool would be best(most efficient, easiest to use, etc.) for doing syntactical analysis and why.

+4  A: 

In the past, I've used ANLTR for both lexer and parser, and the JFlex homepage says it can interoperate with ANTLR. I wouldn't say that ANTLR's online documentation is that great. I ended up investing in 'The Definitive ANTLR reference', which helped considerably.

toolkit
In my experience, ANTLR is by far the most popular Java tool for lexing/parsing.
Don
+1  A: 

GNU Bison has a Java interface,

http://www.gnu.org/software/bison/manual/html%5Fnode/Java-Bison-Interface.html

You can use it go generate Java code.

ZZ Coder
What are your experiences with this? Does it work well?
Thorbjørn Ravn Andersen
+5  A: 

If you specifically want YACC-like behavior (table-driven), the only one I know is CUP.

In the Java world, it seems that more people lean toward recursive descent parsers like ANTLR or JavaCC.

And efficiency is seldom a reason to pick a parser generator.

kdgregory
+1  A: 

Another option would be the GOLD Parser.

Unlike many of the alternatives, the GOLD parser generates the parsing tables from the grammar and places them in a binary, non-executable file. Each supported language then has an engine which reads the binary tables and parses your source file.

I've not used the Java implementation specifically, but have used the Delphi engine with fairly good results.

Steve N