Which parser generator uses CPython?

I read this page in the documentation and noticed what it says

This is a complete Python grammar, as it is read by the parser generator and used to parse Python source files

However, it’s hard for me to understand what the CPython parser generator uses. So which parser generator uses CPython? Are there other parser generators that could use the grammar on this page without any changes?

+6
source share
1 answer

Python is open source, so you can check the source code ...

The Python source directory contains the "Parser" directory containing "Python.asdl" with a note

  - ASDL four builtin types are identifier, int, string, object

There is also an asdl.py file in the same directory ...

<Preview> "" Implementation of Zephyr syntax definition language. See http://asdl.sourceforge.net/ and http://www.cs.princeton.edu/research/techreps/TR-554-97 Only the top-level decl module is supported, not view. I assume the view is intended to support the browser, and I am not interested in the browser. Changes for Python: add support for module versions ""

So, it looks like this is a custom parser generator. LALR parser generators (1) are not that hard to write.

+3
source

Source: https://habr.com/ru/post/916620/


All Articles