#[deny(missing_docs)]
use lexer::lex;
use parser::parse;
extern crate wasm_bindgen;
pub(crate) mod instructions;
pub(crate) mod lexer;
pub(crate) mod parser;
pub(crate) mod runner;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn run(program: &str) -> String {
let operation_codes = lex(program.to_string());
let instructions = parse(operation_codes);
let output = runner::run(&instructions);
output
}
#[cfg(test)]
mod tests {
use crate::run;
#[test]
fn gives_correct_output() {
let hello_world = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
let output = run(hello_world);
assert_eq!(output, "Hello World!\n")
}
}