jasonjmcghee/basic-treesitter-cranelift-jit: Simple live calculator in tree-sitter + cranelift jit

A basic working example of tree-sitter + cranelift jit.

There’s really one core file – I could break it up, but wanted it to be in one place for this basic example.

The one core file

Here’s the grammar.


calc-demo.mp4


You can run the repl (using crossterm)

Or do a little stress test (using cross term)

cargo run --example stress

Also some simple benchmarks.

Very similar to the “stress” test

 cargo bench --bench calculator_random_bench

And a more basic, non-random one

 cargo bench --bench calculator_bench

If you modify the grammar, cargo build in the main project will update everything as needed.

The main binary uses syntax highlighting as an example of that.

Leave a Reply