Serialize to wasm during wasm compare.
This commit is contained in:
parent
55ad136283
commit
23f4ba4205
@ -36,8 +36,6 @@ async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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.")?;
|
||||
|
@ -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;
|
||||
|
@ -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<P: AsRef<str>>(
|
||||
org_contents: P,
|
||||
@ -21,13 +25,19 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user