Litan is a gradual typed programming language with a C-like syntax. The Compiler and Bytecode-VM can be used as standalones or C++-Library to add scripts to any application.
function main() {
std::println("Hello World");
}
Litan has fully-featured lambda expressions and supports higher-order-functions.
function use_lambda(fx) {
return fx(1, 2);
}
function make_lambda(c)
=> lambda[c](a, b) => (a + b + c)
function main() {
std::println(use_lambda(make_lambda(3))); // 6
}
Reflections allow you to gather infos about your programm at compile-time.
function main() {
std::println("Line: " + std::str(reflect(line))); // Line 2
}
Litan uses structs whose members can added or removed dynamically.
function main() {
var object = std::struct();
object.foo = 42;
object.bar = 1337;
std::println(object.foo);
std::println(object.bar);
}
- Sphinx (Unit test framework)
- CMake 3.13 or newer
- A modern C++ compiler with C++20 support
- Clang++-10 or newer
- GCC-10 or newer
- stdxx library
- Clone the repository recursively.
- Run
./build.sh
to compile the compiler, vm and everything needed.- Note: Clang++ is choosen by default but this can be changed.
Just run
./build.sh COMPILER_GOES_HERE
in this case.
- Note: Clang++ is choosen by default but this can be changed.
Just run
- Run
./install.sh
to install ltn, ltnc, ltnvm and ltninfo into the /usr/local/bin/ directory.
- Add litan as a submodule to your project.
- Add stdxx as a submodule to your project.
- Add the litan subdirectory to your project: e.g.
add_subdirectory(libs/litan)
- Link the library: e.g.
target_link_libraries(my_project litan)
- Include the main header: e.g.
#include "libs/litan/Litan.hxx"
Bob Nystrom: For his great book "Crafting Interpreters" which provided a large portion of the information I needed to realize this project.