polka 0.1.2

A dot language parser for Rust; based on Parser Expression Grammar (PEG) using the excellent pest crate as the underpinning.
Documentation

Polka

A dot language parser for Rust; based on Parser Expression Grammar (PEG) using the excellent pest crate as the underpinning.


Usage (as a Rust Library)

  1. Add this to your Cargo.toml:
  [dependencies]
  rand = "0.6"
  1. Call the parser function by passing an input String
  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,
  //     graph_type: Some(
  //         Digraph,
  //     ),
  //     id: None,
  //     statements: [
  //         EdgeStatement(
  //             EdgeStatement {
  //                 edge: NodeId(
  //                     NodeId {
  //                         node_id: "a",
  //                         port: None,
  //                     },
  //                 ),
  //                 edge_rhs_list: [
  //                     EdgeRhs {
  //                         edge_op: Arrow,
  //                         edge: NodeId(
  //                             NodeId {
  //                                 node_id: "b",
  //                                 port: None,
  //                             },
  //                         ),
  //                     },
  //                     EdgeRhs {
  //                         edge_op: Arrow,
  //                         edge: NodeId(
  //                             NodeId {
  //                                 node_id: "c",
  //                                 port: None,
  //                             },
  //                         ),
  //                     },
  //                 ],
  //                 attributes: None,
  //             },
  //         ),
  //     ],
  // }

Known Limitations:

  1. HTML ids are currently not supported.

License

MIT