Files
ruff/crates/ruff_python_parser
Charlie Marsh 25b10f9d01 Avoid redundant lexer token bookkeeping (#26765)
## Summary

`Lexer::next_token` previously marked the token start before every
token, and the common lexing path marked it again after optional
whitespace handling even when the cursor had not moved. We now track
token starts only on paths that actually lex a token:
interpolated-string and indentation paths mark their ranges explicitly,
while the common path marks the start immediately before consuming the
token. Whitespace-at-EOF errors use an explicit start offset instead of
depending on the current token range.
2026-07-14 10:40:42 -07:00
..
2026-07-09 15:42:27 -04:00
2026-07-09 15:42:27 -04:00

Ruff Python Parser

Ruff's Python parser is a hand-written recursive descent parser which can parse Python source code into an Abstract Syntax Tree (AST). It also utilizes the Pratt parsing technique to parse expressions with different precedence.

Try out the parser in the playground.

Contributing

Refer to the contributing guidelines to get started and GitHub issues with the parser label for issues that need help.

Versioning

This crate is an internal component of Ruff. The Rust API exposed here is unstable and will have frequent breaking changes.

This version (0.0.4) is a component of Ruff 0.15.21. The source can be found here.

See Ruff's crate versioning policy for details on versioning.