Skip to content

Commit

Permalink
remove duplicity in TreeToObjects model
Browse files Browse the repository at this point in the history
  • Loading branch information
Marketa Opichalova committed Feb 26, 2024
1 parent b446b2a commit a3eca18
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions eBCSgen/Parsing/ParseBCSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,30 +647,24 @@ def model(self, matches):
for match in matches:
if type(match) == dict:
key, value = list(match.items())[0]
if key == "rules":
rules.update(value)
if key == "inits":
inits.update(value)
if key == "definitions":
definitions.update(value)
if key == "regulation":
if regulation:
raise UnspecifiedParsingError("Multiple regulations")
regulation = value
elif isinstance(match, Tree) and match.data == "sections":
if isinstance(match.children[0], Tree):
continue
key, value = list(match.children[0].items())[0]
if key == "rules":
rules.update(value)
if key == "inits":
inits.update(value)
if key == "definitions":
definitions.update(value)
if key == "regulation":
if regulation:
raise UnspecifiedParsingError("Multiple regulations")
regulation = value
else:
continue

if key == "rules":
rules.update(value)
elif key == "inits":
inits.update(value)
elif key == "definitions":
definitions.update(value)
elif key == "regulation":
if regulation:
raise UnspecifiedParsingError("Multiple regulations")
regulation = value

params = self.params - set(definitions)
return Model(rules, inits, definitions, params, regulation)

Expand Down

0 comments on commit a3eca18

Please sign in to comment.