A dot language parser for Rust; based on Parser Expression Grammar (PEG) using the excellent pest crate as the underpinning.
Add this to your Cargo.toml
:
toml
[dependencies]
rand = "0.6"
Call the parser
function by passing an input String
```rust extern crate polka; use polka::parse;
fn main() { let input = "digraph { a -> b -> c }".to_string(); println!("Polka AST\n: {:?}", parse(input).unwrap()); }
// Polka AST: // Graph { // strict: false, // graphtype: Some( // Digraph, // ), // id: None, // statements: [ // EdgeStatement( // EdgeStatement { // edge: NodeId( // NodeId { // nodeid: "a", // port: None, // }, // ), // edgerhslist: [ // EdgeRhs { // edgeop: Arrow, // edge: NodeId( // NodeId { // nodeid: "b", // port: None, // }, // ), // }, // EdgeRhs { // edgeop: Arrow, // edge: NodeId( // NodeId { // nodeid: "c", // port: None, // }, // ), // }, // ], // attributes: None, // }, // ), // ], // } ```