2 releases
0.1.2 | Jun 25, 2019 |
---|---|
0.1.1 | Jun 18, 2019 |
#39 in #dot
47KB
1.5K
SLoC
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)
- Add this to your
Cargo.toml
:
[dependencies]
rand = "0.6"
- Call the
parser
function by passing an inputString
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:
- HTML ids are currently not supported.
License
Dependencies
~1MB
~11K SLoC