diff options
author | Damien George <damien.p.george@gmail.com> | 2017-02-17 11:30:14 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-02-17 11:30:14 +1100 |
commit | 773278ec3030ea9ed809c5a248fde2278ce4b557 (patch) | |
tree | b5a7824dee8dbd2b06acaed06116a7e56e6f03d4 /py/lexer.c | |
parent | ae436797927c3c9f7ccdc25dd78af3dd279ca7ff (diff) |
py/lexer: Simplify handling of line-continuation error.
Previous to this patch there was an explicit check for errors with line
continuation (where backslash was not immediately followed by a newline).
But this check is not necessary: if there is an error then the remaining
logic of the tokeniser will reject the backslash and correctly produce a
syntax error.
Diffstat (limited to 'py/lexer.c')
-rw-r--r-- | py/lexer.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/py/lexer.c b/py/lexer.c index 5c942f934..ad4fe3fcb 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; } |