GitXplorerGitXplorer
F

lox-lang

public
18 stars
0 forks
1 issues

Commits

List of commits on branch main.
Unverified
2cd73bbbbe4bbc8fca68e7d94f7df1b51f52df17

Update benchmark svg

FFolyd committed 3 months ago
Unverified
901b7fb36c73afba8e61c74e72fb6c49c4da88a5

Improve garbage collecting strategy

FFolyd committed 3 months ago
Unverified
d870982e23cfd8181dd378fdbb20037d564b7aad

Optimize performance a little bit

FFolyd committed 3 months ago
Unverified
11b4a3c35cafa9c4c4bee83f5a46ead7d423cfac

Simplify OpCode design

FFolyd committed 3 months ago
Unverified
adc9cfa148983b59097ae3f46c74c2122d6dc722

Stack get uncheck

FFolyd committed 3 months ago
Unverified
d544833c224ce2f101224dfc244edffd745617b2

Clean code

FFolyd committed 3 months ago

README

The README file for this repository.

lox-lang

Lox language interpreter written in Rust

Run

fun main() {
    print "hello world!"
}

main();

cargo run example.lox

Test

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).

Benchmark

Rust (this interpreter)

$ 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

Python v3.12.3

$ 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

Perl v5.34.1

$ 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

Clox (Crafting Interpreters)

$ 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