Re: [RFC PATCH 10/17] verification/rvgen: Add support for Hybrid Automata
From: Gabriele Monaco <gmonaco@redhat.com>
Date: 2025-08-21 13:15:56
Also in:
lkml
On Thu, 2025-08-21 at 14:38 +0200, Nam Cao wrote:
On Thu, Aug 14, 2025 at 05:08:02PM +0200, Gabriele Monaco wrote:quoted
+import reOh no..
I was tempted to suggest rewriting the dot parser with regex but I guess I'll hold that back!
quoted
+from typing import Iterator class Automata: """Automata class: Reads a dot file and part it as an automata. + It supports both deterministic and hybrid automata. + Attributes: dot_file: A dot file with an state_automaton definition. """ invalid_state_str = "INVALID_STATE" + # val can be numerical, uppercase (constant or macro), lowercase (parameter or function) + # only numerical values should have units + constraint_rule = re.compile(r""" + ^ + (?P<env>[a-zA-Z_][a-zA-Z0-9_]+) # C-like identifier for the env var^ My regex knowledge is not that great, but I think this is not standard regex syntax, right? I'm guessing this is Python's feature to store this group into "env"? I think my brain's battery just run out, I will continue with the review another day.
Yeah, you got that right. That P is kinda python specific, but it seems other regex variants (perl/PCRE) work with the same notation, there's another notation supported by browsers and .NET without the P. Unfortunately regex are as standard as many other things in the unix world [1].. I tried to be as verbose as possible in this regex and I think a crafted parser would look much uglier, but I'd appreciate your comments! Thanks, Gabriele [1] - https://xkcd.com/927/