Skip to content

Commit

Permalink
Merge pull request #379 from s-hadinger/lexer_no_terminated_comment
Browse files Browse the repository at this point in the history
Error message for unterminated comments
  • Loading branch information
skiars committed Nov 13, 2023
2 parents 8fcd2e6 + 224b3ca commit 234af61
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/be_lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ static void skip_comment(blexer *lexer)
{
next(lexer); /* skip '#' */
if (lgetc(lexer) == '-') { /* mult-line comment */
int lno = lexer->linenumber;
int mark, c = 'x'; /* skip first '-' (#- ... -#) */
do {
mark = c == '-';
Expand All @@ -269,6 +270,9 @@ static void skip_comment(blexer *lexer)
}
c = next(lexer);
} while (!(mark && c == '#') && c != EOS);
if (c == EOS) {
be_lexerror(lexer, be_pushfstring(lexer->vm, "unterminated comment block started in line %d", lno));
}
next(lexer); /* skip '#' */
} else { /* line comment */
while (!is_newline(lgetc(lexer)) && lgetc(lexer)) {
Expand Down

0 comments on commit 234af61

Please sign in to comment.