Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakobknauer/l0
https://github.com/jakobknauer/l0
compiler cpp cpp23 llvm
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jakobknauer/l0
- Owner: jakobknauer
- License: mit
- Created: 2024-06-25T15:12:10.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-02-02T10:46:16.000Z (2 days ago)
- Last Synced: 2025-02-02T11:26:36.657Z (2 days ago)
- Topics: compiler, cpp, cpp23, llvm
- Language: C++
- Homepage:
- Size: 241 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
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
- 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)
- [Structs](examples/structs/structs.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
```