From 4cccbf77fa7f3e7df0c3d12993fb4edda869461e Mon Sep 17 00:00:00 2001 From: Aki Van Ness Date: Thu, 31 Mar 2022 08:50:49 -0400 Subject: [PATCH] sby: core: Added preliminary support for the `[setup]` section --- sbysrc/sby_core.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 366817f..599e7bc 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -247,6 +247,7 @@ class SbyConfig: def __init__(self): self.options = dict() self.engines = list() + self.setup = dict() self.script = list() self.autotune_config = None self.files = dict() @@ -294,6 +295,12 @@ class SbyConfig: self.error(f"sby file syntax error: '[engines]' section does not accept any arguments. got {args}") continue + if entries[0] == "setup": + mode = "setup" + if len(self.setup) != 0 or len(entries) != 1: + self.error(f"sby file syntax error: {line}") + continue + if section == "script": mode = "script" if len(self.script) != 0: @@ -351,6 +358,28 @@ class SbyConfig: self.engines.append(entries) continue + if mode == "setup": + self.error("[setup] section not yet supported") + kvp = line.split() + if kvp[0] not in ("cutpoint", "disable", "enable", "assume", "define"): + self.error(f"sby file syntax error: {line}") + else: + stmt = kvp[0] + if stmt == 'define': + if 'define' not in self.setup: + self.setup['define'] = {} + + if len(kvp[1:]) < 2: + self.error(f"sby file syntax error: {line}") + elif kvp[1][0] != '@': + self.error(f"sby file syntax error: {line}") + else: + name = kvp[1][1:] + self.setup['define'][name] = kvp[2:] + else: + self.setup[key] = kvp[1:] + continue + if mode == "script": self.script.append(line) continue