#pest-grammar #pest-parser #pest #ascii #tree

pest_ascii_tree

Helper crates converting the parsing result of any pest grammar into an ascii tree

1 unstable release

0.1.0 Oct 14, 2019

#1658 in Text processing

Download history 911/week @ 2024-03-13 729/week @ 2024-03-20 722/week @ 2024-03-27 900/week @ 2024-04-03 985/week @ 2024-04-10 1009/week @ 2024-04-17 844/week @ 2024-04-24 1017/week @ 2024-05-01 1036/week @ 2024-05-08 873/week @ 2024-05-15 830/week @ 2024-05-22 1056/week @ 2024-05-29 1763/week @ 2024-06-05 1580/week @ 2024-06-12 1067/week @ 2024-06-19 1220/week @ 2024-06-26

5,799 downloads per month
Used in 4 crates

MIT/Apache

12KB
185 lines

pest_ascii_tree

pest_ascii_tree

This is a small helper crate useful for quickly debugging your pest grammar. The rules found by parsing the file are formated into an ascii_tree.

It is useful, you you want to quickly debug your grammar without having to write specialized code for handling the Pairs iterator returned by your pest parser.

Example, for whan an output might look like.

 expr
 ├─ expr
 │  ├─ val "u"
 │  ├─ op "+"
 │  └─ expr
 │     ├─ val "v"
 │     ├─ op "+"
 │     └─ val "w"
 ├─ op "+"
 ├─ expr
 │  ├─ val "x"
 │  ├─ op "+"
 │  └─ val "y"
 ├─ op "+"
 └─ val "z"

Please, that the EOI rule is skipped.


lib.rs:

pest_ascii_tree

This is a small helper crate useful for quickly debugging your pest grammar. The rules found by parsing the file are formated into an ascii_tree.

It is useful, you you want to quickly debug your grammar without having to write specialized code for handling the Pairs iterator returned by your pest parser.

Example, for whan an output might look like.

  expr
  ├─ expr
  │  ├─ val "u"
  │  ├─ op "+"
  │  └─ expr
  │     ├─ val "v"
  │     ├─ op "+"
  │     └─ val "w"
  ├─ op "+"
  ├─ expr
  │  ├─ val "x"
  │  ├─ op "+"
  │  └─ val "y"
  ├─ op "+"
  └─ val "z"
 

Please, that the EOI rule is skipped.

Dependencies

~2.2–3MB
~59K SLoC