pub fn into_ascii_tree<R>(pairs: Pairs<'_, R>) -> Result<String, Error>where
R: RuleType,
Expand description
Formats the parsing result by pest into an ascii_tree
into a String
.
§Error
If the internal call to ascii_tree::write_tree
failed, the error
variant is passed to the caller.
§Examples
ⓘ
let result = pest_ascii_tree::into_ascii_tree(
ExpressionParser::parse(Rule::expr, "(u + (v + w)) + (x + y) + z")?)?;
assert_eq!(
result,
String::new()
+ " expr\n"
+ " ├─ expr\n"
+ " │ ├─ val \"u\"\n"
+ " │ ├─ op \"+\"\n"
+ " │ └─ expr\n"
+ " │ ├─ val \"v\"\n"
+ " │ ├─ op \"+\"\n"
+ " │ └─ val \"w\"\n"
+ " ├─ op \"+\"\n"
+ " ├─ expr\n"
+ " │ ├─ val \"x\"\n"
+ " │ ├─ op \"+\"\n"
+ " │ └─ val \"y\"\n"
+ " ├─ op \"+\"\n"
+ " └─ val \"z\"\n"
);