"compiler" for the slope programming language https://slope.colorfield.space
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sloum eeaaf092f3 Brings code in line with 0.7.8 12 months ago
runtime Brings code in line with 0.7.8 12 months ago
slc Brings code in line with 0.7.8 12 months ago
.gitignore Adds ability to use an alternate runtime location via command flag 1 year ago
Makefile Updates termios and adds gui options 1 year ago
README.md Updates the runtime to slope 0.7.5 12 months ago


slc - slope language compiler

So, compiler is sort of a misnomer here. It is more like freezing the runtime with a linked version of the slope source code.

How it works

When you run slc with a given slope source code file it will replace all calls to load, load-mod, and load-mod-file with the contents of the given files (this happens recursively to ensure all needed components are included). That file will be saved and embeded into the slope runtime, which will then be compiled by the Go compiler. The resulting binary will lex, parse, and evaluate the source code just as the interpreter would, but from an embedded string rather than from a file that gets read in.

The resulting binary will be fairly large as it packages both the necessary components of the go runtime as well as the slope runtime on top of that. Execution should be at least as fast as the slope interpreter. So the main gain by using slc is that you can more easily distribute your slope programs. To combat some size issues some compiler flags are used to discard binary debugging information. You can reduce the size significantly by processing the resulting file with upx, if you have it on your system.

Example slc usage:

slc -name myprogram ./myprogram.slo

Since the Go compiler is used under the hood here, you can set environment variables to enable cross-compilation for a different OS or architecture:

GOOS=linux GOARCH=386 slc -name myprogram ./myprogram.slo

If you need to link in the gui lib use the -g flag:

slc -name my-program -g ./myprogram.slo

If you want to see version information use the -v flag. Note that this outputs the version of the underlying slope runtime and not the slc version (which is more or less linked to the runtime version). This will allow you to verify that the version of slc you have will have the features you need based on what version of the slope interpreter you wrote the code for.

slc -v


  • go >= 1.16 is required for building slc, but must also exist on the system that is running slc. The slope interpreter, however, is not required
  • make; it is possible BSD make will work, but GNU make was used for testing
  • a slope file you want to freeze/"compile"


To install, navigate to the root of this repo, then do the following:

make              # builds the slc binary
sudo make install # global installs slp & runtime lib

If you do not wish to install globally or do not have sudo privleges:

make configure # locally installs the runtime lib
make           # builds the binary
mv ./slc/slc . # moves the binary to current dir, or elsewhere if you replace the last . with a path