We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 417ef43 commit f3e24d5Copy full SHA for f3e24d5
wasm/src/lib.rs
@@ -1,7 +1,8 @@
1
mod utils;
2
3
use wasm_bindgen::prelude::*;
4
-use parser::parse;
+use parser::{parse_ast_json_string};
5
+use wasm_bindgen::throw_str;
6
7
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
8
// allocator.
@@ -15,11 +16,11 @@ extern {
15
16
}
17
18
#[wasm_bindgen]
-pub fn greet() -> String {
19
- match parse("let a = 3") {
+pub fn parse(input: &str) -> String {
20
+ match parse_ast_json_string(input) {
21
Ok(node) => {
22
node.to_string()
23
},
- Err(e) => format!("parse error: {}", e[0])
24
+ Err(e) => throw_str(format!("parse error: {}", e[0]).as_str())
25
26
0 commit comments