Invoking wasm_compare_document.
This commit is contained in:
parent
23f4ba4205
commit
99376515ef
@ -13,3 +13,4 @@ pub use compare::run_compare_on_file_with_settings;
|
|||||||
pub use compare::silent_anonymous_compare;
|
pub use compare::silent_anonymous_compare;
|
||||||
pub use compare::silent_compare_on_file;
|
pub use compare::silent_compare_on_file;
|
||||||
pub use sexp::sexp;
|
pub use sexp::sexp;
|
||||||
|
pub use sexp::Token;
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
#[cfg(feature = "compare")]
|
// TODO: I only include compare to use some shared stuff like sexp and DiffResult. Ideally, this would be moved to a shared module.
|
||||||
|
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||||
pub mod compare;
|
pub mod compare;
|
||||||
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
use crate::types::Document;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
use super::standard_properties::WasmStandardProperties;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::types::Document;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "ast_node")]
|
#[serde(tag = "ast_node")]
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "org-data")]
|
||||||
pub(crate) struct WasmDocument<'s> {
|
pub struct WasmDocument<'s> {
|
||||||
standard_properties: WasmStandardProperties,
|
standard_properties: WasmStandardProperties,
|
||||||
additional_properties: Vec<(String, &'s str)>,
|
additional_properties: Vec<(String, &'s str)>,
|
||||||
children: Vec<WasmAstNode<'s>>,
|
children: Vec<WasmAstNode<'s>>,
|
||||||
|
@ -62,6 +62,7 @@ mod underline;
|
|||||||
mod verbatim;
|
mod verbatim;
|
||||||
mod verse_block;
|
mod verse_block;
|
||||||
|
|
||||||
|
pub use document::WasmDocument;
|
||||||
pub use parse_result::wasm_parse_org;
|
pub use parse_result::wasm_parse_org;
|
||||||
pub use parse_result::ParseResult;
|
pub use parse_result::ParseResult;
|
||||||
pub(crate) use to_wasm::ToWasm;
|
pub(crate) use to_wasm::ToWasm;
|
||||||
|
9
src/wasm_test/compare.rs
Normal file
9
src/wasm_test/compare.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
use crate::compare::Token;
|
||||||
|
use crate::wasm::WasmDocument;
|
||||||
|
|
||||||
|
pub fn wasm_compare_document<'b, 's>(
|
||||||
|
emacs: &'b Token<'s>,
|
||||||
|
wasm: &'b WasmDocument<'s>,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
todo!()
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
mod compare;
|
||||||
mod runner;
|
mod runner;
|
||||||
|
|
||||||
pub use runner::wasm_run_anonymous_compare;
|
pub use runner::wasm_run_anonymous_compare;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
use super::compare::wasm_compare_document;
|
||||||
use crate::compare::sexp;
|
use crate::compare::sexp;
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::parser::parse_with_settings;
|
use crate::parser::parse_with_settings;
|
||||||
use crate::util::emacs_parse_anonymous_org_document;
|
use crate::util::emacs_parse_anonymous_org_document;
|
||||||
use crate::util::print_versions;
|
use crate::util::print_versions;
|
||||||
use crate::wasm::ParseResult;
|
|
||||||
use crate::wasm::ToWasm;
|
use crate::wasm::ToWasm;
|
||||||
use crate::wasm::ToWasmContext;
|
use crate::wasm::ToWasmContext;
|
||||||
|
|
||||||
@ -26,10 +26,9 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
|
|||||||
}
|
}
|
||||||
let rust_parsed = parse_with_settings(org_contents, global_settings)?;
|
let rust_parsed = parse_with_settings(org_contents, global_settings)?;
|
||||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
let to_wasm_context = ToWasmContext::new(org_contents);
|
||||||
let wasm_parsed = match rust_parsed.to_wasm(to_wasm_context) {
|
let wasm_parsed = rust_parsed
|
||||||
Ok(wasm_document) => ParseResult::Success(wasm_document),
|
.to_wasm(to_wasm_context)
|
||||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
.map_err(|_e| "Failed to convert to wasm.")?;
|
||||||
};
|
|
||||||
let org_sexp = emacs_parse_anonymous_org_document(org_contents, global_settings).await?;
|
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())?;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We do the diffing after printing out both parsed forms in case the diffing panics
|
// We do the diffing after printing out both parsed forms in case the diffing panics
|
||||||
// let diff_result = compare_document(&parsed_sexp, &rust_parsed)?;
|
let diff_result = wasm_compare_document(&parsed_sexp, &wasm_parsed)?;
|
||||||
// if !silent {
|
// if !silent {
|
||||||
// diff_result.print(org_contents)?;
|
// diff_result.print(org_contents)?;
|
||||||
// }
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user