summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-30 18:51:30 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-30 18:51:30 -0400
commit121eda3464cb52e75b6090a22e059a5d0d577296 (patch)
treec3a718f57ab062baebda629193acd3f7bc127e0e
parentonly save test source (diff)
downloadmips-121eda3464cb52e75b6090a22e059a5d0d577296.tar.gz
mips-121eda3464cb52e75b6090a22e059a5d0d577296.tar.bz2
mips-121eda3464cb52e75b6090a22e059a5d0d577296.zip
fix parse strings with new line
-rw-r--r--masm/lex.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/masm/lex.c b/masm/lex.c
index 8b68932..a7707d6 100644
--- a/masm/lex.c
+++ b/masm/lex.c
@@ -101,6 +101,12 @@ static int lex_string(struct lexer *lexer,char text[MAX_LEX_LENGTH])
if (c == '"')
break;
+ // strings cannot span multiple lines
+ if (c == '\n') {
+ ERROR_POS(pos, "reached newline before end of string");
+ return M_ERROR;
+ }
+
// match escape character
if (c == '\\') {
switch (lex_peek(lexer)) {
@@ -123,12 +129,6 @@ static int lex_string(struct lexer *lexer,char text[MAX_LEX_LENGTH])
}
}
- // strings cannot span multiple lines
- if (c == '\n') {
- ERROR_POS(pos, "reached newline before end of string");
- return M_ERROR;
- }
-
if (len + 1 == MAX_LEX_LENGTH) {
ERROR_POS(pos, "string has max length of %d",
MAX_LEX_LENGTH);