Skip to content

Commit

Permalink
Merge pull request #1 from LordOfTrident/main
Browse files Browse the repository at this point in the history
Fix compiler error
  • Loading branch information
MESYETI authored Apr 17, 2024
2 parents 60ff4f5 + db9ffb6 commit 3dae027
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ class Lexer {
string reading;
string extra;

char[char] escapes = [
'n': '\n',
'r': '\r',
't': '\t',
'e': '\x1b',
'"': '"',
'\\': '\\'
];
char[char] escapes;

this() {

escapes = [
'n': '\n',
'r': '\r',
't': '\t',
'e': '\x1b',
'"': '"',
'\\': '\\'
];
}

ErrorInfo GetError() {
Expand Down Expand Up @@ -83,23 +83,23 @@ class Lexer {
if (!reading.OnlyContains("0123456789abcdefABCDEF")) {
Error("Invalid literal");
}

reading = format("%d", reading[2 .. $].to!long(16));
AddToken(TokenType.Integer);
}
else if (reading.startsWith("0b")) {
if (!reading.OnlyContains("01")) {
Error("Invalid binary literal");
}

reading = format("%d", reading[2 .. $].to!long(2));
AddToken(TokenType.Integer);
}
else if (reading.startsWith("0o")) {
if (!reading.OnlyContains("01234567")) {
Error("Invalid octal literal");
}

reading = format("%d", reading[2 .. $].to!long(8));
AddToken(TokenType.Integer);
}
Expand Down Expand Up @@ -214,7 +214,7 @@ class Lexer {

ch = escapes[code[i]];
}

Next();
ExpectChar('\'');

Expand Down

0 comments on commit 3dae027

Please sign in to comment.