1 Commits

Author SHA1 Message Date
Gašper Dobrovoljc
b325647ad9 Limited comment length to 10 characters 2025-06-03 22:20:10 +02:00
3 changed files with 8 additions and 30 deletions

1
.gitignore vendored
View File

@@ -3,4 +3,3 @@ out/
*.zip *.zip
prg/**/*.ast prg/**/*.ast
prg/**/*.out prg/**/*.out
prg/**/*.pins25

2
prg/test.pins25 Normal file
View File

@@ -0,0 +1,2 @@
//1234567890
//12345678901

View File

@@ -246,38 +246,15 @@ public class LexAn implements AutoCloseable {
buffToken = new Token(start, Token.Symbol.DIV, "/"); buffToken = new Token(start, Token.Symbol.DIV, "/");
return; return;
} }
nextChar();
nextChar(); int length = 0;
if (buffChar == '{') {
int depth = 1;
nextChar();
while (depth > 0) {
switch (buffChar) {
case '}':
nextChar();
if (buffChar != '/') continue;
nextChar();
if (buffChar != '/') continue;
depth--;
break;
case '/':
nextChar();
if (buffChar != '/') continue;
nextChar();
if (buffChar != '{') continue;
depth++;
break;
case -1:
throw new Report.Error(currentLocation(), "Unterminated multiline comment");
default:
nextChar();
}
}
} else {
while (buffChar != '\n' && buffChar != -1) { while (buffChar != '\n' && buffChar != -1) {
nextChar(); length++;
if (length > 10) {
throw new Report.Error(currentLocation(), "Comments can only be 10 characters long");
} }
nextChar();
} }
nextToken(); nextToken();