Add new C API functions PyPegen_*FromFileObject and use them in interactive mode#38
Add new C API functions PyPegen_*FromFileObject and use them in interactive mode#38lysnikolaou merged 6 commits intopegenfrom
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
There's still something wrong:
(v39) ~/cpygen$ ./python.exe -p new
Python 3.9.0a5+ (heads/pr/38:431f2e06d0, Apr 3 2020, 15:09:29)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Cannot read termcap database;
using dumb terminal settings.
>>> f() = 1
Segmentation fault: 11
(v39) ~/cpygen$
But with your last commit you're probably on the right track...
|
There is one problem here, whose solution is non-trivial. In case one presses Ctrl-D in the interactive interpreter, the current parser returns NULL and signifies an error, which is then caught in I haven't dug into the tokenizer code, but is there a token we can parse, which we could use to signify an EOF? |
|
The tokenizer (which we didn't change) is supposed to detect EOF, and it is supposed to return Is this related to the segfault I reported? |
Could we then change the grammar to accept an ENDMARKER as well when in
I'm currently investigating, but it does not appear so. |
|
I suppose you could accept ENDMARKER and special-case it somewhere else? It must be special-cased somewhere with the old parser right? |
This is related to the call to |
Yes, that's the way. |
gvanrossum
left a comment
There was a problem hiding this comment.
Good enough.
There's one edge case where the old parser is still different: in interactive mode, type
>>> if 1:
... ^D
The old parser quits without an error (which is arguably wrong), the new parser produces a syntax error and then prompts again. I think this is actually in some sense an improvement, so let's see if anyone disagrees.
Agreed. |
No description provided.