[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Guido van Rossum
Guido van Rossum added the comment: In response to my PEG blogs last year someone showed me an entirely different algorithm, based on first looking for matching parentheses (and other matching things), then for operators by priority, and so on. The approach was designed with C in mind but lo

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: I also concur with Guido here. I have played around with other languages and I dislike getting a long list of expected tokens, that are not helpful, if not actually confusing sometimes. I think that the current generic SyntaxError description together wi

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > (Huh, where did it get __new_parser__?) >From here: https://github.com/python/cpython/blob/master/Parser/pegen/parse.c#L67 -- ___ Python tracker _

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Guido van Rossum
Guido van Rossum added the comment: I had hoped that error labels would get us closer to error recovery, but it appears that is still quite elusive. :-( -- ___ Python tracker ___

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > SyntaxError: Invalid syntax. Expected one of: for, pass, lambda, False, > global, True, __new_parser__, if, raise, continue, not, break, while, None, > del, nonlocal, import, assert, return, class, with, def, try, from, yield Haha, that is a good po

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Guido van Rossum
Guido van Rossum added the comment: Hmm... The errors get long, and by focusing only on keywords they can be misleading. E.g. >>> from x import a b c File "", line 1 from x import a b c ^ SyntaxError: Invalid syntax. Expected one of: as >>> But the most likely erro

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +19350 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20039 ___ Python tracker __

[issue40599] Improve error messages with expected keywords

2020-05-11 Thread Pablo Galindo Salgado
New submission from Pablo Galindo Salgado : Using the new parser, we could improve the plain "syntax error" messages with the tokens/keywords that would have made the parser advance. There is a proof of concept in https://github.com/python/cpython/pull/20039 you can play with. I would like to