1use serde::{Serialize, Deserialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct Property {
6 pub sign: PropertySign,
7 pub name: String,
8}
9
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub enum PropertySign {
13 Plus,
14 Minus,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19pub struct Transition {
20 pub from: String,
21 pub to: String,
22 pub properties: Vec<Property>,
23}
24
25#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
27pub struct Graph {
28 pub name: String,
29 pub transitions: Vec<Transition>,
30}
31
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
34pub struct GraphState {
35 pub graph_name: String,
36 pub current_nodes: Vec<String>,
37}
38
39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
41pub struct Model {
42 pub name: String,
43 pub graphs: Vec<Graph>,
44 pub state: Option<Vec<GraphState>>,
45}
46
47#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
49pub struct Formula {
50 pub name: String,
51 pub expression: FormulaExpr,
52}
53
54#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
56pub enum FormulaExpr {
57 True,
59 False,
60 And(Box<FormulaExpr>, Box<FormulaExpr>),
62 Or(Box<FormulaExpr>, Box<FormulaExpr>),
63 Not(Box<FormulaExpr>),
64 Paren(Box<FormulaExpr>),
66 Diamond(Vec<Property>, Box<FormulaExpr>),
68 Box(Vec<Property>, Box<FormulaExpr>),
69}
70
71impl Model {
72 pub fn new(name: String) -> Self {
74 Self {
75 name,
76 graphs: Vec::new(),
77 state: None,
78 }
79 }
80
81 pub fn add_graph(&mut self, graph: Graph) {
83 self.graphs.push(graph);
84 }
85
86 pub fn set_state(&mut self, state: Vec<GraphState>) {
88 self.state = Some(state);
89 }
90}
91
92impl Graph {
93 pub fn new(name: String) -> Self {
95 Self {
96 name,
97 transitions: Vec::new(),
98 }
99 }
100
101 pub fn add_transition(&mut self, transition: Transition) {
103 self.transitions.push(transition);
104 }
105}
106
107impl Transition {
108 pub fn new(from: String, to: String) -> Self {
110 Self {
111 from,
112 to,
113 properties: Vec::new(),
114 }
115 }
116
117 pub fn add_property(&mut self, property: Property) {
119 self.properties.push(property);
120 }
121}
122
123impl Property {
124 pub fn new(sign: PropertySign, name: String) -> Self {
126 Self { sign, name }
127 }
128}
129
130impl GraphState {
131 pub fn new(graph_name: String, current_nodes: Vec<String>) -> Self {
133 Self {
134 graph_name,
135 current_nodes,
136 }
137 }
138}
139
140impl Formula {
141 pub fn new(name: String, expression: FormulaExpr) -> Self {
143 Self { name, expression }
144 }
145}
146
147#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
149pub enum TopLevelItem {
150 Model(Model),
151 Formula(Formula),
152}