Yacc equivalent for Java

25,211

Solution 1

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.

Solution 2

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.

Solution 3

GNU Bison has a Java interface,

http://www.gnu.org/software/bison/manual/html_node/Java-Bison-Interface.html

You can use it go generate Java code.

Solution 4

There is also jacc.

Jacc is about as close to yacc as you can get, but it is implemented in pure java and generates a java parser.

It interfaces well with jFlex

http://web.cecs.pdx.edu/~mpj/jacc/

Solution 5

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.

Share:
25,211
vuzun
Author by

vuzun

Updated on September 03, 2020

Comments

  • vuzun
    vuzun over 3 years

    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.