[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b06da1ceee8a7f4efe97c6b46fe26f9f68d8b18f.camel@redhat.com>
Date: Thu, 21 Aug 2025 15:15:50 +0200
From: Gabriele Monaco <gmonaco@...hat.com>
To: Nam Cao <namcao@...utronix.de>
Cc: linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
linux-trace-kernel@...r.kernel.org, Tomas Glozar <tglozar@...hat.com>, Juri
Lelli <jlelli@...hat.com>, Clark Williams <williams@...hat.com>, John Kacur
<jkacur@...hat.com>
Subject: Re: [RFC PATCH 10/17] verification/rvgen: Add support for Hybrid
Automata
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:
> > +import re
>
> Oh no..
I was tempted to suggest rewriting the dot parser with regex but I
guess I'll hold that back!
>
> > +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/
Powered by blists - more mailing lists