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
@@ -575,11 +575,11 @@ public class Lexer {
private void lexBlockComment() { private void lexBlockComment() {
if (lookahead == EOF) throw unexpectedEndOfFile(); if (lookahead == EOF) throw unexpectedEndOfFile();
var prev = nextChar(); var prev = nextChar();
// block comments in Pkl can stack while (lookahead != EOF) {
var stack = 1; if (prev == '*' && lookahead == '/') {
while (stack > 0 && lookahead != EOF) { nextChar();
if (prev == '*' && lookahead == '/') stack--; break;
if (prev == '/' && lookahead == '*') stack++; }
prev = nextChar(); prev = nextChar();
} }
if (lookahead == EOF) throw unexpectedEndOfFile(); if (lookahead == EOF) throw unexpectedEndOfFile();
@@ -3,7 +3,6 @@ x = 10 // end-of-line comment
y = 20 /* y = 20 /*
multi multi
line line
/* nested */
comment comment
*/ z = 30 */ z = 30