Robert Olofsson



Parjac2 is an experiment in building a java compiler.
It is supposed to be built to be easy to read, easy to run and extend. It may be used for parsing or compiling other things in the future.

The basic parts of parjac are

  • Written with a generic lexer and parser that ought to work for many more languages.
  • Written with modern java in mind and using java 11 as the test bed of functionality and speed.
  • A hand written java lexer. See
  • An earley based parser. See
  • A grammar that tries to stay true to the grammar in 19 of the java 11 jls. See java11.pj.
  • Figuring out types and actual code generation will be added based on code from parjac later on.

Grabbing the code

git clone

Compiling and running

Use mvn compile or mvn package or any other maven command to build. To run the current test program from the command line something like this can be used:
java --module-path=target/classes/ --module org.khelekore.parjac2/org.khelekore.parjac2.java11.TestParser /tmp/some/
java --module-path=target/classes/ --module org.khelekore.parjac2/org.khelekore.parjac2.java11.TestParser -print_syntax /tmp/some/
mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=org.khelekore.parjac2.java11.BatchCompiler -Dexec.args="-i source_directory/ -d destination_directory/"
Please note that this does not compile code correctly yet! Currently it parses the code and generates output directories and generates some sort of output files, but they do not contain everything yet.