|
11 | 11 | from collections import deque |
12 | 12 | from .dot2c import Dot2c |
13 | 13 | from .generator import Monitor |
14 | | -from .automata import _EventConstraintKey, _StateConstraintKey |
| 14 | +from .automata import _EventConstraintKey, _StateConstraintKey, AutomataError |
15 | 15 |
|
16 | 16 |
|
17 | 17 | class dot2k(Monitor, Dot2c): |
@@ -166,14 +166,14 @@ class da2k(dot2k): |
166 | 166 | def __init__(self, *args, **kwargs): |
167 | 167 | super().__init__(*args, **kwargs) |
168 | 168 | if self.is_hybrid_automata(): |
169 | | - raise ValueError("Detected hybrid automata, use the 'ha' class") |
| 169 | + raise AutomataError("Detected hybrid automata, use the 'ha' class") |
170 | 170 |
|
171 | 171 | class ha2k(dot2k): |
172 | 172 | """Hybrid automata only""" |
173 | 173 | def __init__(self, *args, **kwargs): |
174 | 174 | super().__init__(*args, **kwargs) |
175 | 175 | if not self.is_hybrid_automata(): |
176 | | - raise ValueError("Detected deterministic automata, use the 'da' class") |
| 176 | + raise AutomataError("Detected deterministic automata, use the 'da' class") |
177 | 177 | self.trace_h = self._read_template_file("trace_hybrid.h") |
178 | 178 | self.__parse_constraints() |
179 | 179 |
|
@@ -266,22 +266,22 @@ def __validate_constraint(self, key: tuple[int, int] | int, constr: str, |
266 | 266 | # state constraints are only used for expirations (e.g. clk<N) |
267 | 267 | if self.is_event_constraint(key): |
268 | 268 | if not rule and not reset: |
269 | | - raise ValueError("Unrecognised event constraint " |
270 | | - f"({self.states[key[0]]}/{self.events[key[1]]}: {constr})") |
| 269 | + raise AutomataError("Unrecognised event constraint " |
| 270 | + f"({self.states[key[0]]}/{self.events[key[1]]}: {constr})") |
271 | 271 | if rule and (rule["env"] in self.env_types and |
272 | 272 | rule["env"] not in self.env_stored): |
273 | | - raise ValueError("Clocks in hybrid automata always require a storage" |
274 | | - f" ({rule["env"]})") |
| 273 | + raise AutomataError("Clocks in hybrid automata always require a storage" |
| 274 | + f" ({rule["env"]})") |
275 | 275 | else: |
276 | 276 | if not rule: |
277 | | - raise ValueError("Unrecognised state constraint " |
278 | | - f"({self.states[key]}: {constr})") |
| 277 | + raise AutomataError("Unrecognised state constraint " |
| 278 | + f"({self.states[key]}: {constr})") |
279 | 279 | if rule["env"] not in self.env_stored: |
280 | | - raise ValueError("State constraints always require a storage " |
281 | | - f"({rule["env"]})") |
| 280 | + raise AutomataError("State constraints always require a storage " |
| 281 | + f"({rule["env"]})") |
282 | 282 | if rule["op"] not in ["<", "<="]: |
283 | | - raise ValueError("State constraints must be clock expirations like" |
284 | | - f" clk<N ({rule.string})") |
| 283 | + raise AutomataError("State constraints must be clock expirations like" |
| 284 | + f" clk<N ({rule.string})") |
285 | 285 |
|
286 | 286 | def __parse_constraints(self) -> None: |
287 | 287 | self.guards: dict[_EventConstraintKey, str] = {} |
|
0 commit comments