Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py/lexer: Accept \n or \r after line continuation character. #3082

Closed
wants to merge 4 commits into from

Conversation

tomlogic
Copy link
Contributor

One of our users ran across another bug in the lexer. If you make use of the line continuation character in paste mode (pasting sample code with long lines) the device throws a SyntaxError.

Minor change requires checking chr1 against both '\n' and '\r' since next_char() only performs newline conversions on chr0.

And now that I've written that, I realized we can bump the CR LF processing up to the chr1 position from chr0, simplifying it slightly, and then we'll only see '\r' in chr2 (where we need to wait to see if it's followed by a '\n' to consume).

Tests for an issue with line continuation failing in paste mode due to the lexer only checking for \n in the "following" character position, before next_char() has had a chance to convert \r and \r\n to \n.
Resolves issue where lexer failed to accept CR after line continuation character.
@dpgeorge
Copy link
Member

And now that I've written that, I realized we can bump the CR LF processing up to the chr1 position from chr0, simplifying it slightly,

Nice work!

I've rebase, squashed and merged this in 6f56412 and 760aa09

@dpgeorge dpgeorge closed this May 12, 2017
kamtom480 pushed a commit to kamtom480/micropython that referenced this pull request Jul 1, 2020
…s_warning

[main] Custom CSS For "Viewing Outdated Docs" Message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants