Learn from LL(1) to PEG parser the hard way

Kir Chou

CPython Compiler and Interpreters Python 3

See in schedule

Detailed description
In late 2019, Guido van Rossum wrote a series of articles about PEG parser and gave the talk "Writing a PEG parser for fun and profit" in a couple of conferences, such as North Bay Python, mentioned the motivation of his research and prototype of PEG parser. In late 2020, other authors of PEP 617, Pablo Galindo and Lysandros Nikolaou, (created around mid of 2020) were interviewed on Podcast.__init__ to talk about the result of the new PEG parser in CPython.
Above contents assume the audience with solid compiler fundamental knowledge, but the fact is most People, including this talk's speaker, are not specialized in compiler. And another fact is most of the compiler class in school around the world only covers traditional top-down and bottom-up parsing techniques, not to mention PEG parser that appeared in the early 2000s.
For the above reasons, the speaker will stand on the shoulders of giants and share his hard way after a few months of study. He will talk about the fundamentals of Parser (part of compiler frontend), including CFG, traditional parsing techniques, PEG, Packrat parser, and PEG parser in CPython.

Objective
If you have zero compiler background, you can at least learn the frontend compiler knowledge and how it is used in Python. If you have learned fundamental compiler knowledge in university, this talk will make you recall the traditional top-down and bottom-up parser in the class, and additionally add some relatively new ideas that appear in the early 2000s. If you are a compiler master and know the Packrat parsing research done by Bryan Ford, this talk may still provide you a brief idea about the reason why Guido van Rossum picked LL(1) initially, and PEG parser later.

Outline
- Opening + Self-intro - [1 min]
- Motivation - [2 mins]
- What is parser in CPython? - [3 mins]
- Parser 101 - CFG - [7 mins]
- Parser 101 - Traditional top-down/bottom-up Parser - [10 mins]
- Parser 102 - PEG and PEG parser - [3 mins]
- Parser 102 - Packrat Parser - [7 mins]
- CPython’s PEG Parser - [7.5 mins]
- Take Away - [2.5 mins]
- Q&A

Type: Talk (45 mins); Python level: Intermediate; Domain level: Intermediate


Kir Chou

Google

A code monkey with some experience in search and geo services.

PyCon Experience
- PyCon TW speaker in 2017, 2018, 2019, and 2020.
- PyCon TW agenda reviewer since 2017.
- PyCon JP speaker in 2019, and 2020.