remove stacking of block comments (#1022)

This commit is contained in:
Islon Scherer
2025-03-12 18:24:38 +01:00
committed by GitHub
parent 8b7d59e4e4
commit 1cd0549bd6
2 changed files with 6 additions and 7 deletions

View File

@@ -575,11 +575,11 @@ public class Lexer {
private void lexBlockComment() {
if (lookahead == EOF) throw unexpectedEndOfFile();
var prev = nextChar();
// block comments in Pkl can stack
var stack = 1;
while (stack > 0 && lookahead != EOF) {
if (prev == '*' && lookahead == '/') stack--;
if (prev == '/' && lookahead == '*') stack++;
while (lookahead != EOF) {
if (prev == '*' && lookahead == '/') {
nextChar();
break;
}
prev = nextChar();
}
if (lookahead == EOF) throw unexpectedEndOfFile();

View File

@@ -3,11 +3,10 @@ x = 10 // end-of-line comment
y = 20 /*
multi
line
/* nested */
comment
*/ z = 30
/// documentation comment
function myFun() = 0
a = 20 // single-line comment running until EOF rather than newline
a = 20 // single-line comment running until EOF rather than newline