summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/lexer.c14
-rw-r--r--py/lexer.h13
2 files changed, 9 insertions, 18 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 5c942f9344..ad4fe3fcb8 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -290,18 +290,10 @@ void mp_lexer_to_next(mp_lexer_t *lex) {
next_char(lex);
}
// had_physical_newline will be set on next loop
- } else if (is_char(lex, '\\')) {
- // backslash (outside string literals) must appear just before a physical newline
+ } else if (is_char_and(lex, '\\', '\n')) {
+ // line-continuation, so don't set had_physical_newline
+ next_char(lex);
next_char(lex);
- if (!is_physical_newline(lex)) {
- // SyntaxError: unexpected character after line continuation character
- lex->tok_line = lex->line;
- lex->tok_column = lex->column;
- lex->tok_kind = MP_TOKEN_BAD_LINE_CONTINUATION;
- return;
- } else {
- next_char(lex);
- }
} else {
break;
}
diff --git a/py/lexer.h b/py/lexer.h
index d407192856..d5382fc6a3 100644
--- a/py/lexer.h
+++ b/py/lexer.h
@@ -39,18 +39,17 @@
*/
typedef enum _mp_token_kind_t {
- MP_TOKEN_END, // 0
+ MP_TOKEN_END,
MP_TOKEN_INVALID,
MP_TOKEN_DEDENT_MISMATCH,
MP_TOKEN_LONELY_STRING_OPEN,
- MP_TOKEN_BAD_LINE_CONTINUATION,
- MP_TOKEN_NEWLINE, // 5
- MP_TOKEN_INDENT, // 6
- MP_TOKEN_DEDENT, // 7
+ MP_TOKEN_NEWLINE,
+ MP_TOKEN_INDENT,
+ MP_TOKEN_DEDENT,
- MP_TOKEN_NAME, // 8
+ MP_TOKEN_NAME,
MP_TOKEN_INTEGER,
MP_TOKEN_FLOAT_OR_IMAG,
MP_TOKEN_STRING,
@@ -58,7 +57,7 @@ typedef enum _mp_token_kind_t {
MP_TOKEN_ELLIPSIS,
- MP_TOKEN_KW_FALSE, // 14
+ MP_TOKEN_KW_FALSE,
MP_TOKEN_KW_NONE,
MP_TOKEN_KW_TRUE,
MP_TOKEN_KW___DEBUG__,