Crate dot_parser
source ·Expand description
This crate is a parser for DOT/Graphviz files.
The parser strictly sticks to the grammar specified
here. The main structure is
Graph, which can be built from a DOT file. The fields (and subfields) of
the structure coincide with rules of the grammar.
The crate contains two modules: ast and canonical. Both contain a
Graph structure that represent a DOT graph. In the ast module, the
Graph structure is an abstract syntax tree of a given DOT graph. However,
in practice, such graph is not easy to work with. Therefore, the Graph
structure in the canonical module aims to provide a canonic representation
of the graph, much easier to work with.
Modules§
- This module implements an Abstract Syntax Tree for Dot graphs. The main structure is
Graph, which corresponds to thegraphnon-terminal in the grammar. - This modules implement “Canonical graphs”. This is motivated by the fact that graphs parsed naively may be difficult to work with, from a programming viewpoint: typically,
attr_listin the grammar are defined as “[ID = ID, …][ID = ID, …]”. Therefore, we may want to flatten such structures. This is done in thecanonicalmodule. - This module represents a flat graph, i.e. a graph without subgraph. To flatten the graph, existing subgraphs are transformed into their individual nodes: e.g. the statement
a -> { b c }is transformed into two statements:a -> banda -> c. Edge attributes are copied: therefore, a graph can be flattened only if the attribute typeAimplementsCopy.