Skip to content

Commit

Permalink
[cocas] Add check for empty section attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kapkekes committed Oct 19, 2024
1 parent da25c05 commit 74c5b90
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cocas/assembler/ast_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,21 @@ def check_label_is_ext(label: LabelDeclarationNode):
raise AssemblerException(AssemblerExceptionTag.ASM, label.location.file, label.location.line,
"Only external labels are allowed at the top of a file")

def visitSection_attr(self, ctx: AsmParser.Section_attrContext) -> str:
def visitSection_attr(self, ctx: AsmParser.Section_attrContext | None) -> str | None:
if ctx is None:
return None

return ctx.WORD().getText()

def visitSection_attrs(self, ctx: AsmParser.Section_attrsContext) -> list[str]:
return [self.visitSection_attr(section_attr) for section_attr in ctx.section_attr()]
def visitSection_attrs(self, ctx: AsmParser.Section_attrsContext | None) -> list[str]:
if ctx is None:
return []

return [
attribute
for sa in ctx.section_attr()
if (attribute := self.visitSection_attr(sa)) is not None
]

def visitAbsoluteSection(self, ctx: AsmParser.AbsoluteSectionContext) -> AbsoluteSectionNode:
header = ctx.asect_header()
Expand Down

0 comments on commit 74c5b90

Please sign in to comment.