Yacc equivalent for Java

江枫思渺然 提交于 2019-11-27 11:48:30
kdgregory

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.

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.

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.

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/

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!