mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-05 14:04:07 +00:00
some cleanup, added some rough parser tests, and started altering the engines section
This commit is contained in:
parent
0ab158eea1
commit
a0d366e58a
|
@ -246,7 +246,8 @@ class SbyAbort(BaseException):
|
||||||
class SbyConfig:
|
class SbyConfig:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.options = dict()
|
self.options = dict()
|
||||||
self.engines = list()
|
# Define a default case for the engine block
|
||||||
|
self.engines = list() # { None: list() }
|
||||||
self.setup = dict()
|
self.setup = dict()
|
||||||
self.stage = dict()
|
self.stage = dict()
|
||||||
self.script = list()
|
self.script = list()
|
||||||
|
@ -257,6 +258,7 @@ class SbyConfig:
|
||||||
|
|
||||||
def parse_config(self, f):
|
def parse_config(self, f):
|
||||||
mode = None
|
mode = None
|
||||||
|
engine_mode = None
|
||||||
|
|
||||||
for line in f:
|
for line in f:
|
||||||
raw_line = line
|
raw_line = line
|
||||||
|
@ -290,18 +292,26 @@ class SbyConfig:
|
||||||
|
|
||||||
if section == "engines":
|
if section == "engines":
|
||||||
mode = "engines"
|
mode = "engines"
|
||||||
if len(self.engines) != 0:
|
if len(entries) > 2:
|
||||||
self.error(f"sby file syntax error: '[engines]' section already defined")
|
self.error(f"sby file syntax error: [engine] sections expects at most 1 argument, got more '{line}'")
|
||||||
if args is not None:
|
|
||||||
self.error(f"sby file syntax error: '[engines]' section does not accept any arguments. got {args}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
if len(entries) == 2 and entries[1] not in ("bmc", "prove", "cover", "live"):
|
||||||
|
self.error(f"sby file syntax error: Expected one of 'bmc, prove, cover, live' not '{entries[1]}'")
|
||||||
|
elif len(entries) == 2:
|
||||||
|
pass
|
||||||
|
# if entries[1] not in self.engines:
|
||||||
|
# self.engines[entries[1]] = list()
|
||||||
|
# else:
|
||||||
|
# self.error(f"Already defined engine block for mode '{entries[1]}'")
|
||||||
|
|
||||||
|
# [setup]
|
||||||
if entries[0] == "setup":
|
if entries[0] == "setup":
|
||||||
mode = "setup"
|
mode = "setup"
|
||||||
if len(self.setup) != 0 or len(entries) != 1:
|
if len(self.setup) != 0 or len(entries) != 1:
|
||||||
self.error(f"sby file syntax error: {line}")
|
self.error(f"sby file syntax error: {line}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# [stage <NAME> (PARENTS...)]
|
||||||
if entries[0] == "stage":
|
if entries[0] == "stage":
|
||||||
mode = "stage"
|
mode = "stage"
|
||||||
if len(entries) > 3 or len(entries) < 2:
|
if len(entries) > 3 or len(entries) < 2:
|
||||||
|
@ -377,11 +387,11 @@ class SbyConfig:
|
||||||
|
|
||||||
if mode == "engines":
|
if mode == "engines":
|
||||||
entries = line.split()
|
entries = line.split()
|
||||||
|
# self.engines[engine_mode].append(entries)
|
||||||
self.engines.append(entries)
|
self.engines.append(entries)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if mode == "setup":
|
if mode == "setup":
|
||||||
self.error("[setup] section not yet supported")
|
|
||||||
kvp = line.split()
|
kvp = line.split()
|
||||||
if kvp[0] not in ("cutpoint", "disable", "enable", "assume", "define"):
|
if kvp[0] not in ("cutpoint", "disable", "enable", "assume", "define"):
|
||||||
self.error(f"sby file syntax error: {line}")
|
self.error(f"sby file syntax error: {line}")
|
||||||
|
@ -403,7 +413,6 @@ class SbyConfig:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if mode == "stage":
|
if mode == "stage":
|
||||||
self.error("[stage] section not yet supported")
|
|
||||||
kvp = line.split()
|
kvp = line.split()
|
||||||
if key is None or key == '':
|
if key is None or key == '':
|
||||||
self.error(f"sby file syntax error: in stage mode but unknown key")
|
self.error(f"sby file syntax error: in stage mode but unknown key")
|
||||||
|
|
4
tests/parser/.gitignore
vendored
Normal file
4
tests/parser/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
*
|
||||||
|
!Makefile
|
||||||
|
!.gitignore
|
||||||
|
!*.sby
|
2
tests/parser/Makefile
Normal file
2
tests/parser/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
SUBDIR=parser
|
||||||
|
include ../make/subdir.mk
|
13
tests/parser/engines.sby
Normal file
13
tests/parser/engines.sby
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[options]
|
||||||
|
mode bmc
|
||||||
|
depth 1
|
||||||
|
expect error
|
||||||
|
|
||||||
|
[engines]
|
||||||
|
smtbmc
|
||||||
|
|
||||||
|
[engines bmc]
|
||||||
|
smtbmc
|
||||||
|
|
||||||
|
[engines cover]
|
||||||
|
smtbmc
|
4
tests/parser/options.sby
Normal file
4
tests/parser/options.sby
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[options]
|
||||||
|
mode bmc
|
||||||
|
depth 1
|
||||||
|
expect error
|
8
tests/parser/setup.sby
Normal file
8
tests/parser/setup.sby
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[options]
|
||||||
|
mode bmc
|
||||||
|
depth 1
|
||||||
|
expect error
|
||||||
|
|
||||||
|
|
||||||
|
[setup]
|
||||||
|
enable *
|
12
tests/parser/stage.sby
Normal file
12
tests/parser/stage.sby
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[options]
|
||||||
|
mode bmc
|
||||||
|
depth 1
|
||||||
|
expect error
|
||||||
|
|
||||||
|
|
||||||
|
[stage stage_1]
|
||||||
|
mode prove
|
||||||
|
depth 20
|
||||||
|
timeout 60
|
||||||
|
expect error
|
||||||
|
enable *
|
Loading…
Reference in a new issue