Expand description
A library for parsing graphviz dotfiles into an AST format
This crate provides a basic parsing capability for the graphviz file format specified here
What this crate provides is an AST format, and a parser to translate from graphviz files into that ast format. This means that this crate doesn’t do all that much on its own, as it still takes some effort to then utilize the AST format rather than the raw graphviz file strings themselves.
To parse dotfiles using this using this dotfile parser, we could simply use the following code
use graphviz_parser::DotGraph;
use std::str::FromStr;
// read string from file or network
let dotfile_str = "digraph G { A -> { B, D } } ";
let graph = DotGraph::from_str(dotfile_str).unwrap();
match graph {
DotGraph::Directed(g) => {
assert_eq!(g.id, String::from("G"));
},
_ => { unreachable!() } ,
}
Modules§
- ast_
nodes - The AST nodes module provides all the ast components that comprise a graphviz file. These node types map quite closely to the graphviz documentation provided here: link
Enums§
- DotGraph
- DotGraph is the toplevel graph construct we parse into.