A simple interpreter written entirely in Rust. It parses custom .stl code, compiles it to bytecode, and then runs it using a custom-built virtual machine.
This project is made entirely for educational purpooses to understand the working of a Bytecode Interpreter.
- Fully custom language with
.stlextension. - Lexer, Parser, Compiler, and VM for interpreting written from scratch in Rust
- Support for:
- Variables (local and global)
- Arithmetic operations
- Control flow:
if,else,while,for - Simple built-in
printstatement
- Scanner(Lexer): Converts source code into a stream of tokens.
- Compilation: A single pass compiler that consumes tokens and directly emits bytecode.
- Execution: A stack-based VM interprets the bytecode.
Here's an example .stl program that calculates the factorial of 10:
{
let n = 10;
let factorial = 1;
for(let i = n; i > 0; i = i - 1){
factorial = factorial * i;
}
print factorial;
}- Rust (latest stable)
git clone https://github.com/shorya-1012/stellis.git
cd stelliscargo build --releasecargo run -- path/to/your_file.stl