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