Skip to content

Fork of Taro Sako's esolang framework written in Rust

License

Notifications You must be signed in to change notification settings

wspace/faultier-whitebase

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Whitebase

This project provides infrastructure for implementing esolang.

This is a fork of faultier's Whitebase library, which updates it from Rust v0.12.0-pre to modern Rust.

Features

  • The virtual machine having the instruction set based on Whitespace's specification.
  • Parsers and code generators for some languages (e.g. Whitespace, Ook!, etc.)
  • Simple assembly language

Usage

Compile and execute

use std::io::{Cursor, Seek, SeekFrom};

use whitebase::machine;
use whitebase::syntax::{Compiler, Whitespace};

fn main() {
    let src = "   \t\t \t  \t\n   \t  \t   \n\t\n  \t\n  \n\n\n";
    let mut buffer = Cursor::new(src.as_bytes());
    let mut bc = Cursor::new(Vec::new());
    let ws = Whitespace::new();
    match ws.compile(&mut buffer, &mut bc) {
        Err(e) => panic!("{}", e),
        _ => {
            bc.seek(SeekFrom::Start(0)).unwrap();
            let mut machine = machine::with_stdio();
            match machine.run(&mut bc) {
                Err(e) => panic!("{:?}", e),
                _ => (),
            }
        }
    }
}

Application using Whitebase

License

This project distributed under the MIT License. https://opensource.org/license/MIT

Languages

  • Rust 100.0%