Lox language interpreter written in Rust
fun main() {
print "hello world!"
}
main();
cargo run example.lox
cargo test
Most of the test and benchmark files are copied from Crafting Interpreters repository. The copyright for these belongs to Bob Nystrom and are copied here because their license allows it (MIT).
$ python3 run_lox_benchmarks.py lox
Running benchmarks for lox... tests/benchmarks/lox
arithmetic.lox: 2.8146
binary_trees.lox: 6.4399
equality.lox: 3.6683
fib.lox: 2.1664
instantiation.lox: 2.7269
invocation.lox: 0.8192
method_call.lox: 0.5381
properties.lox: 1.1997
trees.lox: 9.0106
zoo.lox: 0.927
$ python3 run_lox_benchmarks.py python
Running benchmarks for python... tests/benchmarks/python
arithmetic.py: 2.617
binary_trees.py: 2.5121
equality.py: 2.6572
fib.py: 1.3623
instantiation.py: 2.4031
invocation.py: 0.5649
method_call.py: 0.2729
properties.py: 0.9565
trees.py: 2.5539
zoo.py: 0.7307
$ python3 run_lox_benchmarks.py perl
Running benchmarks for perl... tests/benchmarks/perl
arithmetic.pl: 1.2259
binary_trees.pl: 7.158
equality.pl: 1.5235
fib.pl: 4.7082
instantiation.pl: 4.24
invocation.pl: 0.9832
method_call.pl: 1.11
properties.pl: 1.574
trees.pl: 12.1001
zoo.pl: 1.2363
$ python3 run_lox_benchmarks.py clox
Running benchmarks for clox... tests/benchmarks/lox
arithmetic.lox: 0.749
binary_trees.lox: 3.8906
equality.lox: 2.0149
fib.lox: 1.0654
instantiation.lox: 1.8701
invocation.lox: 0.2706
method_call.lox: 0.1883
properties.lox: 0.4145
trees.lox: 2.6955
zoo.lox: 0.3104