fix parse strings with new line
This commit is contained in:
parent
4b18ebe1a0
commit
121eda3464
1 changed files with 6 additions and 6 deletions
12
masm/lex.c
12
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);
|
||||
|
|
Loading…
Reference in a new issue