Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yacc equivalent for Java

Tags:

java

yacc

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.

like image 767
vuzun Avatar asked Oct 28 '09 19:10

vuzun


People also ask

Is Lex and Yacc still used?

Yes, these tools are worth learning if you ever need to create or modify code that parses a grammar. For many years the de facto tool for generating code to parse a grammar was yacc, or its GNU cousin, bison.

Is yacc a Lalr?

YACC (yet another compiler-compiler) is an LALR(1) (LookAhead, Left-to-right, Rightmost derivation producer with 1 lookahead token) parser generator.

Why yacc is called Yet Another Compiler Compiler?

Yacc was influenced by and received its name in reference to TMG compiler-compiler. Yacc was originally written in the B programming language, but was soon rewritten in C by Alan Snyder.

Is yacc A parser?

Yacc (yet another compiler compiler) is a grammar parser and parser generator. That is, it is a program that reads a grammar specification and generates code that is able to organize input tokens in a syntactic tree in accordance with the grammar.


1 Answers

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.

like image 145
kdgregory Avatar answered Oct 05 '22 14:10

kdgregory