From: Luke Kenneth Casson Leighton Date: Fri, 27 Oct 2023 14:00:43 +0000 (+0100) Subject: remove use of regex (this code is REQUIRED to be SIMPLE) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efe5dc98ab54b69efa988a90d5ebce640d652d16;p=openpower-isa.git remove use of regex (this code is REQUIRED to be SIMPLE) --- diff --git a/src/openpower/decoder/pseudo/pagereader.py b/src/openpower/decoder/pseudo/pagereader.py index 73173cfc..ed647a6d 100644 --- a/src/openpower/decoder/pseudo/pagereader.py +++ b/src/openpower/decoder/pseudo/pagereader.py @@ -66,14 +66,6 @@ def get_isa_dir(): return os.path.join(fdir, "openpower", "isa") -pattern_opcode = r"[A-Za-z0-9_\.]+\.?" -pattern_dynamic = r"[A-Za-z0-9_]+(?:\([A-Za-z0-9_]+\))*" -pattern_static = r"[A-Za-z0-9]+\=[01]" -regex_opcode = re.compile(f"^{pattern_opcode}$") -regex_dynamic = re.compile(f"^{pattern_dynamic}(?:,{pattern_dynamic})*$") -regex_static = re.compile(f"^\({pattern_static}(?:\s{pattern_static})*\)$") - - def operands(opcode, desc): if desc is None: return @@ -281,19 +273,13 @@ class ISA: rest = l[1:].strip() (opcode, _, rest) = map(str.strip, rest.partition(" ")) - if regex_opcode.match(opcode) is None: - raise IOError(repr(opcode)) opcode = [opcode] (dynamic, _, rest) = map(str.strip, rest.partition(" ")) - if regex_dynamic.match(dynamic) is None and dynamic: - raise IOError(f"{l!r}: {dynamic!r}") if dynamic: opcode.append(dynamic.split(",")) static = rest - if regex_static.match(static) is None and static: - raise IOError(f"{l!r}: {static!r}") if static: opcode.extend(static[1:-1].split(" "))