Skip to content
a compiler for the J programming language
Branch: master
Clone or download
Latest commit 6bfc925 May 12, 2019

README.md

jcompiler

Crates.io Build Status Coverage Status lines of code

A compiler for the J programming language.

Compiling J

You will need LLVM 7 and Rust installed.

$ cargo build --release

You can then compile and run programs as follows:

$ target/release/jcompiler <jfile>.ijs
$ ./<jfile>

Examples

You can find many examples of J programs in the jlang_programs directory. As one example, compiling this J program:

'Some array operations...'
*: 1 2 3 4
matrix =: 2 3 $ 5 + 2 3 4 5 6 7
10 * matrix
1 + 10 20 30
1 2 3 + 10
residues =: 2 | 0 1 2 3 4 5 6 7
residues

with jcompiler and running the compiled binary will yield the following on stdout:

Some array operations...
1 4 9 16
 70  80  90
100 110 120
11 21 31
11 12 13
0 1 0 1 0 1 0 1

By default, jcompiler compiles programs to executables that run on the current machine. You can explicitly specify architecture using LLVM target triples:

$ target/release/jcompiler <jfile>.ijs --target=x86_64-pc-linux-gnu

Documentation

The latest API reference for the master branch is available here.

Tests

There are two categories of tests: one for the parser, the other for the compiler. Both sets can be run with:

$ cargo test

Benchmarks

At present, only the compilation process itself is benchmarked. Future benchmarks for compiled binaries themselves are planned. You can run the compiler benchmarks by invoking:

$ cargo bench

If you have gnuplot installed, graphs will be generated as part of the report. Here's a look at how the compiler runs with optimizations turned off:

unoptimized

compared with all optimizations turned on:

optimized

as of March 30th, 2019.

You can’t perform that action at this time.