2 ms·
As in, how are we parsing the Python code into an AST? CPython uses a generated parser. The grammar is defined in https://github.com/python/cpython/blob/main/G
by zanie 1y ago
As in, how are we parsing the Python code into an AST?
CPython uses a generated parser. The grammar is defined in https://github.com/python/cpython/blob/main/Grammar/python.gram https://github.com/python/cpython/blob/main/Grammar/python.g... which is used to generate the specification at https://docs.python.org/3/reference/grammar.html#full-grammar-specification https://docs.python.org/3/reference/grammar.html#full-gramma...
We use a hand-written parser, in Rust, based on the specification.
We've written that previously at https://astral.sh/blog/ruff-v0.4.0#a-hand-written-parser https://astral.sh/blog/ruff-v0.4.0#a-hand-written-parser