Serialize to wasm during wasm compare.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has failed
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander 2023-12-27 08:57:56 -05:00
parent 55ad136283
commit 23f4ba4205
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 13 additions and 4 deletions

View File

@ -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.")?;

View File

@ -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;

View File

@ -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