Skip to content

Commit c84cb73

Browse files
committed
Fix multiline comments
1 parent 684fca5 commit c84cb73

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

playground/umka.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/umka_lexer.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,22 @@ static void lexSingleLineComment(Lexer *lex)
266266
static void lexMultiLineComment(Lexer *lex)
267267
{
268268
unsigned char ch = lexChar(lex);
269-
bool asteriskFound = false;
270269

271-
while (ch && !(ch == '/' && asteriskFound))
270+
while (ch)
272271
{
273-
asteriskFound = false;
274-
275-
while (ch && ch != '*')
272+
if (ch == '*')
273+
{
276274
ch = lexChar(lex);
277-
278-
if (ch == '*') asteriskFound = true;
275+
if (ch == '/')
276+
break;
277+
}
279278
ch = lexChar(lex);
280279
}
281280

282-
ch = lexChar(lex);
281+
if (!ch)
282+
lex->error->handler(lex->error->context, "Unterminated comment");
283+
284+
lexChar(lex);
283285
}
284286

285287

0 commit comments

Comments
 (0)