1 Commits

Author SHA1 Message Date
Gašper Dobrovoljc
352085b499 Predrok 2025 - Naloga 1 2025-06-04 14:14:46 +02:00
3 changed files with 36 additions and 9 deletions

View File

@@ -69,4 +69,28 @@ restinits -> COMMA initializer restinits | .
initializer -> INTCONST intconstmult | CHARCONST | STRINGCONST . 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,2 +1,5 @@
//1234567890 // line1 --
//12345678901 line2 -----x
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();
int length = 0; StringBuilder builder = new StringBuilder();
while (buffChar != '\n' && buffChar != -1) {
length++; while (buffChar != -1) {
if (length > 10) { if (buffChar == '\n' && !builder.toString().endsWith("--")) {
throw new Report.Error(currentLocation(), "Comments can only be 10 characters long"); break;
} }
builder.append((char) buffChar);
nextChar(); nextChar();
} }