Pablo Galindo Salgado <pablog...@gmail.com> added the comment:
>> Well, I was thinking we could just do a simple check in >> _PyPegen_check_tokenizer_errors or _PyPegen_run_parser functions. If the >> last three tokens in the Parser object's tokens array are NAME, >> EQUAL/MINEQUAL/etc and NEWLINE, we raise the special error. Is this the >> right way to do it? I saw that unclosed parentheses' special error are >> checked in the same place. I find that quite inelegant and error prone. A PEG parser is not assured to finish when you think it will finish as it can backtrack and expand to parse left recursive rules. Incorrect syntax must be handled by the parser itself using the parser process, not after the fact. Once the parser has finished, the semantic information is gone and you are left with unstructured tokens. > Yea, I realized that the "expected an expression" error can be used in > multiple places. Could be added one by one? Not sure what you mean here, but this should be added in a single place related to the assignment rule, otherwise is going to be quite difficult to maintain. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44324> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com