successfully compile basic test to wasm

This commit is contained in:
2021-10-25 21:12:56 +02:00
parent b8b0a21ef9
commit 3b4eeb5f9c
9 changed files with 435 additions and 28 deletions

View File

@@ -1,7 +1,12 @@
use std::fs::File;
use std::io::prelude::*;
mod parser;
mod ast;
mod typecheck;
mod constfold;
mod emit;
fn main() {
let input = include_str!("../test.hw");
@@ -10,7 +15,9 @@ fn main() {
Ok(mut script) => {
constfold::fold_script(&mut script);
typecheck::tc_script(&mut script).unwrap();
dbg!(script);
let wasm = emit::emit(&script);
let mut file = File::create("test.wasm").unwrap();
file.write_all(&wasm).unwrap();
},
Err(err) => println!("error: {}", nom::error::convert_error(input, err))
}