diff --git a/src/bin_wasm_test.rs b/src/bin_wasm_test.rs index 48a271f..fda2774 100644 --- a/src/bin_wasm_test.rs +++ b/src/bin_wasm_test.rs @@ -36,8 +36,6 @@ async fn main_body() -> Result<(), Box> { let args = std::env::args().skip(1); if args.is_empty() { let org_contents = read_stdin_to_string()?; - // let wasm_result = wasm_parse_org(org_contents.as_str()); - // println!("{}", serde_json::to_string(&wasm_result)?); if wasm_run_anonymous_compare(org_contents).await? { } else { Err("Diff results do not match.")?; diff --git a/src/compare/mod.rs b/src/compare/mod.rs index b103216..95290e2 100644 --- a/src/compare/mod.rs +++ b/src/compare/mod.rs @@ -12,3 +12,4 @@ pub use compare::run_compare_on_file; pub use compare::run_compare_on_file_with_settings; pub use compare::silent_anonymous_compare; pub use compare::silent_compare_on_file; +pub use sexp::sexp; diff --git a/src/wasm_test/runner.rs b/src/wasm_test/runner.rs index b10b395..0f5aa7e 100644 --- a/src/wasm_test/runner.rs +++ b/src/wasm_test/runner.rs @@ -1,7 +1,11 @@ +use crate::compare::sexp; use crate::context::GlobalSettings; use crate::parser::parse_with_settings; use crate::util::emacs_parse_anonymous_org_document; use crate::util::print_versions; +use crate::wasm::ParseResult; +use crate::wasm::ToWasm; +use crate::wasm::ToWasmContext; pub async fn wasm_run_anonymous_compare>( org_contents: P, @@ -21,13 +25,19 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef>( print_versions().await?; } let rust_parsed = parse_with_settings(org_contents, global_settings)?; + let to_wasm_context = ToWasmContext::new(org_contents); + let wasm_parsed = match rust_parsed.to_wasm(to_wasm_context) { + Ok(wasm_document) => ParseResult::Success(wasm_document), + Err(err) => ParseResult::Error(format!("{:?}", err)), + }; let org_sexp = emacs_parse_anonymous_org_document(org_contents, global_settings).await?; - // let (_remaining, parsed_sexp) = sexp(org_sexp.as_str()).map_err(|e| e.to_string())?; + let (_remaining, parsed_sexp) = sexp(org_sexp.as_str()).map_err(|e| e.to_string())?; if !silent { println!("{}\n\n\n", org_contents); - // println!("{}", org_sexp); + println!("{}", org_sexp); println!("{:#?}", rust_parsed); + println!("{}", serde_json::to_string(&wasm_parsed)?); } // We do the diffing after printing out both parsed forms in case the diffing panics