Slide 113
Slide 113 text
def parse_comment_statement(text, index):
is_success, next_index = expect_keyword("//", text, index)
if not is_success:
return None, index
comment_content_chars = []
while True:
comment_content_char, next_index = \
expect_either(uppercase + [" ", "_"], text, next_index)
if comment_content_char is None:
break
comment_content_chars.append(comment_content_char)
is_success, next_index = expect_keyword("\n", text, next_index)
if not is_success:
return None, index
comment_content_chars = "".join(comment_content_chars)
return CommentStatementNode(comment_content_chars), next_index
<ίϝϯτจ> := "//" [A-Z_ ]* "\n"