Crates.io | chasm-rs |
lib.rs | chasm-rs |
version | 0.1.0 |
source | src |
created_at | 2021-11-13 18:03:38.171664 |
updated_at | 2021-11-13 18:03:38.171664 |
description | A simple compile-to-WebAssembly language rewritted in Rust |
homepage | |
repository | https://github.com/Rodrigodd/chasm-rs |
max_upload_size | |
id | 481484 |
size | 47,081 |
This crate is a single-pass compiler to WebAssembly for the language chasm.
chasm is a very simple language created by Colin Eberhardt, to introduce the basic building blocks of compilers, and reveal some of the inner workings of WebAssembly. This is a implementation of the compiler in Rust.
Specify the dependency in Cargo.toml:
[dependencies]
chasm-rs = "0.1.0"
And then simply call chasm_rs::compile
to compile a source code to a
WebAssembly module:
let source = "
var y = 0
while (y < 100)
var x = 0
while (x < 100)
c = ((y/100)*255)
setpixel (x, y, c)
x = (x + 1)
endwhile
y = (y + 1)
endwhile";
let wasm = chasm_rs::compile(source);
assert!(wasm.is_ok());
Copyright © 2021, Rodrigodd. Released under the MIT License.