summaryrefslogtreecommitdiff
path: root/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/no/eliashaugsbakk/kompilator/IRGeneration')
-rw-r--r--src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerationException.java2
-rw-r--r--src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerator.java12
-rw-r--r--src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/Instructions/Alloc.java4
3 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerationException.java b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerationException.java
index b6a7062..4fef546 100644
--- a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerationException.java
+++ b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerationException.java
@@ -6,7 +6,7 @@ public class IRGenerationException extends RuntimeException {
public IRGenerationException(Position position, String message) {
String pos;
if (position == null) {
- pos = "unknown position";
+ pos = "ukjent posisjon";
} else {
pos = position.line() + ":" + position.column();
}
diff --git a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerator.java b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerator.java
index c72db95..04e8564 100644
--- a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerator.java
+++ b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/IRGenerator.java
@@ -35,7 +35,7 @@ public class IRGenerator {
generateStatement(stmt);
}
if (Main.VERBOSE) {
- IO.println("======= IRGenerator =======");
+ IO.println("======= IR-generator =======");
ir.forEach(IO::println);
IO.println("\n\n\n\n");
}
@@ -57,7 +57,7 @@ public class IRGenerator {
if (assignment.expression instanceof StringLiteral stringLiteral) {
value = stringLiteral.value;
} else {
- throw new IRGenerationException(assignment.position, "Only strings are implemented");
+ throw new IRGenerationException(assignment.position, "Bare strenger er implementert");
}
ir.add(new Assign(assignment.identifier, value));
}
@@ -67,7 +67,7 @@ public class IRGenerator {
if (identifierDecl.initializer instanceof StringLiteral stringLiteral) {
value = stringLiteral.value;
} else {
- throw new IRGenerationException(identifierDecl.position, "Unknown function: " + identifierDecl.initializer);
+ throw new IRGenerationException(identifierDecl.position, "Ukjent funksjon: " + identifierDecl.initializer);
}
ir.add(new Alloc(identifierDecl.identifier, identifierDecl.type.name(), identifierDecl.mutable,
value));
@@ -77,7 +77,7 @@ public class IRGenerator {
if (expr instanceof FunctionCall call) {
generateFunctionCall(call);
} else {
- throw new IRGenerationException(expr.position, "Only expression which can stand alone are functions");
+ throw new IRGenerationException(expr.position, "Bare funksjoner kan stå alene som uttrykk");
}
}
@@ -88,12 +88,12 @@ public class IRGenerator {
fnCall.arguments.forEach(arg -> {
if (arg instanceof StringLiteral stringLiteral) {
String temp = "t" + tempCounter++;
- ir.add(new Alloc(temp, "string", false, stringLiteral.value));
+ ir.add(new Alloc(temp, "streng", false, stringLiteral.value));
arguments.add(temp);
} else if (arg instanceof Identifier identifier) {
arguments.add(identifier.name);
} else {
- throw new IRGenerationException(fnCall.position, "Unknown function: " + arg);
+ throw new IRGenerationException(fnCall.position, "Ukjent funksjon: " + arg);
}
});
diff --git a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/Instructions/Alloc.java b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/Instructions/Alloc.java
index fd6e7b7..655597e 100644
--- a/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/Instructions/Alloc.java
+++ b/src/main/java/no/eliashaugsbakk/kompilator/IRGeneration/Instructions/Alloc.java
@@ -2,9 +2,9 @@ package no.eliashaugsbakk.kompilator.IRGeneration.Instructions;
import org.jetbrains.annotations.NotNull;
-// allocate a new variable: set x: string = "Hello"; mut y: string?;
+// allocate a new variable: set x: streng = "Hello"; mut y: streng?;
//
-// Alloc("x", "string", false, "Hello") // Alloc("y", "string", true, "null")
+// Alloc("x", "streng", false, "Hello") // Alloc("y", "streng", true, "null")
public record Alloc(String name, String type, boolean mutable, String initializer) implements Instruction {
@Override
@NotNull