Skip to content

Commit

Permalink
iteration api - by section #12
Browse files Browse the repository at this point in the history
  • Loading branch information
mugdhadhole1 committed May 24, 2024
1 parent 3188b09 commit 61317ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions trlc/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ def __init__(self, name, location, n_typ, section, n_package):
# lobster-trace: LRM.Section_Declaration
# lobster-trace: LRM.Unspecified_Optional_Components
assert isinstance(n_typ, Record_Type)
assert isinstance(section, Section) or section is None
assert isinstance(section, list) or section is None
assert isinstance(n_package, Package)
super().__init__(name, location, n_typ)
self.field = {
Expand Down Expand Up @@ -2983,7 +2983,7 @@ class Section(Entity):
"""
def __init__(self, name, location, parent):
super().__init__(name, location)
assert isinstance(parent, Section) or parent is None
assert isinstance(parent, list) or parent is None
self.parent = parent

def dump(self, indent=0): # pragma: no cover
Expand Down
16 changes: 7 additions & 9 deletions trlc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,14 +1519,12 @@ def parse_section_declaration(self):
self.match_kw("section")
t_section = self.ct
self.match("STRING")
if self.section:
sec = ast.Section(name = self.ct.value,
location = self.ct.location,
parent = self.section[-1])
else:
sec = ast.Section(name = self.ct.value,
location = self.ct.location,
parent = None)

self.match_kw("section")
self.match("STRING")
sec = ast.Section(name = self.ct.value,
location = self.ct.location,
parent = self.section)
sec.set_ast_link(self.ct)
sec.set_ast_link(t_section)
self.section.append(sec)
Expand Down Expand Up @@ -1762,7 +1760,7 @@ def parse_record_object_declaration(self):
name = self.ct.value,
location = self.ct.location,
n_typ = r_typ,
section = self.section[-1] if self.section else None,
section = self.section if self.section else None,
n_package = self.cu.package)
self.cu.package.symbols.register(self.mh, obj)
obj.set_ast_link(self.ct)
Expand Down

0 comments on commit 61317ae

Please sign in to comment.