Skip to content

shorya-1012/stellis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stellis : A Simple Interpreter written in RUST.

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.

Features

  • Fully custom language with .stl extension.
  • 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 print statement

Design Overview

  • 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.

Example Code

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;
}

Build & Run

Prerequisites

  • Rust (latest stable)

Clone the repo

git clone https://github.com/shorya-1012/stellis.git
cd stellis

Build

cargo build --release

Run

cargo run -- path/to/your_file.stl

About

A simple Interpreter written in RUST

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages