diff --git a/trlc/ast.py b/trlc/ast.py index dbe71ec..897caed 100644 --- a/trlc/ast.py +++ b/trlc/ast.py @@ -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 = { @@ -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 diff --git a/trlc/parser.py b/trlc/parser.py index 1f4797a..1fdff48 100644 --- a/trlc/parser.py +++ b/trlc/parser.py @@ -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) @@ -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)