Trying to understand the new Python* (*grammer)

For reasons I don't fully understand, I started reading the PEP 617 -- New PEG parser for CPython today morning. Note that the PEP is accepted and the latest Python release (Python v 3.9.0) uses the new PEG parser by default and in Python 3.10, the old LL(1) parser will be removed.



I remember looking at the Python 2.7 grammer when I started using CPython professionally four years back. None of it made sense whatsoever to me so I mostly ignored the Language Reference section of the Python docs.

To cut the story short, see the difference in CPython grammer for yourselves - grammer for version 3.8 and grammer for version 3.9.

I ended up searching for, and coming across the above linked talk by Guido because I wanted to see if anyone had already put together a talk around the new PEG based parser for CPython. I also came across this interesting looking series of blogposts by Guido regarding the work he did to implement the PEG parser for CPython.

I say interesting looking, not interesting because I haven't read any of them yet. That's my homework for the upcoming week.

The talk itself was very useful to understand the PEP better but I still think there is an interesting talk here, mainly around the actual inner working of the PEG parser and/or understanding the grammer using example Python code and/or walking through a Python source code and seeing how it is tokenized and parsed.

It looks like the code Guido used to visualize the PEG parser is open source (should have expected it) and is available on GitHub. Well, there goes the rest of the day, and possibly the weekend.

Popular posts from this blog

Animation using GNUPlot

Thoughts on the National Deep Tech Startup Policy

Arxiv author affiliations using Python