summaryrefslogtreecommitdiff
path: root/src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java
diff options
context:
space:
mode:
authorElias Haugsbakk <[email protected]>2026-09-20 23:02:49 +0200
committerElias Haugsbakk <[email protected]>2026-09-20 23:02:49 +0200
commitc84b76d3848b089cbdd5650b894067fbf6060161 (patch)
tree6f3911f2416725b1e5f6dbb393f542dd8afb5526 /src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java
parent79fc3dd706b968a9249dfd2db6b5175e4e4a85d4 (diff)
Implement the record interpretation in asm construction and implement variables
Diffstat (limited to 'src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java')
-rw-r--r--src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java b/src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java
index 9e9ebfd..fb3e09e 100644
--- a/src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java
+++ b/src/main/java/no/eliashaugsbakk/kompilator/tokenization/Lexer.java
@@ -125,6 +125,18 @@ public class Lexer {
state = NORMAL;
position++; // skip closing "
current = input.charAt(position);
+ } else if (current == '\\' && position + 1 < input.length()) {
+ // The source file contains \n as two characters: '\' and 'n'.
+ // We intercept the backslash and emit the character it represents.
+ position++;
+ current = input.charAt(position);
+ switch (current) {
+ case 'n' -> wordBuffer.append('\n');
+ case 't' -> wordBuffer.append('\t');
+ case 'r' -> wordBuffer.append('\r');
+ case '\\' -> wordBuffer.append('\\');
+ default -> wordBuffer.append(current);
+ }
} else {
wordBuffer.append(current);
}