1 Commits

Author SHA1 Message Date
Gašper Dobrovoljc
30fbde8c31 Added multiline comments 2025-06-03 17:45:56 +02:00
4 changed files with 32 additions and 37 deletions

1
.gitignore vendored
View File

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

View File

@@ -70,27 +70,3 @@ initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST .
intconstmult -> MUL const | .
const -> INTCONST | CHARCONST | STRINGCONST .
--------------------------------------------------------------------
//LEFT ASOC.
exp0 = exp0 op other | other
|
v
exp0 = other exp0'
exp0' = op other exp0' | .
//RIGHT ASOC.
exp0 = other op exp0 | other
|
v
exp0 = other exp0'
exp0' = op exp0 | .

View File

@@ -1,5 +0,0 @@
// line1 --
line2 -----x
line3
fun main() = 0

View File

@@ -247,14 +247,37 @@ public class LexAn implements AutoCloseable {
return;
}
StringBuilder builder = new StringBuilder();
nextChar();
if (buffChar == '{') {
int depth = 1;
while (buffChar != -1) {
if (buffChar == '\n' && !builder.toString().endsWith("--")) {
break;
}
builder.append((char) buffChar);
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) {
nextChar();
}
}
nextToken();