mirror of
https://github.com/apple/pkl.git
synced 2026-07-08 14:05:17 +02:00
remove stacking of block comments (#1022)
This commit is contained in:
@@ -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,11 +3,10 @@ x = 10 // end-of-line comment
|
|||||||
y = 20 /*
|
y = 20 /*
|
||||||
multi
|
multi
|
||||||
line
|
line
|
||||||
/* nested */
|
|
||||||
comment
|
comment
|
||||||
*/ z = 30
|
*/ z = 30
|
||||||
|
|
||||||
/// documentation comment
|
/// documentation comment
|
||||||
function myFun() = 0
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user