4 releases (2 breaking)

0.3.0 Aug 18, 2023
0.2.0 Aug 12, 2023
0.1.1 Aug 12, 2023
0.1.0 Aug 12, 2023

#433 in Programming languages

Download history 4/week @ 2024-02-26 8/week @ 2024-03-11 62/week @ 2024-04-01

70 downloads per month

MIT license

1.5MB
1.5K SLoC

Contains (Mach-o exe, 2MB) main, (Mach-o exe, 2MB) artifacts/main, (Mach-o exe, 2KB) artifacts/output.o

läspa

Build Status codecov Downloads Version License

A toy language I designed to be as easy as possible to implement. Reminiscent of lisp, läspa uses Reverse Polish Notation for basic arithmetic and for function calls. With a basic interpreter implemented, I plan to implement a compiler with the help of LLVM and plain machine-code generation.

Installation

cargo install laspa

You will need the llvm toolchain to build the executable. Clang is also used for linking.

brew install llvm && export LLVM_SYS_160_PREFIX='/usr/local/opt/llvm@16'

Usage

See this test file for example syntax.

A simple Lisp-like language built with Rust

Usage: laspa [OPTIONS] <FILE>

Arguments:
  <FILE>  The file to build

Options:
  -O, --optimization-level <OPTIMIZATION_LEVEL>  Optimization level for the compiler [default: 1]
  -i, --interpret                                Interpret the file
  -v, --verbose...                               Verbose output
  -o, --executable-name <EXECUTABLE_NAME>        Executable name [default: main]
      --jit                                      Execute IR with JIT
  -h, --help                                     Print help (see more with '--help')
  -V, --version                                  Print version

Why

I was reading an article on the fastest implementation of a binary search algorithm. I saw llvm and thought to myself: "Hmm, wouldn't it be interesting to make a language." The rest is history.

Important Code

The lex, parse, and eval functions are the meat of the execution of the language. Those familiar with language development will recognize those names. llvm.rs is crucial to generating and compiling the IR for LLVM executations.

Dependencies

~7–18MB
~207K SLoC