4 ms·
There is a formal grammar defined in the CPython repo, implemented in a language called ASDL: https://github.com/python/cpython/blob/main/Parser/Python.asdl ht
by dcreager 1y ago
There is a formal grammar defined in the CPython repo, implemented in a language called ASDL:
https://github.com/python/cpython/blob/main/Parser/Python.asdl https://github.com/python/cpython/blob/main/Parser/Python.as...
ty uses the same AST and parser as ruff. We don't use the ASDL grammar directly, because we store a few syntax nodes differently internally than how they're represented upstream. Our parser is hand-written in Rust. At first, our AST was also entirely hand-written, though we're moving in the direction of auto-generating more of it from a declarative grammar.
https://github.com/astral-sh/ruff/issues/15655 https://github.com/astral-sh/ruff/issues/15655
https://github.com/astral-sh/ruff/tree/main/crates/ruff_python_parser https://github.com/astral-sh/ruff/tree/main/crates/ruff_pyth...
https://github.com/astral-sh/ruff/blob/main/crates/ruff_python_ast/ast.toml https://github.com/astral-sh/ruff/blob/main/crates/ruff_pyth...
- zanie 1y agoditto! but we gave impressively non-overlapping answers