NIMBLE (Nam's Interpreted Modular Basic Language Engine) is a dynamically typed, interpreted programming language with C-like syntax. This repository contains the source code for the NIMBLE programming language's interpreter.
I started this project at the beginning of June 2024 with the goal of learning more about programming language design and practicing my C++ skills. It then gradually became one of my biggest projects yet.
The interpreter is not very optimized and there may be some bugs that I might have overlooked, but I'm quite happy with how it turned out.
import "core:math";
// collatz conjecture function
fun collatz_conjecture(n)
{
if (n % 2 == 0)
{
n = floordiv(n, 2);
return n;
}
else if (n % 2 == 1)
{
n = 3 * n + 1;
return n;
}
}
mut n = input("Enter number: ");
mut i = 0;
mut li = [];
// main loop
while (n != 1)
{
n = collatz_conjecture(n);
li[i] = n;
i += 1;
}
print(li);
NIMBLE is a dynamically typed programming language, featuring C-like syntax with class support and C++ inheritance syntax. It has a very "fun" syntax (because the function keyword is fun)
Before compilation, you'll need to have these tools installed first:
Directory | Description |
---|---|
benchmark | Benchmark programs |
doc | Documentation |
examples | Example programs |
include | Header files |
lib | Core library |
src | Source code |
tests | Test cases |
tools | Useful tools and scripts |
web | Code runner website |
If you're using make
:
make compile
to compile the program into thebin/
directorymake run
to run the programmake clean
to clean up the object and binary filesmake test
to run test casesmake bench
to run benchmarks
You can run the interpreter with make run
or ./bin/nimble <filename>.nbl
Elapsed time of computationally intensive programs:
Program | Mininum | Average | Maximum |
---|---|---|---|
bintree.nbl | 1.13 | 1.19 | 1.30 |
count.nbl | 0.57 | 0.61 | 0.64 |
fibonacci.nbl | 1.01 | 1.04 | 1.10 |
prime.nbl | 0.34 | 0.34 | 0.35 |
You can find the documentation in the doc directory. You can also learn about the syntax of the language through example programs found in the examples directory.
For now, most of the features of the language and the interpreter is complete. Currently, I'm working on the documentation for this interpreter.
Hopefully I could integrate this project with LLVM and create a compiler for this language for improved performance and speed in the future.
I've created a VSCode extension for the language. You can checkout the extension here