A toolchain for a simple programming language, inspired by the Go toolchain. - by Lukas Malkmus
spl is a compiler and toolchain for a simple programming language I had to build a compiler in an university course on building compilers. The design is heavily inspired by the packages of the Go language and features a handwritten parser as well as the two excellent books from Thorsten Ball on building an interpreter and a compiler.
The languages specification can be reviewed here (in german). A machine translated one in english (yes, I'm a lazy fuck) can be reviewed here.
The easiest way to run spl is by grabbing the latest standalone binary from the release page.
This project uses native go mod support for vendoring and requires a working
go
toolchain installation when installing via go get
or from source.
GO111MODULE=on go install github.com/lukasmalkmus/spl/cmd/spl
git clone https://github.com/lukasmalkmus/spl.git
cd spl
make # Build production binary
make install # Build and install binary into $GOPATH
The installation can be validated by running spl version
in the terminal.
spl is a Twelve Factor Application and can be configured by either
configuration file, the environment or command line flags. It provides a basic
help flag --help
which prints out application and configuration help. See
using the application.
Configuration files are TOML formatted:
[format]
indent = 8
Sections which are in TOML indicated by [...]
are mapped to their respective
environment variables by seperating sections and values with an underscore _
.
However, they are prefixed by the application name:
export SPL_FORMAT_INDENT=8
The same is true for command line flags but they are separated by a dot .
and
not prefixed:
spl --format.indent=8
Configuration values without a default value must be set explicitly.
The application itself can echo out its configuration by calling the config
command:
spl config > spl.toml
Configuration priority from lowest to highest is like presented above: Configuration file, environment, command line option (flag).
Click to expand default configuration file:
# SPL COMPILER TOOLCHAIN CONFIGURATION
# Source code formatter configuration.
[format]
# Indentation width used.
indent = 4
spl [flags] [commands]
Help on flags and commands:
spl --help
Feel free to submit PRs or to fill Issues. Every kind of help is appreciated.
More information about the project layout is documented here.
© Lukas Malkmus, 2019
Distributed under MIT License (The MIT License
).
See LICENSE for more information.