Our hand-written Java parser supports Java 8 to 12.
Initially, Lilit's semantics engine was built with Scala/Java. But, quickly enough, we have reached the limit in terms of how much we can pay for the machines. The cost is proportional to memory usage. Therefore, we want to reduce memory usage by ~10x.
We've chosen Rust because:
- Rust can operate on string slices, and we can avoid making a lot of copies of strings.
- Memory overhead on an object is low.
- It's a modern language, so it's more pleasant to use.
The disadvantage we've seen so far is that Rust can't model a complex tree where nodes can refer to some other nodes. We use unsafe pointers everywhere :S
- Parse all Java files in OpenJDK 8 and 12 successfully
- It doesn't detect
var
in Java 10 yet.
Because we are using spawn_unchecked
when spawning a thread.
cargo +nightly run
in order to runsrc/main.rs
cargo +nightly test
in order to run all tests.cargo +nightly test -- --nocapture
in order to run all tests with STDOUT- Profile:
cargo +nightly profiler callgrind
We have acceptance test in ./tests/syntax/acceptance_test.rs
, which tests the parser against real-world Java files in
./test/fixtures/*.java
.
cargo test benchmark --release -- --nocapture --ignored
Our real-world test parses all Java files under the specified directory (recursively).
Note that it doesn't parse package-info.java
and module-info.java
.
- Change the directory location in
./tests/parse/real_world_test.rs
. cargo test real_world --release -- --nocapture --ignored