Files
Charlie Marsh 48630fbedd Allow match identifiers after a semicolon (#29760)
## Summary

`match` is a soft keyword. It can name a variable, a function, or the
target of an annotated assignment, including after a semicolon.

```python
first(); match = value
first(); match(value)
first(); match[0]: int
```

The parser reported a compound-statement error as soon as it saw the
`match` token. We now check the preceding separator when parsing a match
statement. If the token turns out to be an identifier, speculative
parsing discards the diagnostic. A genuine `match` statement on the same
logical line still produces the original error.
2026-10-27 17:10:45 -07:00
..
2026-10-26 20:14:27 -04:00
2026-10-26 20:14: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.20) is a component of Ruff 0.17.3. The source can be found here.

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