1use core::range::Range;
3
4#[derive(Debug, Clone, PartialEq)]
6pub struct DotRoot {
7 pub graphs: Vec<Graph>,
8}
9
10#[derive(Debug, Clone, PartialEq)]
12pub struct Graph {
13 pub strict: bool,
14 pub graph_type: GraphType,
15 pub id: Option<String>,
16 pub statements: Vec<Statement>,
17 pub span: Range<usize>,
18}
19
20#[derive(Debug, Clone, PartialEq)]
22pub enum GraphType {
23 Graph,
24 Digraph,
25}
26
27#[derive(Debug, Clone, PartialEq)]
29pub enum Statement {
30 Node(NodeStatement),
31 Edge(EdgeStatement),
32 Attribute(AttributeStatement),
33 Subgraph(SubgraphStatement),
34 Assignment(AssignmentStatement),
35}
36
37#[derive(Debug, Clone, PartialEq)]
39pub struct NodeStatement {
40 pub node_id: NodeId,
41 pub attributes: Vec<Attribute>,
42 pub span: Range<usize>,
43}
44
45#[derive(Debug, Clone, PartialEq)]
47pub struct EdgeStatement {
48 pub left: EdgeOperand,
49 pub edges: Vec<(EdgeOp, EdgeOperand)>,
50 pub attributes: Vec<Attribute>,
51 pub span: Range<usize>,
52}
53
54#[derive(Debug, Clone, PartialEq)]
56pub enum EdgeOperand {
57 Node(NodeId),
58 Subgraph(SubgraphStatement),
59}
60
61#[derive(Debug, Clone, PartialEq)]
63pub enum EdgeOp {
64 Directed, Undirected, }
67
68#[derive(Debug, Clone, PartialEq)]
70pub struct AttributeStatement {
71 pub target: AttributeTarget,
72 pub attributes: Vec<Attribute>,
73 pub span: Range<usize>,
74}
75
76#[derive(Debug, Clone, PartialEq)]
78pub enum AttributeTarget {
79 Graph,
80 Node,
81 Edge,
82}
83
84#[derive(Debug, Clone, PartialEq)]
86pub struct SubgraphStatement {
87 pub id: Option<String>,
88 pub statements: Vec<Statement>,
89 pub span: Range<usize>,
90}
91
92#[derive(Debug, Clone, PartialEq)]
94pub struct AssignmentStatement {
95 pub id: String,
96 pub value: String,
97 pub span: Range<usize>,
98}
99
100#[derive(Debug, Clone, PartialEq)]
102pub struct NodeId {
103 pub id: String,
104 pub port: Option<Port>,
105 pub span: Range<usize>,
106}
107
108#[derive(Debug, Clone, PartialEq)]
110pub struct Port {
111 pub id: Option<String>,
112 pub compass: Option<Compass>,
113 pub span: Range<usize>,
114}
115
116#[derive(Debug, Clone, PartialEq)]
118pub enum Compass {
119 N,
120 NE,
121 E,
122 SE,
123 S,
124 SW,
125 W,
126 NW,
127 C,
128}
129
130#[derive(Debug, Clone, PartialEq)]
132pub struct Attribute {
133 pub name: String,
134 pub value: Option<String>,
135 pub span: Range<usize>,
136}