Added carriage return as escapable character

This commit is contained in:
2023-08-28 22:04:15 +10:00
parent bcc9df928a
commit 308fba1a8c
2 changed files with 4 additions and 0 deletions

View File

@@ -178,6 +178,7 @@ static Toy_Token makeIntegerOrFloat(Toy_Lexer* lexer) {
static bool isEscapableCharacter(char c) { static bool isEscapableCharacter(char c) {
switch (c) { switch (c) {
case 'n': case 'n':
case 'r':
case 't': case 't':
case '\\': case '\\':
case '"': case '"':

View File

@@ -281,6 +281,9 @@ static Toy_Opcode string(Toy_Parser* parser, Toy_ASTNode** nodeHandle) {
case 'n': case 'n':
buffer[strLength++] = '\n'; buffer[strLength++] = '\n';
break; break;
case 'r':
buffer[strLength++] = '\r';
break;
case 't': case 't':
buffer[strLength++] = '\t'; buffer[strLength++] = '\t';
break; break;