The goal of this Project is to develop an experimental versionof the javac compiler based upon agrammarwritten inANTLR.
The parser that is currently in the javac compiler is ahand-written LALR parser. It is somewhat fragile, and is not alwayseasy to extend when working on potential new language features. Inaddition, it is not well-suited for analysis, such as comparisonagainst the grammar rules in the Java Language Specification(JLS).
There is a separate but related problem with JLS. The JLSactually contains two slightly different grammars. One is the"exposition grammar" used through the body of the book in chapters1-17; the other is the "reference grammar" in chapter 18,supposedly suitable as the basis for an implementation. They aredifferent in a number of places, and neither match exactly what isdone in the javac compiler itself. Thus, a subsidiary goal is tounderstand the differences between these three formulations, withthe possibility of aligning them, and being able to formally testthe result.
The project is available in the Mercurial repositories at:
Within that forest, all the changes to the javac compiler are inthelangtools
repository.
The original Java.g ANTLR grammar has been integrated into thejavac compiler. The resulting compiler passes all the compilerregression tests and all the relevant JCK tests for a Javacompiler. The grammar has also been marked up with comments so thatit is possible to strip out those parts that are specific to javac(such as building javac AST nodes) leaving a grammar which can beused within tools likeANTLRWorks.
This Project is sponsored by theCompiler Group.