Skip to content

bpo-42997: Improve error message for missing : before suites #24292

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

Merged
merged 10 commits into from
Feb 2, 2021

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jan 22, 2021

  • Add to the peg generator a new directive ('&&') that allows to expect
    a token and hard fail the parsing if the token is not found. This
    allows to quickly emit syntax errors for missing tokens.

  • Use the new grammar element to hard-fail if the ':' is missing before
    suites.

See #24293 for a simpler (but more verbose) approach

https://bugs.python.org/issue42997

Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicking here and there. Feel free to ignore.

@pablogsal pablogsal requested a review from lysnikolaou January 28, 2021 02:32
@pablogsal pablogsal marked this pull request as ready for review January 31, 2021 22:55
pablogsal and others added 4 commits January 31, 2021 23:01
* Add to the peg generator a new directive ('&&') that allows to expect
  a token and hard fail the parsing if the token is not found. This
  allows to quickly emmit syntax errors for missing tokens.

* Use the new grammar element to hard-fail if the ':' is missing before
  suites.
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
@pablogsal
Copy link
Member Author

I have added a new section to the highlighting code in the grammar docs so the new symbol do not appear

@pablogsal pablogsal requested a review from gvanrossum January 31, 2021 23:56
Copy link
Member

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a long-awaited improvement! 🚀 Really good job! After this we can think about using the forced-expect operator in other places as well.

@pablogsal pablogsal merged commit 58fb156 into python:master Feb 2, 2021
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…H-24292)

* Add to the peg generator a new directive ('&&') that allows to expect
  a token and hard fail the parsing if the token is not found. This
  allows to quickly emmit syntax errors for missing tokens.

* Use the new grammar element to hard-fail if the ':' is missing before
  suites.
@pablogsal pablogsal deleted the bpo-42997 branch May 19, 2021 19:00
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.

5 participants