Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manorajesh/laspa
Lisp-like Language with LLVM Backend
https://github.com/manorajesh/laspa
lisp llvm programming-language rust
Last synced: 17 days ago
JSON representation
Lisp-like Language with LLVM Backend
- Host: GitHub
- URL: https://github.com/manorajesh/laspa
- Owner: manorajesh
- License: mit
- Created: 2023-08-11T20:23:59.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-29T22:51:10.000Z (over 1 year ago)
- Last Synced: 2024-12-24T08:37:22.763Z (about 2 months ago)
- Topics: lisp, llvm, programming-language, rust
- Language: Rust
- Homepage:
- Size: 3.47 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# läspa
![Build Status](https://github.com/manorajesh/laspa/actions/workflows/rust.yml/badge.svg)
[![codecov](https://codecov.io/gh/manorajesh/laspa/branch/master/graph/badge.svg?token=2CN1LLRK4P)](https://codecov.io/gh/manorajesh/laspa)
![Downloads](https://img.shields.io/crates/d/laspa)
![Version](https://img.shields.io/crates/v/laspa)
![License](https://img.shields.io/crates/l/laspa)A toy language I designed to be as easy as possible to implement.
Reminiscent of [lisp](https://en.wikipedia.org/wiki/Lisp_(programming_language)),
läspa uses [Reverse Polish Notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation)
for basic arithmetic and for function calls. With a basic interpreter implemented and
[LLVM](https://llvm.org/docs/LangRef.html#type-system) executables, I plan to implement
a machine-code generation component, without using the LLVM toolchain.## Installation
```shell
cargo install laspa
```You will need the llvm toolchain to build the executable. Clang is also used for linking.
```shell
brew install llvm && export LLVM_SYS_160_PREFIX='/usr/local/opt/llvm@16'
```## Usage
See [this test file](https://github.com/manorajesh/laspa/blob/master/examples/test.laspa) for example syntax.
```
A simple Lisp-like language built with RustUsage: laspa [OPTIONS]
Arguments:
The file to buildOptions:
-O, --optimization-level Optimization level for the compiler [default: 1]
-i, --interpret Interpret the file
-v, --verbose... Verbose output
-o, --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](https://mhdm.dev/posts/sb_lower_bound/) 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.