Skip to content

Commit f45e09e

Browse files
committed
chore: add python method
1 parent 7293c9e commit f45e09e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/seclang_parser/listener.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class ParserResult:
1414
"""Stores results from parsing for test validation."""
1515

16+
comments: list[str] = field(default_factory=list)
1617
variables: list[str] = field(default_factory=list)
1718
negated_var_count: int = 0
1819
collection_length_count: int = 0
@@ -125,3 +126,10 @@ def enterCtl_action(self, ctx: SecLangParser.Ctl_actionContext):
125126

126127
def enterCtl_id(self, ctx: SecLangParser.Ctl_idContext):
127128
self.results.directive_values.append(ctx.getText())
129+
130+
def enterComment(self, ctx: SecLangParser.CommentContext):
131+
# ctx.COMMENT() can be None if there is only a HASH without comment text
132+
if ctx.COMMENT() is not None:
133+
self.results.comments.append(ctx.COMMENT().getText())
134+
else:
135+
self.results.comments.append("")

0 commit comments

Comments
 (0)