Compare commits
No commits in common. "122adee23be942490874a309355d3372b9053546" and "e4407cbdd1387df3f0b98abd00cb28bb8627be5e" have entirely different histories.
122adee23b
...
e4407cbdd1
2
Makefile
2
Makefile
@ -76,8 +76,6 @@ buildtest:
|
|||||||
> cargo build --no-default-features --features compare,tracing
|
> cargo build --no-default-features --features compare,tracing
|
||||||
> cargo build --no-default-features --features compare,foreign_document_test
|
> cargo build --no-default-features --features compare,foreign_document_test
|
||||||
> cargo build --no-default-features --features compare,tracing,foreign_document_test
|
> cargo build --no-default-features --features compare,tracing,foreign_document_test
|
||||||
> cargo build --target wasm32-unknown-unknown --profile wasm --bin wasm --no-default-features --features wasm
|
|
||||||
> cargo build --bin wasm_test --no-default-features --features wasm_test
|
|
||||||
|
|
||||||
.PHONY: foreign_document_test
|
.PHONY: foreign_document_test
|
||||||
foreign_document_test:
|
foreign_document_test:
|
||||||
|
@ -1,8 +1,28 @@
|
|||||||
|
use organic::parser::parse_with_settings;
|
||||||
|
use organic::settings::GlobalSettings;
|
||||||
|
use organic::wasm::ParseResult;
|
||||||
|
use organic::wasm::ToWasm;
|
||||||
|
use organic::wasm::ToWasmContext;
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
||||||
organic::wasm_cli::parse_org(org_contents)
|
let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) {
|
||||||
|
Ok(document) => document,
|
||||||
|
Err(err) => {
|
||||||
|
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let to_wasm_context = ToWasmContext::new(org_contents);
|
||||||
|
let wasm_document = match rust_parsed.to_wasm(to_wasm_context) {
|
||||||
|
Ok(document) => document,
|
||||||
|
Err(err) => {
|
||||||
|
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
serde_wasm_bindgen::to_value(&ParseResult::Success(wasm_document)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -14,11 +14,9 @@ extern crate test;
|
|||||||
pub mod compare;
|
pub mod compare;
|
||||||
pub mod parse_cli;
|
pub mod parse_cli;
|
||||||
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
|
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
|
||||||
mod util;
|
pub mod util;
|
||||||
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
||||||
mod wasm;
|
pub mod wasm;
|
||||||
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
|
||||||
pub mod wasm_cli;
|
|
||||||
#[cfg(feature = "wasm_test")]
|
#[cfg(feature = "wasm_test")]
|
||||||
pub mod wasm_test;
|
pub mod wasm_test;
|
||||||
|
|
||||||
|
@ -3,12 +3,8 @@ mod util;
|
|||||||
|
|
||||||
pub use sexp::sexp;
|
pub use sexp::sexp;
|
||||||
pub(crate) use sexp::unquote;
|
pub(crate) use sexp::unquote;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
pub(crate) use sexp::TextWithProperties;
|
pub(crate) use sexp::TextWithProperties;
|
||||||
pub use sexp::Token;
|
pub use sexp::Token;
|
||||||
#[cfg(feature = "compare")]
|
|
||||||
pub(crate) use util::get_emacs_standard_properties;
|
pub(crate) use util::get_emacs_standard_properties;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
pub(crate) use util::maybe_token_to_usize;
|
pub(crate) use util::maybe_token_to_usize;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
pub(crate) use util::EmacsStandardProperties;
|
pub(crate) use util::EmacsStandardProperties;
|
||||||
|
@ -61,7 +61,6 @@ impl<'s> Token<'s> {
|
|||||||
}?)
|
}?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "compare")]
|
|
||||||
pub(crate) fn as_text<'p>(
|
pub(crate) fn as_text<'p>(
|
||||||
&'p self,
|
&'p self,
|
||||||
) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
|
) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
|
||||||
|
@ -29,7 +29,6 @@ pub(crate) struct EmacsStandardProperties {
|
|||||||
pub(crate) post_blank: Option<usize>,
|
pub(crate) post_blank: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "compare")]
|
|
||||||
pub(crate) fn get_emacs_standard_properties(
|
pub(crate) fn get_emacs_standard_properties(
|
||||||
emacs: &Token<'_>,
|
emacs: &Token<'_>,
|
||||||
) -> Result<EmacsStandardProperties, Box<dyn std::error::Error>> {
|
) -> Result<EmacsStandardProperties, Box<dyn std::error::Error>> {
|
||||||
|
@ -66,9 +66,7 @@ mod verse_block;
|
|||||||
pub use additional_property::AdditionalProperties;
|
pub use additional_property::AdditionalProperties;
|
||||||
pub use additional_property::AdditionalPropertyValue;
|
pub use additional_property::AdditionalPropertyValue;
|
||||||
pub use ast_node::WasmAstNode;
|
pub use ast_node::WasmAstNode;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
pub use ast_node::WasmAstNodeWrapper;
|
pub use ast_node::WasmAstNodeWrapper;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
pub use document::WasmDocument;
|
pub use document::WasmDocument;
|
||||||
pub use parse_result::ParseResult;
|
pub use parse_result::ParseResult;
|
||||||
pub(crate) use standard_properties::WasmStandardProperties;
|
pub(crate) use standard_properties::WasmStandardProperties;
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
use crate::parser::parse_with_settings;
|
|
||||||
use crate::settings::GlobalSettings;
|
|
||||||
use crate::wasm::ParseResult;
|
|
||||||
use crate::wasm::ToWasm;
|
|
||||||
use crate::wasm::ToWasmContext;
|
|
||||||
|
|
||||||
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
|
||||||
let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) {
|
|
||||||
Ok(document) => document,
|
|
||||||
Err(err) => {
|
|
||||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
|
||||||
let wasm_document = match rust_parsed.to_wasm(to_wasm_context) {
|
|
||||||
Ok(document) => document,
|
|
||||||
Err(err) => {
|
|
||||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
serde_wasm_bindgen::to_value(&ParseResult::Success(wasm_document)).unwrap()
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user