Predrok 2025 - Naloga 1

This commit is contained in:
Gašper Dobrovoljc 2025-06-04 14:14:46 +02:00
parent 1b45d6a0f9
commit 352085b499
No known key found for this signature in database
GPG Key ID: 0E7E037018CFA5A5
4 changed files with 37 additions and 3 deletions

1
.gitignore vendored
View File

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

View File

@ -70,3 +70,27 @@ 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 | .

5
prg/test.pins25 Normal file
View File

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

View File

@ -247,7 +247,13 @@ public class LexAn implements AutoCloseable {
return;
}
while (buffChar != '\n' && buffChar != -1) {
StringBuilder builder = new StringBuilder();
while (buffChar != -1) {
if (buffChar == '\n' && !builder.toString().endsWith("--")) {
break;
}
builder.append((char) buffChar);
nextChar();
}