Skip to content

Commit f3e24d5

Browse files
committed
feat: add initial wasm version
1 parent 417ef43 commit f3e24d5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

wasm/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
mod utils;
22

33
use wasm_bindgen::prelude::*;
4-
use parser::parse;
4+
use parser::{parse_ast_json_string};
5+
use wasm_bindgen::throw_str;
56

67
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
78
// allocator.
@@ -15,11 +16,11 @@ extern {
1516
}
1617

1718
#[wasm_bindgen]
18-
pub fn greet() -> String {
19-
match parse("let a = 3") {
19+
pub fn parse(input: &str) -> String {
20+
match parse_ast_json_string(input) {
2021
Ok(node) => {
2122
node.to_string()
2223
},
23-
Err(e) => format!("parse error: {}", e[0])
24+
Err(e) => throw_str(format!("parse error: {}", e[0]).as_str())
2425
}
2526
}

0 commit comments

Comments
 (0)