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 9 additions and 36 deletions

View File

@@ -70,27 +70,3 @@ initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST .
intconstmult -> MUL const | . intconstmult -> MUL const | .
const -> INTCONST | CHARCONST | STRINGCONST . 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 +1,2 @@
// line1 -- //1234567890
line2 -----x //12345678901
line3
fun main() = 0

View File

@@ -246,14 +246,14 @@ public class LexAn implements AutoCloseable {
buffToken = new Token(start, Token.Symbol.DIV, "/"); buffToken = new Token(start, Token.Symbol.DIV, "/");
return; return;
} }
nextChar();
StringBuilder builder = new StringBuilder(); int length = 0;
while (buffChar != '\n' && buffChar != -1) {
while (buffChar != -1) { length++;
if (buffChar == '\n' && !builder.toString().endsWith("--")) { if (length > 10) {
break; throw new Report.Error(currentLocation(), "Comments can only be 10 characters long");
} }
builder.append((char) buffChar);
nextChar(); nextChar();
} }