General
About
GIT
Contacts
Robert Olofsson
robo@khelekore.org
|
|
About
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 21 as the test bed of functionality and speed.
- A hand written java lexer. See CharBufferLexer.java.
- An earley based parser. See Parser.java. This meaans that it is fast and has good error handling.
- A grammar that tries to stay true to the grammar in
§19 of the java 21 jls.
See java21.pj.
- It uses the ClassFile api (well, the backport of it) to actually generate class files.
- It compiles all .java-files found in the given input directory and its sub-directories
Grabbing the code
git clone http://www.khelekore.org/parjac2/parjac2.git
Compiling and running
mvn package
java -jar target/parjac2-1.0-shaded.jar -i src/ -d /tmp/out/
If you do not give any command line arguments (as in run with java -jar target/parjac2-1.0-shaded.jar ) you will get a usage clause.
You can of course also use any other maven targets, possibly mvn compile or mvn test
It is also possible 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/File.java
java --module-path=target/classes/ --module org.khelekore.parjac2/org.khelekore.parjac2.java11.TestParser -print_syntax /tmp/some/File.java
or
mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=org.khelekore.parjac2.java11.BatchCompiler -Dexec.args="-i source_directory/ -d destination_directory/"
-
It can parse the full java 21 (to my knowledge) and it does quite a few semantic checks and it outputs correct classes for most of the language.
-
It currently only parses generics, but it does not use it for method lookups. This of course means that any non-trivaial program will fail.
-
It can correctly compile many programs, the test suite has grown quite large
|