1 Commits

Author SHA1 Message Date
Gašper Dobrovoljc
d64e597414 Replaced mul with times in initializers 2025-06-03 17:16:34 +02:00
6 changed files with 11 additions and 40 deletions

1
.gitignore vendored
View File

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

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 +0,0 @@
// line1 --
line2 -----x
line3
fun main() = 0

View File

@@ -69,6 +69,10 @@ public record Token(Report.Location location, Symbol symbol, String lexeme) impl
* Kljucna beseda {@code in}. * Kljucna beseda {@code in}.
*/ */
IN, IN,
/**
* Kljucna beseda {@code times}.
*/
TIMES,
/** /**
* Kljucna beseda {@code end}. * Kljucna beseda {@code end}.
*/ */

View File

@@ -247,13 +247,7 @@ public class LexAn implements AutoCloseable {
return; return;
} }
StringBuilder builder = new StringBuilder(); while (buffChar != '\n' && buffChar != -1) {
while (buffChar != -1) {
if (buffChar == '\n' && !builder.toString().endsWith("--")) {
break;
}
builder.append((char) buffChar);
nextChar(); nextChar();
} }
@@ -325,6 +319,7 @@ public class LexAn implements AutoCloseable {
case "let" -> Token.Symbol.LET; case "let" -> Token.Symbol.LET;
case "in" -> Token.Symbol.IN; case "in" -> Token.Symbol.IN;
case "end" -> Token.Symbol.END; case "end" -> Token.Symbol.END;
case "times" -> Token.Symbol.TIMES;
default -> null; default -> null;
}; };
} }

View File

@@ -360,9 +360,9 @@ public class SynAn implements AutoCloseable {
private AST.AtomExpr parseIntegerConstantMultiplier() { private AST.AtomExpr parseIntegerConstantMultiplier() {
Token token = lexAn.peekToken(); Token token = lexAn.peekToken();
if (token.symbol() == Token.Symbol.MUL) { if (token.symbol() == Token.Symbol.TIMES) {
// intconstmult -> MUL const // intconstmult -> TIMES const
check(Token.Symbol.MUL); check(Token.Symbol.TIMES);
return parseConstant(); return parseConstant();
} }
// intconstmult -> ε // intconstmult -> ε