Expand description
Provides simple conversion from Pest grammar syntax to Amazon Ion.
§Example
The easiest way to convert Pest grammars to Ion is from a str
slice:
use pest_ion::*;
use ion_rs::value::*;
use ion_rs::value::reader::*;
fn main() -> PestToIonResult<()> {
// parse a Pest grammar and convert it to Ion element
let actual = r#"a = @{ "a" | "b" ~ "c" }"#.try_pest_to_element()?;
// here is the equivalent Ion element
let ion_text = r#"{
a: {
type: atomic,
expression:
(choice
(string exact "a")
(sequence
(string exact "b")
(string exact "c")
)
)
}
}"#;
let expected = element_reader().read_one(ion_text.as_bytes())?;
// these should be equivalent
assert_eq!(expected, actual);
Ok(())
}
Re-exports§
pub use result::*;
Modules§
Traits§
- Pest
ToElement - Infallible conversion of a Pest grammar (or part of a grammar) into Ion
Element
. - TryPest
ToElement - Converts representation of a Pest grammar (or part of a grammar) into Ion
Element
.