Sollux is a "self hosted" metacompiler. It accepts as input a grammar decorated with tiles and produces as output a compiler written in C for the object language. While the compiler sollux generates is written in C, the target language of the resultant compiler generated by Sollux is unrestricted. This is probably the coolest thing I've ever made.
Sollux (and the compiler it generates) needs to be linked with libc, libcirces, and libmf. Circes is a library I wrote that generates parsers and recognizes regular expressions. Mf is a personal util library.
The langauge definitions used in both of these examples are in the samples directory of this repository. Go there to see what a language definition looks like. These are examples of how to use Sollux and it's resultant compilers after you've written a language definition.
This trivial example defines the language greet. The greet compiler 'greetc' as defined by the sollux code in 'greet.ta' produces lua code from greet code.
$ cd samples/hello_world
sollux <greet.ta greetc.c
clang -g -O0 -c greetc.c -o greetc.o
clang greetc.o -lcirces -lmf -o greetc
./greetc <program.greet program
chmod +x program
$ ./program
Hello, DennisR!
Hello, KenT!
Hello, BrianK!
This trivial example defines the language fzzbzz. The fzzbzz compiler 'fzzbzzc' as defined by the sollux code in 'fzzbzz.ta' produces C code from fzzbzz code.
$ cd samples/fzzbzz
$ make
sollux <fzzbzz.ta fzzbzzc.c
clang -g -O0 -c fzzbzzc.c -o fzzbzzc.o
clang fzzbzzc.o -lcirces -lmf -o fzzbzzc
./fzzbzzc <program.fzzbzz program
$ mv program program.c
$ clang program.c
$ ./a.out
1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz
Sollux is a non trivial example of it's own capability.
The file src/main.ta
is sollux defined in it's own language.
The binary produced by the C source in this repository is only
used to take src/main.ta
(to C and then) to a binary,
completeing the bootstrapping process.