https://github.com/jakobknauer/l0
Statically typed, compiled programming language based on LLVM
https://github.com/jakobknauer/l0
compiler cpp cpp23 llvm
Last synced: 3 months ago
JSON representation
Statically typed, compiled programming language based on LLVM
- Host: GitHub
- URL: https://github.com/jakobknauer/l0
- Owner: jakobknauer
- License: mit
- Created: 2024-06-25T15:12:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-23T18:22:08.000Z (4 months ago)
- Last Synced: 2025-02-23T19:26:36.180Z (4 months ago)
- Topics: compiler, cpp, cpp23, llvm
- Language: C++
- Homepage:
- Size: 357 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
L0 is statically typed, compiled programming language that I started as a hobby project to get into compilers and the LLVM toolchain.
L0 features and characteristics:
- Strong and static typing
- Structures and enums
- Namespaces
- Type inference for local variables
- Immutability by default
- Functions as first-class citizens, higher-order functions, anonymous functions, closures
- Pointer semantics and arithmetic
- Manual memory management## Examples
This is a Hello World program in L0:
```
fn main () -> ()
{
printf("Hello, World!\n");
};
```You can find more examples in [the examples directory](examples):
- [Variables](examples/variables/variables.l0)
- [Control Flow and Booleans](examples/control-flow/control-flow.l0)
- [References and Dynamic Allocations](examples/references/references.l0)
- [Functions](examples/functions/functions.l0)
- [Namespaces](examples/namespaces/namespaces.l0)
- [Structs](examples/structs/structs.l0)
- [Enums](examples/enums/enums.l0)
- [Closures](examples/closures/closures.l0)
- [An interactive program for computing faculties](examples/faculty). This includes a String struct representing strings of dynamic size, conversion from and to integers, etc.## Build
To build the project itself, run
```shell
mkdir build && cd build
cmake ..
make
```## Run
```shell
# Generate textual IR representation from L0 files
build/src/l0/main/l0c# Compile and link to executable
clang -o# E.g. to build and run the faculty example:
cd examples/faculty
../build/src/l0/main/l0c "faculty.l0" "math.l0" "print.l0" "read.l0" "string.l0"
clang *.ll -o faculty
./faculty
```